HTTP: don't send Content-Length: 0 _and_ Expect: 100-continue
authorDaniel Stenberg <daniel@haxx.se>
Fri, 4 Apr 2014 12:50:18 +0000 (14:50 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 4 Apr 2014 13:46:35 +0000 (15:46 +0200)
Without request body there's no point in asking for 100-continue.

Bug: http://curl.haxx.se/bug/view.cgi?id=1349
Reported-by: JimS
lib/http.c
tests/data/Makefile.am
tests/data/test1001
tests/data/test1002
tests/data/test1411 [new file with mode: 0644]
tests/data/test155
tests/data/test88

index 789ee8f..f803e58 100644 (file)
@@ -2395,9 +2395,11 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
         return result;
     }
 
-    result = expect100(data, conn, req_buffer);
-    if(result)
-      return result;
+    if(postsize != 0) {
+      result = expect100(data, conn, req_buffer);
+      if(result)
+        return result;
+    }
 
     result = Curl_add_buffer(req_buffer, "\r\n", 2); /* end of headers */
     if(result)
index 9a8ee56..5c520c4 100644 (file)
@@ -120,7 +120,7 @@ test1388 test1389 test1390 test1391 test1392 test1393 test1394 test1395 \
 test1396 test1397 \
 \
 test1400 test1401 test1402 test1403 test1404 test1405 test1406 test1407 \
-test1408 test1409 test1410          test1412 test1413 test1414 test1415 \
+test1408 test1409 test1410 test1411 test1412 test1413 test1414 test1415 \
 test1416 test1417 test1418 test1419 \
 \
 test1500 test1501 test1502 test1503 test1504 test1505 test1506 test1507 \
index aabbec9..529e770 100644 (file)
@@ -90,7 +90,6 @@ Host: %HOSTIP:%HTTPPORT
 Accept: */*\r
 Proxy-Connection: Keep-Alive\r
 Content-Length: 0\r
-Expect: 100-continue\r
 \r
 GET http://%HOSTIP:%HTTPPORT/1001 HTTP/1.1\r
 Authorization: Digest username="auser", realm="testrealm", nonce="1053604144", uri="/1001", response="6af4d89c952f4dd4cc215a6878dc499d"\r
index 829444c..c2b811f 100644 (file)
@@ -89,7 +89,6 @@ Host: %HOSTIP:%HTTPPORT
 Accept: */*\r
 Proxy-Connection: Keep-Alive\r
 Content-Length: 0\r
-Expect: 100-continue\r
 \r
 GET http://%HOSTIP:%HTTPPORT/1002.upload1 HTTP/1.1\r
 Authorization: Digest username="auser", realm="testrealm", nonce="1053604144", uri="/1002.upload1", response="198aa9b6acb4b0c71d02a197a5e41f54"\r
diff --git a/tests/data/test1411 b/tests/data/test1411
new file mode 100644 (file)
index 0000000..3ffd586
--- /dev/null
@@ -0,0 +1,60 @@
+<testcase>
+<info>
+<keywords>
+HTTP
+PUT
+</keywords>
+</info>
+
+<reply>
+<data>
+HTTP/1.1 200 OK
+Date: Thu, 09 Nov 2010 14:49:00 GMT
+Server: test-server/fake
+Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT
+ETag: "21025-dc7-39462498"
+Accept-Ranges: bytes
+Content-Length: 6
+Connection: close
+Content-Type: text/html
+Funny-head: yesyes
+
+-foo-
+</data>
+</reply>
+
+
+#
+# Client-side
+<client>
+<server>
+http
+</server>
+
+# make sure there's no Expect: 100-continue when there's no file to send!
+ <name>
+HTTP with zero size file PUT
+ </name>
+ <command>
+http://%HOSTIP:%HTTPPORT/1411 -T log/empty1411
+</command>
+# create an empty file
+<file name="log/empty1411">
+</file>
+</client>
+
+#
+# Verify data after the test has been "shot"
+<verify>
+<strip>
+^User-Agent:.*
+</strip>
+<protocol>
+PUT /1411 HTTP/1.1\r
+Host: %HOSTIP:%HTTPPORT\r
+Accept: */*\r
+Content-Length: 0\r
+\r
+</protocol>
+</verify>
+</testcase>
index 8f76533..0a2a999 100644 (file)
@@ -121,7 +121,6 @@ Authorization: NTLM TlRMTVNTUAABAAAABoIIAAAAAAAAAAAAAAAAAAAAAAA=
 Host: %HOSTIP:%HTTPPORT\r
 Accept: */*\r
 Content-Length: 0\r
-Expect: 100-continue\r
 \r
 PUT /155 HTTP/1.1\r
 Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAACeAJ4AWAAAAAAAAAD2AAAACAAIAPYAAAAIAAgA/gAAAAAAAAAAAAAABoKBAFuu0VIvKeMdPwjDPk7eAnwxMjM0NTY3OC1uDhL9DbZXt27JqdXMDkABAQAAAAAAAACAPtXesZ0BMTIzNDU2NzgAAAAAAgAEAEMAQwABABIARQBMAEkAUwBBAEIARQBUAEgABAAYAGMAYwAuAGkAYwBlAGQAZQB2AC4AbgB1AAMALABlAGwAaQBzAGEAYgBlAHQAaAAuAGMAYwAuAGkAYwBlAGQAZQB2AC4AbgB1AAAAAAAAAAAAdGVzdHVzZXJjdXJsaG9zdA==\r
index 2495aec..878b7db 100644 (file)
@@ -82,7 +82,6 @@ PUT /88 HTTP/1.1
 Host: %HOSTIP:%HTTPPORT\r
 Accept: */*\r
 Content-Length: 0\r
-Expect: 100-continue\r
 \r
 PUT /88 HTTP/1.1\r
 Authorization: Digest username="testuser", realm="testrealm", nonce="1053604145", uri="/88", response="78a49fa53d0c228778297687d4168e71"\r