]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
http: don't send 100-continue for short PUT requests
authorDan Fandrich <dan@coneharvesters.com>
Fri, 10 Mar 2023 21:15:43 +0000 (13:15 -0800)
committerDan Fandrich <dan@coneharvesters.com>
Sun, 12 Mar 2023 02:57:19 +0000 (18:57 -0800)
This is already how curl is documented to behave in Everything curl, but
in actuality only short POSTs skip this. This should knock 30 seconds
off a full run of the test suite since the 100-continue timeout will no
longer be hit.

Closes #10740

34 files changed:
docs/FAQ
lib/http.c
tests/data/test10
tests/data/test1001
tests/data/test1002
tests/data/test1030
tests/data/test1041
tests/data/test1051
tests/data/test1055
tests/data/test1071
tests/data/test1075
tests/data/test1131
tests/data/test1285
tests/data/test1524
tests/data/test1525
tests/data/test1526
tests/data/test154
tests/data/test155
tests/data/test156
tests/data/test1948
tests/data/test2058
tests/data/test2059
tests/data/test2060
tests/data/test208
tests/data/test218
tests/data/test281
tests/data/test33
tests/data/test357
tests/data/test364
tests/data/test490
tests/data/test491
tests/data/test492
tests/data/test58
tests/data/test88

index c8ba7feb3d6fc5f22f6d91c14a06d3387a126f45..b96357cc1ad8c65ab2b0e86245213da256d0ac87 100644 (file)
--- a/docs/FAQ
+++ b/docs/FAQ
@@ -990,11 +990,10 @@ FAQ
 
   4.16 My HTTP POST or PUT requests are slow
 
-  libcurl makes all POST and PUT requests (except for POST requests with a
-  tiny request body) use the "Expect: 100-continue" header. This header
-  allows the server to deny the operation early so that libcurl can bail out
-  before having to send any data. This is useful in authentication
-  cases and others.
+  libcurl makes all POST and PUT requests (except for requests with a small
+  request body) use the "Expect: 100-continue" header. This header allows the
+  server to deny the operation early so that libcurl can bail out before having
+  to send any data. This is useful in authentication cases and others.
 
   However, many servers do not implement the Expect: stuff properly and if the
   server does not respond (positively) within 1 second libcurl will continue
index 299a499f0091a2af2b56de42a8b5217e63b059d6..faa486cc6f890fdd11eb92aa3b8b4c59eb6b60af 100644 (file)
@@ -2340,7 +2340,16 @@ CURLcode Curl_http_bodysend(struct Curl_easy *data, struct connectdata *conn,
         return result;
     }
 
-    if(http->postsize) {
+    /* For really small puts we don't use Expect: headers at all, and for
+       the somewhat bigger ones we allow the app to disable it. Just make
+       sure that the expect100header is always set to the preferred value
+       here. */
+    ptr = Curl_checkheaders(data, STRCONST("Expect"));
+    if(ptr) {
+      data->state.expect100header =
+        Curl_compareheader(ptr, STRCONST("Expect:"), STRCONST("100-continue"));
+    }
+    else if(http->postsize > EXPECT_100_THRESHOLD || http->postsize < 0) {
       result = expect100(data, conn, r);
       if(result)
         return result;
index 5b5534b674a98ee829fae7cfdabcbea5aa945db2..5dd9356cd463cf89a74e58b202b29b6dc2a54b29 100644 (file)
@@ -49,7 +49,6 @@ Host: %HOSTIP:%HTTPPORT
 User-Agent: curl/%VERSION\r
 Accept: */*\r
 Content-Length: 78\r
-Expect: 100-continue\r
 \r
 Weird
      file
index df42f713430792b6ca46eaf6b52894812e79722b..738afb27f91ff8264645ac2ea65cc1ffe67a7c84 100644 (file)
@@ -98,7 +98,6 @@ User-Agent: curl/%VERSION
 Accept: */*\r
 Proxy-Connection: Keep-Alive\r
 Content-Length: 3\r
-Expect: 100-continue\r
 \r
 st
 </protocol>
index ca58be6f4e8d58deb6aeb63bdad79ad858b74732..d929ae724c1953f383881b740273fad5c1f48a9b 100644 (file)
@@ -97,7 +97,6 @@ User-Agent: curl/%VERSION
 Accept: */*\r
 Proxy-Connection: Keep-Alive\r
 Content-Length: 3\r
-Expect: 100-continue\r
 \r
 st
 GET http://%HOSTIP:%HTTPPORT/%TESTNUMBER.upload2 HTTP/1.1\r
@@ -116,7 +115,6 @@ User-Agent: curl/%VERSION
 Accept: */*\r
 Proxy-Connection: Keep-Alive\r
 Content-Length: 3\r
-Expect: 100-continue\r
 \r
 st
 </protocol>
index bd4e18f1a12cb0c2e9a556890572039c4ebee61e..5824977023df87cf0f89e34d643fba5104372e79 100644 (file)
@@ -85,7 +85,6 @@ Host: %HOSTIP:%HTTPPORT
 User-Agent: curl/%VERSION\r
 Accept: */*\r
 Content-Length: 85\r
-Expect: 100-continue\r
 \r
 This is data we upload with PUT
 a second line
@@ -97,7 +96,6 @@ Authorization: Digest username="testuser", realm="gimme all yer s3cr3ts", nonce=
 User-Agent: curl/%VERSION\r
 Accept: */*\r
 Content-Length: 85\r
-Expect: 100-continue\r
 \r
 This is data we upload with PUT
 a second line
index 5580b9589a827eadd625d5755f9457eae43a6b86..6c3c01cbcf32a47c2a1b88f44cee696342fcfc89 100644 (file)
@@ -59,7 +59,6 @@ Content-Range: bytes 0-99/100
 User-Agent: curl/%VERSION\r
 Accept: */*\r
 Content-Length: 100\r
-Expect: 100-continue\r
 \r
 012345678
 012345678
index 5a1cf34c6ffb05573f0723ecaa7e19ddf314bcba..9c082067b0ffc300210e9d9604589e18fd663b9f 100644 (file)
@@ -85,7 +85,6 @@ Host: %HOSTIP:%HTTPPORT
 User-Agent: curl/%VERSION\r
 Accept: */*\r
 Content-Length: 78\r
-Expect: 100-continue\r
 \r
 Weird
      file
@@ -101,7 +100,6 @@ Host: %HOSTIP:%HTTPPORT
 User-Agent: curl/%VERSION\r
 Accept: */*\r
 Content-Length: 78\r
-Expect: 100-continue\r
 \r
 Weird
      file
index f6f37531f81eab42bc5abe30853a4f261796bc87..b27b35b81d0a310eae7f2f33f2204ee371f10885 100644 (file)
@@ -60,7 +60,6 @@ Host: %HOSTIP:%HTTPPORT
 User-Agent: curl/%VERSION\r
 Accept: */*\r
 Content-Length: 78\r
-Expect: 100-continue\r
 \r
 Weird
      file
index 6c6947227ece6c7ee9987eb66e3e480c1dae23c8..9eee479705ea1e155abcfa695018c2f7a65ee00b 100644 (file)
@@ -91,7 +91,6 @@ Host: %HOSTIP:%HTTPPORT
 User-Agent: curl/%VERSION\r
 Accept: */*\r
 Content-Length: 85\r
-Expect: 100-continue\r
 \r
 This is data we upload with PUT
 a second line
index 2d111f284153e9c9a74df20f210ae672729a8aef..d55468138f14ddeae68547bd260d82fdfdec4d38 100644 (file)
@@ -70,7 +70,6 @@ Host: %HOSTIP:%HTTPPORT
 User-Agent: curl/%VERSION\r
 Accept: */*\r
 Content-Length: 85\r
-Expect: 100-continue\r
 \r
 This is data we upload with PUT
 a second line
@@ -82,7 +81,6 @@ Authorization: Basic dGVzdHVzZXI6dGVzdHBhc3M=
 User-Agent: curl/%VERSION\r
 Accept: */*\r
 Content-Length: 85\r
-Expect: 100-continue\r
 \r
 This is data we upload with PUT
 a second line
index 8ead289c565abc2e60da1205dc0b1a60d8156e7a..685e80e89428066932718a3054e05937aa905e38 100644 (file)
@@ -51,7 +51,7 @@ http
 HTTP PUT expect 100-continue with a 400
  </name>
  <command option="no-output">
--T log/file%TESTNUMBER http://%HOSTIP:%HTTPPORT/%TESTNUMBER -T log/file%TESTNUMBER http://%HOSTIP:%HTTPPORT/%TESTNUMBER0001
+-H "Expect: 100-continue" -T log/file%TESTNUMBER http://%HOSTIP:%HTTPPORT/%TESTNUMBER -T log/file%TESTNUMBER http://%HOSTIP:%HTTPPORT/%TESTNUMBER0001
 </command>
 </client>
 
@@ -79,15 +79,15 @@ PUT /%TESTNUMBER HTTP/1.1
 Host: %HOSTIP:%HTTPPORT\r
 User-Agent: curl/%VERSION\r
 Accept: */*\r
-Content-Length: 100\r
 Expect: 100-continue\r
+Content-Length: 100\r
 \r
 PUT /%TESTNUMBER0001 HTTP/1.1\r
 Host: %HOSTIP:%HTTPPORT\r
 User-Agent: curl/%VERSION\r
 Accept: */*\r
-Content-Length: 100\r
 Expect: 100-continue\r
+Content-Length: 100\r
 \r
 </protocol>
 </verify>
index e5a38e071dbd31ce99f0edd13ac9128ec15d5375..0a907b60ec2481354547109de07a033f0f7eb7d9 100644 (file)
@@ -85,7 +85,6 @@ Authorization: Digest username="auser", realm="testrealm", nonce="1053604144", u
 User-Agent: curl/%VERSION\r
 Accept: */*\r
 Content-Length: 85\r
-Expect: 100-continue\r
 \r
 This is data we upload with PUT
 a second line
index 39da646f59ac547e8d5a33a4248c0853f87579df..65831ddc5d326cc5255a2314f89a572acc4a5e9e 100644 (file)
@@ -61,7 +61,6 @@ Host: %HOSTIP:%HTTPPORT
 User-Agent: curl/%VERSION\r
 Accept: */*\r
 Content-Length: 4\r
-Expect: 100-continue\r
 \r
 moo
 GET /blah/moo.html&testcase=/%TESTNUMBER0002 HTTP/1.1\r
index 34495b7e57a33c6bdebfd3172c5bc68420aa4af2..33f71c877cb5a5d96391e63443066c750be8ed05 100644 (file)
@@ -71,7 +71,6 @@ Host: the.old.moo.%TESTNUMBER:%HTTPPORT
 Accept: */*\r
 User-Agent: Http Agent\r
 Content-Length: 13\r
-Expect: 100-continue\r
 \r
 Hello Cloud!
 </protocol>
index 39e8668e8bc513cbf8b256c4bef3d2800c826580..4076124054d47d74e334466bdf8f26fcdf3d3893 100644 (file)
@@ -73,7 +73,6 @@ Host: the.old.moo.%TESTNUMBER:%HTTPPORT
 Accept: */*\r
 User-Agent: Http Agent\r
 Content-Length: 13\r
-Expect: 100-continue\r
 \r
 Hello Cloud!
 </protocol>
index c0f76514d750fe61e401b912d6290b729876ef00..0b180b90a90085c7abb72262a27d0fc6739d98f0 100644 (file)
@@ -10,9 +10,6 @@ HTTP Digest auth
 
 # Server-side
 <reply>
-<servercmd>
-auth_required
-</servercmd>
 <data>
 HTTP/1.1 401 Authorization Required swsclose\r
 Server: Apache/1.3.27 (Darwin) PHP/4.1.2\r
@@ -88,15 +85,17 @@ Host: %HOSTIP:%HTTPPORT
 User-Agent: curl/%VERSION\r
 Accept: */*\r
 Content-Length: 85\r
-Expect: 100-continue\r
 \r
+This is data we upload with PUT
+a second line
+line three
+four is the number of lines
 PUT /%TESTNUMBER HTTP/1.1\r
 Host: %HOSTIP:%HTTPPORT\r
 Authorization: Digest username="testuser", realm="gimme all yer s3cr3ts", nonce="11223344", uri="/%TESTNUMBER", response="b71551e12d1c456e47d8388ecb2edeca"\r
 User-Agent: curl/%VERSION\r
 Accept: */*\r
 Content-Length: 85\r
-Expect: 100-continue\r
 \r
 This is data we upload with PUT
 a second line
index 2d916c9759c23769700d1feb4a404b9d0e1c9f1e..353edb9fa84048fdf7828ccfd8f5ea17d20431ea 100644 (file)
@@ -10,9 +10,6 @@ NTLM
 
 # Server-side
 <reply>
-<servercmd>
-auth_required
-</servercmd>
 <data>
 HTTP/1.1 401 NTLM Authorization Required swsclose\r
 Server: Apache/1.3.27 (Darwin) PHP/4.1.2\r
@@ -105,8 +102,11 @@ Host: %HOSTIP:%HTTPPORT
 User-Agent: curl/%VERSION\r
 Accept: */*\r
 Content-Length: 85\r
-Expect: 100-continue\r
 \r
+This is data we upload with PUT
+a second line
+line three
+four is the number of lines
 PUT /%TESTNUMBER HTTP/1.1\r
 Host: %HOSTIP:%HTTPPORT\r
 Authorization: NTLM TlRMTVNTUAABAAAABoIIAAAAAAAAAAAAAAAAAAAAAAA=\r
@@ -120,7 +120,6 @@ Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAAL
 User-Agent: curl/%VERSION\r
 Accept: */*\r
 Content-Length: 85\r
-Expect: 100-continue\r
 \r
 This is data we upload with PUT
 a second line
index 94bb3393f85204861df7cb1908fc7f07838b8d20..35de74d24054f89f58c8dc251ea6542408608676 100644 (file)
@@ -46,7 +46,6 @@ Host: %HOSTIP:%HTTPPORT
 User-Agent: curl/%VERSION\r
 Accept: */*\r
 Content-Length: 85\r
-Expect: 100-continue\r
 \r
 This is data we upload with PUT
 a second line
index 639523d99591c584fc5628a2e29076fc3295bed2..4c50b02acd718bb730bad97cac7955e4993d2268 100644 (file)
@@ -58,7 +58,6 @@ PUT /%TESTNUMBER HTTP/1.1
 Host: %HOSTIP:%HTTPPORT\r
 Accept: */*\r
 Content-Length: 22\r
-Expect: 100-continue\r
 \r
 This is test PUT data
 POST /1948 HTTP/1.1\r
index c400f26307228d35901a6216ff60d85972792fe2..ba4a53e8440b77757057729d2cdb2ad46d854e28 100644 (file)
@@ -98,7 +98,6 @@ User-Agent: curl/%VERSION
 Accept: */*\r
 Proxy-Connection: Keep-Alive\r
 Content-Length: 3\r
-Expect: 100-continue\r
 \r
 st
 </protocol>
index 3170c99a11c740084c6f02689baef84e439e72a5..4776970d32dd563eddbbf0a2b30b75553a01e2f2 100644 (file)
@@ -98,7 +98,6 @@ User-Agent: curl/%VERSION
 Accept: */*\r
 Proxy-Connection: Keep-Alive\r
 Content-Length: 3\r
-Expect: 100-continue\r
 \r
 st
 </protocol>
index 11dd155265d3625c0687fba7de4bc53094893841..9a8057d514a450f403f3d9f4e8d99f7187bfeb5f 100644 (file)
@@ -98,7 +98,6 @@ User-Agent: curl/%VERSION
 Accept: */*\r
 Proxy-Connection: Keep-Alive\r
 Content-Length: 3\r
-Expect: 100-continue\r
 \r
 st
 </protocol>
index d081b5131f74f93251f411619bdbe1851e2905ac..a6c0eea492f17e0e62536c69813ae948bc12a632 100644 (file)
@@ -58,7 +58,6 @@ User-Agent: curl/%VERSION
 Accept: */*\r
 Proxy-Connection: Keep-Alive\r
 Content-Length: 78\r
-Expect: 100-continue\r
 \r
 Weird
      file
index dc71442e87f2bdf5b4660eda2c020ccb195262db..08ee8c6d45bde7aa8c057019ac59cbbc7e71a4b0 100644 (file)
@@ -45,7 +45,6 @@ Host: %HOSTIP:%HTTPPORT
 User-Agent: curl/%VERSION\r
 Accept: */*\r
 Transfer-Encoding: chunked\r
-Expect: 100-continue\r
 \r
 %if hyper
 1E\r
index 4210f7b8f04c6ceb6c79857bb118f36713a64882..f92b753af2728804d37112207a8492e912a41cd6 100644 (file)
@@ -49,7 +49,6 @@ Host: %HOSTIP:%HTTPPORT
 User-Agent: curl/%VERSION\r
 Accept: */*\r
 Content-Length: 38\r
-Expect: 100-continue\r
 \r
 Weird
      file
index 1b9c898ef988be0d6923e6c86496b7b26f4c81a7..56024842cca43ca3e190cae9750918dea04c4c55 100644 (file)
@@ -49,7 +49,6 @@ Content-Range: bytes 50-99/100
 User-Agent: curl/%VERSION\r
 Accept: */*\r
 Content-Length: 50\r
-Expect: 100-continue\r
 \r
 012345678
 012345678
index 8ddcdc90d1b64865f0a99c79bc1747d1d0808557..4c204f60ef799d76eb4d00261bc2ac23d8e8983d 100644 (file)
@@ -53,16 +53,9 @@ HTTP PUT with Expect: 100-continue and 417 response
  <command>
 http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER -T log/test%TESTNUMBER.txt
 </command>
+# 1053700 x 'x', large enough to invoke the 100-continue behaviour
 <file name="log/test%TESTNUMBER.txt">
-Weird
-     file
-         to
-   upload
-for
-   testing
-the
-   PUT
-      feature
+%repeat[1053700 x x]%
 </file>
 </client>
 
@@ -73,24 +66,16 @@ PUT /we/want/%TESTNUMBER HTTP/1.1
 Host: %HOSTIP:%HTTPPORT\r
 User-Agent: curl/%VERSION\r
 Accept: */*\r
-Content-Length: 78\r
+Content-Length: 1053701\r
 Expect: 100-continue\r
 \r
 PUT /we/want/%TESTNUMBER HTTP/1.1\r
 Host: %HOSTIP:%HTTPPORT\r
 User-Agent: curl/%VERSION\r
 Accept: */*\r
-Content-Length: 78\r
+Content-Length: 1053701\r
 \r
-Weird
-     file
-         to
-   upload
-for
-   testing
-the
-   PUT
-      feature
+%repeat[1053700 x x]%
 </protocol>
 </verify>
 </testcase>
index 5afb8c96d8c841fed9a3afe5716f01a5216850f2..a5c92659031658eca2157b70f2a622014dad2543 100644 (file)
@@ -43,7 +43,6 @@ Host: %HOSTIP:%HTTPSPORT
 User-Agent: curl/%VERSION\r
 Accept: */*\r
 Content-Length: 1201\r
-Expect: 100-continue\r
 \r
 %repeat[200 x banana]%
 </protocol>
index 2d4cf1604a9cfcf9750fd8c5c7525066d698f610..3fcd0f3d50379e83ddfb0c2f6985d1164324c8c8 100644 (file)
@@ -51,7 +51,6 @@ Host: %HOSTIP:%HTTPPORT
 User-Agent: curl/%VERSION\r
 Accept: */*\r
 Content-Length: 10\r
-Expect: 100-continue\r
 \r
 surprise!
 PUT /%TESTNUMBER HTTP/1.1\r
@@ -59,7 +58,6 @@ Host: %HOSTIP:%HTTPPORT
 User-Agent: curl/%VERSION\r
 Accept: */*\r
 Content-Length: 10\r
-Expect: 100-continue\r
 \r
 surprise!
 </protocol>
index 5f2c27d6a27ef57dc4023dc40bcd771305d08f38..a2191ffe587198ec17ab70c83107942344d8f2ad 100644 (file)
@@ -51,7 +51,6 @@ Host: %HOSTIP:%HTTPPORT
 User-Agent: curl/%VERSION\r
 Accept: */*\r
 Content-Length: 10\r
-Expect: 100-continue\r
 \r
 surprise!
 </protocol>
index aedaf5b8a4fc0965ddc7902c662760176ef08792..6c704000db5889ba94d85c2db6e864d8b72daf43 100644 (file)
@@ -55,7 +55,6 @@ User-Agent: curl/%VERSION
 Accept: */*\r
 Testno: %TESTNUMBER\r
 Content-Length: 19\r
-Expect: 100-continue\r
 \r
 first %TESTNUMBER contents
 PUT /two/first%TESTNUMBER HTTP/1.1\r
@@ -64,7 +63,6 @@ User-Agent: curl/%VERSION
 Accept: */*\r
 Testno: %TESTNUMBER\r
 Content-Length: 19\r
-Expect: 100-continue\r
 \r
 first %TESTNUMBER contents
 PUT /one/second%TESTNUMBER HTTP/1.1\r
@@ -73,7 +71,6 @@ User-Agent: curl/%VERSION
 Accept: */*\r
 Testno: %TESTNUMBER\r
 Content-Length: 20\r
-Expect: 100-continue\r
 \r
 second %TESTNUMBER contents
 PUT /two/second%TESTNUMBER HTTP/1.1\r
@@ -82,7 +79,6 @@ User-Agent: curl/%VERSION
 Accept: */*\r
 Testno: %TESTNUMBER\r
 Content-Length: 20\r
-Expect: 100-continue\r
 \r
 second %TESTNUMBER contents
 </protocol>
index 75765b224f955ee0049889cfe080954ddf49cd42..9322ecca7bf000d01b8f6dd74f55ebe0e23c0356 100644 (file)
@@ -41,7 +41,6 @@ Host: %HOSTIP:%HTTPPORT
 User-Agent: curl/%VERSION\r
 Accept: */*\r
 Content-Length: 12\r
-Expect: 100-continue\r
 \r
 a few bytes
 </protocol>
index b7c6207628f41228b152a91a05b5fb07431d76c2..842031a8585ae39d942dc1130a8e215f5dc4d93d 100644 (file)
@@ -88,7 +88,6 @@ Authorization: Digest username="testuser", realm="testrealm", nonce="1053604145"
 User-Agent: curl/%VERSION\r
 Accept: */*\r
 Content-Length: 85\r
-Expect: 100-continue\r
 \r
 This is data we upload with PUT
 a second line