]> granicus.if.org Git - curl/commitdiff
http: refuse to pass on response body with NO_NODY was set
authorDaniel Stenberg <daniel@haxx.se>
Fri, 9 Sep 2016 13:57:44 +0000 (15:57 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Sun, 11 Sep 2016 10:02:07 +0000 (12:02 +0200)
... like when a HTTP/0.9 response comes back without any headers at all
and just a body this now prevents that body from being sent to the
callback etc.

Adapted test 1144 to verify.

Fixes #973

Assisted-by: Ray Satiro
lib/transfer.c
tests/data/test1144

index 2fad6f32fc1a0944684ed9b35f8bdec50faee6f2..24bdf2155b2f7eb38d7b9aceeace01f3a84a56f0 100644 (file)
@@ -535,6 +535,13 @@ static CURLcode readwrite_data(struct Curl_easy *data,
        is non-headers. */
     if(k->str && !k->header && (nread > 0 || is_empty_data)) {
 
+      if(data->set.opt_no_body) {
+        /* data arrives although we want none, bail out */
+        streamclose(conn, "ignoring body");
+        *done = TRUE;
+        return CURLE_WEIRD_SERVER_REPLY;
+      }
+
 #ifndef CURL_DISABLE_HTTP
       if(0 == k->bodywrites && !is_empty_data) {
         /* These checks are only made the first time we are about to
index 3b4a1b47959e9133a74222203b7541eea86e0ae1..3fb90936a032980e1ca97a9fb56526bc250b1e7b 100644 (file)
@@ -30,6 +30,10 @@ data to
 
 verify
 </data>
+# make sure no data is written
+<datacheck nonewline="yes">
+
+</datacheck>
 </reply>
 
 #
@@ -58,5 +62,8 @@ Host: %HOSTIP:%HTTPPORT
 Accept: */*\r
 \r
 </protocol>
+<errorcode>
+8
+</errorcode>
 </verify>
 </testcase>