]> granicus.if.org Git - curl/commitdiff
Remove stray CRLF in chunk-encoded content-free request bodies
authorFabian Keil <fk@fabiankeil.de>
Sun, 25 Nov 2012 17:34:01 +0000 (18:34 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 26 Nov 2012 14:28:53 +0000 (15:28 +0100)
.. that are sent when auth-negotiating before a chunked
upload or when setting the 'Transfer-Encoding: chunked'
header and intentionally sending no content.

Adjust test565 and test1333 accordingly.

lib/http.c
tests/data/test1333
tests/data/test565

index 4eee832216069391c972f494d18303094950cf45..965b375037bc9d37fc4c69879bbd63f8f7df577a 100644 (file)
@@ -2484,15 +2484,19 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
           if(postsize) {
             /* Append the POST data chunky-style */
             result = Curl_add_bufferf(req_buffer, "%x\r\n", (int)postsize);
-            if(CURLE_OK == result)
+            if(CURLE_OK == result) {
               result = Curl_add_buffer(req_buffer, data->set.postfields,
                                        (size_t)postsize);
+              if(CURLE_OK == result)
+                 result = Curl_add_buffer(req_buffer, "\r\n", 2);
+              included_body = postsize + 2;
+            }
           }
           if(CURLE_OK == result)
             result = Curl_add_buffer(req_buffer,
-                                     "\x0d\x0a\x30\x0d\x0a\x0d\x0a", 7);
-          /* CR  LF   0  CR  LF  CR  LF */
-          included_body = postsize + 7;
+                                     "\x30\x0d\x0a\x0d\x0a", 5);
+          /* 0  CR  LF  CR  LF */
+          included_body += 5;
         }
         if(result)
           return result;
@@ -2526,8 +2530,8 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
         /* Chunky upload is selected and we're negotiating auth still, send
            end-of-data only */
         result = Curl_add_buffer(req_buffer,
-                                 "\x0d\x0a\x30\x0d\x0a\x0d\x0a", 7);
-        /* CR  LF   0  CR  LF  CR  LF */
+                                 "\x30\x0d\x0a\x0d\x0a", 5);
+        /* 0  CR  LF  CR  LF */
         if(result)
           return result;
       }
index 51ba75b4e49140771e0c796227eeec54b67dce93..a2ea3014375061b4bd6a3d4b2ab2b4955d6766fc 100644 (file)
@@ -47,7 +47,6 @@ Accept: */*
 Transfer-Encoding: chunked\r
 Content-Type: application/x-www-form-urlencoded\r
 \r
-\r
 0\r
 \r
 </protocol>
index fdf75a5f88ccbc16c2f627d2a3be32e25383d69c..b8d12b45c686e7acf67dafea36c4c3fdfe039cf0 100644 (file)
@@ -79,7 +79,6 @@ Accept: */*
 Transfer-Encoding: chunked\r
 Content-Type: application/x-www-form-urlencoded\r
 \r
-\r
 0\r
 \r
 POST /565 HTTP/1.1\r