>From a41bb544767b7f6adcca84f9b6b73302dc934a65 Mon Sep 17 00:00:00 2001 From: Tim Ruehsen
Date: Tue, 22 Apr 2014 13:06:00 +0200 Subject: [PATCH] fixed 204 response handling, added new Test-204.px --- src/ChangeLog | 4 ++++ src/http.c | 17 +++++++++++++++++ tests/ChangeLog | 6 ++++++ tests/Makefile.am | 1 + tests/Test-204.px | 35 +++++++++++++++++++++++++++++++++++ tests/run-px | 1 + 6 files changed, 64 insertions(+) create mode 100644 tests/Test-204.px diff --git a/src/ChangeLog b/src/ChangeLog index 4f88172..e8069bd 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2014-04-22 Tim Ruehsen + + * http.c (gethttp): Fix 204 response handling + 2014-03-26 Darshit Shah * ftp.c (getftp): Rearrange parameters to fix compiler warning diff --git a/src/http.c b/src/http.c index 024fc46..c8ff37d 100644 --- a/src/http.c +++ b/src/http.c @@ -2614,6 +2614,23 @@ read_header: } resp_free (resp); + if (statcode == HTTP_STATUS_NO_CONTENT) + { + /* 204 response has no body (RFC 2616, 4.3) */ + *dt |= RETROKF; + + /* In case the caller cares to look... */ + hs->len = 0; + hs->res = 0; + hs->restval = 0; + + CLOSE_FINISH (sock); + xfree_null (type); + xfree (head); + + return RETRFINISHED; + } + /* 20x responses are counted among successful by default. */ if (H_20X (statcode)) *dt |= RETROKF; diff --git a/tests/ChangeLog b/tests/ChangeLog index c3baac3..dc69402 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,9 @@ +2014-40-22 Tim Ruehsen + + * Test-204.px: added file + * run-px: added Test-204.px + * Makefile.am: added Test-204.px + 2014-02-24 Yousong Zhou (tiny change) * tests/Test--httpsonly-r.px: Add feature constraint on https. diff --git a/tests/Makefile.am b/tests/Makefile.am index bea262e..e6742b9 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -139,6 +139,7 @@ EXTRA_DIST = FTPServer.pm FTPTest.pm HTTPServer.pm HTTPTest.pm \ Test--spider-r--no-content-disposition-trivial.px \ Test--spider-r.px \ Test--httpsonly-r.px \ + Test-204.px \ run-px certs check_PROGRAMS = unit-tests diff --git a/tests/Test-204.px b/tests/Test-204.px new file mode 100644 index 0000000..6f3e8dc --- /dev/null +++ b/tests/Test-204.px @@ -0,0 +1,35 @@ +#!/usr/bin/env perl + +use strict; +use warnings; + +use HTTPTest; + + +############################################################################### + +# code, msg, headers, content +my %urls = ( + '/dummy' => { + code => "204", + msg => "Dontcare", + }, +); + +my $cmdline = $WgetTest::WGETPATH . " http://localhost:{{port}}/dummy"; + +my $expected_error_code = 0; + +my %expected_downloaded_files = ( +); + +############################################################################### + +my $the_test = HTTPTest->new (name => "Test-204", + input => \%urls, + cmdline => $cmdline, + errcode => $expected_error_code, + output => \%expected_downloaded_files); +exit $the_test->run(); + +# vim: et ts=4 sw=4 diff --git a/tests/run-px b/tests/run-px index 402f229..49dcb74 100755 --- a/tests/run-px +++ b/tests/run-px @@ -91,6 +91,7 @@ my @tests = ( 'Test--start-pos.px', 'Test-ftp--start-pos.px', 'Test--start-pos--continue.px', + 'Test-204.px', ); foreach my $var (qw(SYSTEM_WGETRC WGETRC)) { -- 1.9.2