]> sjero.net Git - wget/commitdiff
fixed 204 response handling, added new Test-204.px
authorTim Ruehsen <tim.ruehsen@gmx.de>
Tue, 22 Apr 2014 11:06:00 +0000 (13:06 +0200)
committerGiuseppe Scrivano <gscrivan@redhat.com>
Thu, 24 Apr 2014 11:27:44 +0000 (13:27 +0200)
src/ChangeLog
src/http.c
tests/ChangeLog
tests/Makefile.am
tests/Test-204.px [new file with mode: 0644]
tests/run-px

index 4f88172bce30ee293b9aa8e7eec5df6c21e7db73..e8069bda540b59752f60685be52a951babfd6790 100644 (file)
@@ -1,3 +1,7 @@
+2014-04-22  Tim Ruehsen  <tim.ruehsen@gmx.de>
+
+        * http.c (gethttp): Fix 204 response handling
+
 2014-03-26  Darshit Shah  <darnir@gmail.com>
 
        * ftp.c (getftp): Rearrange parameters to fix compiler warning
 2014-03-26  Darshit Shah  <darnir@gmail.com>
 
        * ftp.c (getftp): Rearrange parameters to fix compiler warning
index 8bba70dfdb5cb0ea0fa192c01361559e18e81af4..00a35b324aae5ed9672d6a91c4e6bb6d42ecbaf6 100644 (file)
@@ -2618,6 +2618,22 @@ read_header:
   if (H_20X (statcode))
     *dt |= RETROKF;
 
   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)
     {
   /* Return if redirected.  */
   if (H_REDIRECTED (statcode) || statcode == HTTP_STATUS_MULTIPLE_CHOICES)
     {
index 83d380b83a40ed29a58312a0c165704dfa24ff88..a2d85804a706f630f5a49d69ea53300cb7ce94bf 100644 (file)
@@ -1,3 +1,9 @@
+2014-40-22  Tim Ruehsen <tim.ruehsen@gmx.de>
+
+        * Test-204.px: added file
+        * run-px: added Test-204.px
+        * Makefile.am: added Test-204.px
+
 2014-04-22  Giuseppe Scrivano  <gscrivan@redhat.com>
 
        * Makefile.am (EXTRA_DIST): Add missing Test--start-pos.px,
 2014-04-22  Giuseppe Scrivano  <gscrivan@redhat.com>
 
        * Makefile.am (EXTRA_DIST): Add missing Test--start-pos.px,
index 76fe2f09b020a8249d3c1d4ea615f66cf18ec344..fdde94d6dea6639469567406117ea907e036bc40 100644 (file)
@@ -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--start-pos.px \
              Test--start-pos--continue.px \
              Test--httpsonly-r.px \
+             Test-204.px \
              run-px certs
 
 check_PROGRAMS = unit-tests
              run-px certs
 
 check_PROGRAMS = unit-tests
diff --git a/tests/Test-204.px b/tests/Test-204.px
new file mode 100644 (file)
index 0000000..6f3e8dc
--- /dev/null
@@ -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
index 402f22929d93340db17f6f2c792f488be744c814..49dcb740a2c99601d0915e05a77844c4079a0099 100755 (executable)
@@ -91,6 +91,7 @@ my @tests = (
     'Test--start-pos.px',
     'Test-ftp--start-pos.px',
     'Test--start-pos--continue.px',
     'Test--start-pos.px',
     'Test-ftp--start-pos.px',
     'Test--start-pos--continue.px',
+    'Test-204.px',
 );
 
 foreach my $var (qw(SYSTEM_WGETRC WGETRC)) {
 );
 
 foreach my $var (qw(SYSTEM_WGETRC WGETRC)) {