From 848d7537e17a6ca6b5e91b016e1490b1703b7331 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 | 16 ++++++++++++++++ tests/ChangeLog | 6 ++++++ tests/Makefile.am | 1 + tests/Test-204.px | 35 +++++++++++++++++++++++++++++++++++ tests/run-px | 1 + 6 files changed, 63 insertions(+) create mode 100644 tests/Test-204.px diff --git a/src/ChangeLog b/src/ChangeLog index 4f88172b..e8069bda 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 8bba70df..00a35b32 100644 --- a/src/http.c +++ b/src/http.c @@ -2618,6 +2618,22 @@ read_header: if (H_20X (statcode)) *dt |= RETROKF; + if (statcode == HTTP_STATUS_NO_CONTENT) + { + /* 204 response has no body (RFC 2616, 4.3) */ + + /* 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; + } + /* Return if redirected. */ if (H_REDIRECTED (statcode) || statcode == HTTP_STATUS_MULTIPLE_CHOICES) { diff --git a/tests/ChangeLog b/tests/ChangeLog index 83d380b8..a2d85804 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-04-22 Giuseppe Scrivano * Makefile.am (EXTRA_DIST): Add missing Test--start-pos.px, diff --git a/tests/Makefile.am b/tests/Makefile.am index 76fe2f09..fdde94d6 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -142,6 +142,7 @@ EXTRA_DIST = FTPServer.pm FTPTest.pm HTTPServer.pm HTTPTest.pm \ Test--start-pos.px \ Test--start-pos--continue.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 00000000..6f3e8dc0 --- /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 402f2292..49dcb740 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)) { -- 2.39.2