diff --git a/docs/FAQ b/docs/FAQ
index c8ba7feb3d..b96357cc1a 100644
--- 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
diff --git a/lib/http.c b/lib/http.c
index 299a499f00..faa486cc6f 100644
--- a/lib/http.c
+++ b/lib/http.c
@@ -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;
diff --git a/tests/data/test10 b/tests/data/test10
index 5b5534b674..5dd9356cd4 100644
--- a/tests/data/test10
+++ b/tests/data/test10
@@ -49,7 +49,6 @@ Host: %HOSTIP:%HTTPPORT
User-Agent: curl/%VERSION
Accept: */*
Content-Length: 78
-Expect: 100-continue
Weird
file
diff --git a/tests/data/test1001 b/tests/data/test1001
index df42f71343..738afb27f9 100644
--- a/tests/data/test1001
+++ b/tests/data/test1001
@@ -98,7 +98,6 @@ User-Agent: curl/%VERSION
Accept: */*
Proxy-Connection: Keep-Alive
Content-Length: 3
-Expect: 100-continue
st
diff --git a/tests/data/test1002 b/tests/data/test1002
index ca58be6f4e..d929ae724c 100644
--- a/tests/data/test1002
+++ b/tests/data/test1002
@@ -97,7 +97,6 @@ User-Agent: curl/%VERSION
Accept: */*
Proxy-Connection: Keep-Alive
Content-Length: 3
-Expect: 100-continue
st
GET http://%HOSTIP:%HTTPPORT/%TESTNUMBER.upload2 HTTP/1.1
@@ -116,7 +115,6 @@ User-Agent: curl/%VERSION
Accept: */*
Proxy-Connection: Keep-Alive
Content-Length: 3
-Expect: 100-continue
st
diff --git a/tests/data/test1030 b/tests/data/test1030
index bd4e18f1a1..5824977023 100644
--- a/tests/data/test1030
+++ b/tests/data/test1030
@@ -85,7 +85,6 @@ Host: %HOSTIP:%HTTPPORT
User-Agent: curl/%VERSION
Accept: */*
Content-Length: 85
-Expect: 100-continue
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
Accept: */*
Content-Length: 85
-Expect: 100-continue
This is data we upload with PUT
a second line
diff --git a/tests/data/test1041 b/tests/data/test1041
index 5580b9589a..6c3c01cbcf 100644
--- a/tests/data/test1041
+++ b/tests/data/test1041
@@ -59,7 +59,6 @@ Content-Range: bytes 0-99/100
User-Agent: curl/%VERSION
Accept: */*
Content-Length: 100
-Expect: 100-continue
012345678
012345678
diff --git a/tests/data/test1051 b/tests/data/test1051
index 5a1cf34c6f..9c082067b0 100644
--- a/tests/data/test1051
+++ b/tests/data/test1051
@@ -85,7 +85,6 @@ Host: %HOSTIP:%HTTPPORT
User-Agent: curl/%VERSION
Accept: */*
Content-Length: 78
-Expect: 100-continue
Weird
file
@@ -101,7 +100,6 @@ Host: %HOSTIP:%HTTPPORT
User-Agent: curl/%VERSION
Accept: */*
Content-Length: 78
-Expect: 100-continue
Weird
file
diff --git a/tests/data/test1055 b/tests/data/test1055
index f6f37531f8..b27b35b81d 100644
--- a/tests/data/test1055
+++ b/tests/data/test1055
@@ -60,7 +60,6 @@ Host: %HOSTIP:%HTTPPORT
User-Agent: curl/%VERSION
Accept: */*
Content-Length: 78
-Expect: 100-continue
Weird
file
diff --git a/tests/data/test1071 b/tests/data/test1071
index 6c6947227e..9eee479705 100644
--- a/tests/data/test1071
+++ b/tests/data/test1071
@@ -91,7 +91,6 @@ Host: %HOSTIP:%HTTPPORT
User-Agent: curl/%VERSION
Accept: */*
Content-Length: 85
-Expect: 100-continue
This is data we upload with PUT
a second line
diff --git a/tests/data/test1075 b/tests/data/test1075
index 2d111f2841..d55468138f 100644
--- a/tests/data/test1075
+++ b/tests/data/test1075
@@ -70,7 +70,6 @@ Host: %HOSTIP:%HTTPPORT
User-Agent: curl/%VERSION
Accept: */*
Content-Length: 85
-Expect: 100-continue
This is data we upload with PUT
a second line
@@ -82,7 +81,6 @@ Authorization: Basic dGVzdHVzZXI6dGVzdHBhc3M=
User-Agent: curl/%VERSION
Accept: */*
Content-Length: 85
-Expect: 100-continue
This is data we upload with PUT
a second line
diff --git a/tests/data/test1131 b/tests/data/test1131
index 8ead289c56..685e80e894 100644
--- a/tests/data/test1131
+++ b/tests/data/test1131
@@ -51,7 +51,7 @@ http
HTTP PUT expect 100-continue with a 400
--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
@@ -79,15 +79,15 @@ PUT /%TESTNUMBER HTTP/1.1
Host: %HOSTIP:%HTTPPORT
User-Agent: curl/%VERSION
Accept: */*
-Content-Length: 100
Expect: 100-continue
+Content-Length: 100
PUT /%TESTNUMBER0001 HTTP/1.1
Host: %HOSTIP:%HTTPPORT
User-Agent: curl/%VERSION
Accept: */*
-Content-Length: 100
Expect: 100-continue
+Content-Length: 100
diff --git a/tests/data/test1285 b/tests/data/test1285
index e5a38e071d..0a907b60ec 100644
--- a/tests/data/test1285
+++ b/tests/data/test1285
@@ -85,7 +85,6 @@ Authorization: Digest username="auser", realm="testrealm", nonce="1053604144", u
User-Agent: curl/%VERSION
Accept: */*
Content-Length: 85
-Expect: 100-continue
This is data we upload with PUT
a second line
diff --git a/tests/data/test1524 b/tests/data/test1524
index 39da646f59..65831ddc5d 100644
--- a/tests/data/test1524
+++ b/tests/data/test1524
@@ -61,7 +61,6 @@ Host: %HOSTIP:%HTTPPORT
User-Agent: curl/%VERSION
Accept: */*
Content-Length: 4
-Expect: 100-continue
moo
GET /blah/moo.html&testcase=/%TESTNUMBER0002 HTTP/1.1
diff --git a/tests/data/test1525 b/tests/data/test1525
index 34495b7e57..33f71c877c 100644
--- a/tests/data/test1525
+++ b/tests/data/test1525
@@ -71,7 +71,6 @@ Host: the.old.moo.%TESTNUMBER:%HTTPPORT
Accept: */*
User-Agent: Http Agent
Content-Length: 13
-Expect: 100-continue
Hello Cloud!
diff --git a/tests/data/test1526 b/tests/data/test1526
index 39e8668e8b..4076124054 100644
--- a/tests/data/test1526
+++ b/tests/data/test1526
@@ -73,7 +73,6 @@ Host: the.old.moo.%TESTNUMBER:%HTTPPORT
Accept: */*
User-Agent: Http Agent
Content-Length: 13
-Expect: 100-continue
Hello Cloud!
diff --git a/tests/data/test154 b/tests/data/test154
index c0f76514d7..0b180b90a9 100644
--- a/tests/data/test154
+++ b/tests/data/test154
@@ -10,9 +10,6 @@ HTTP Digest auth
# Server-side
-
-auth_required
-
HTTP/1.1 401 Authorization Required swsclose
Server: Apache/1.3.27 (Darwin) PHP/4.1.2
@@ -88,15 +85,17 @@ Host: %HOSTIP:%HTTPPORT
User-Agent: curl/%VERSION
Accept: */*
Content-Length: 85
-Expect: 100-continue
+This is data we upload with PUT
+a second line
+line three
+four is the number of lines
PUT /%TESTNUMBER HTTP/1.1
Host: %HOSTIP:%HTTPPORT
Authorization: Digest username="testuser", realm="gimme all yer s3cr3ts", nonce="11223344", uri="/%TESTNUMBER", response="b71551e12d1c456e47d8388ecb2edeca"
User-Agent: curl/%VERSION
Accept: */*
Content-Length: 85
-Expect: 100-continue
This is data we upload with PUT
a second line
diff --git a/tests/data/test155 b/tests/data/test155
index 2d916c9759..353edb9fa8 100644
--- a/tests/data/test155
+++ b/tests/data/test155
@@ -10,9 +10,6 @@ NTLM
# Server-side
-
-auth_required
-
HTTP/1.1 401 NTLM Authorization Required swsclose
Server: Apache/1.3.27 (Darwin) PHP/4.1.2
@@ -105,8 +102,11 @@ Host: %HOSTIP:%HTTPPORT
User-Agent: curl/%VERSION
Accept: */*
Content-Length: 85
-Expect: 100-continue
+This is data we upload with PUT
+a second line
+line three
+four is the number of lines
PUT /%TESTNUMBER HTTP/1.1
Host: %HOSTIP:%HTTPPORT
Authorization: NTLM TlRMTVNTUAABAAAABoIIAAAAAAAAAAAAAAAAAAAAAAA=
@@ -120,7 +120,6 @@ Authorization: NTLM TlRMTVNTUAADAAAAGAAYAEAAAAAYABgAWAAAAAAAAABwAAAACAAIAHAAAAAL
User-Agent: curl/%VERSION
Accept: */*
Content-Length: 85
-Expect: 100-continue
This is data we upload with PUT
a second line
diff --git a/tests/data/test156 b/tests/data/test156
index 94bb3393f8..35de74d240 100644
--- a/tests/data/test156
+++ b/tests/data/test156
@@ -46,7 +46,6 @@ Host: %HOSTIP:%HTTPPORT
User-Agent: curl/%VERSION
Accept: */*
Content-Length: 85
-Expect: 100-continue
This is data we upload with PUT
a second line
diff --git a/tests/data/test1948 b/tests/data/test1948
index 639523d995..4c50b02acd 100644
--- a/tests/data/test1948
+++ b/tests/data/test1948
@@ -58,7 +58,6 @@ PUT /%TESTNUMBER HTTP/1.1
Host: %HOSTIP:%HTTPPORT
Accept: */*
Content-Length: 22
-Expect: 100-continue
This is test PUT data
POST /1948 HTTP/1.1
diff --git a/tests/data/test2058 b/tests/data/test2058
index c400f26307..ba4a53e844 100644
--- a/tests/data/test2058
+++ b/tests/data/test2058
@@ -98,7 +98,6 @@ User-Agent: curl/%VERSION
Accept: */*
Proxy-Connection: Keep-Alive
Content-Length: 3
-Expect: 100-continue
st
diff --git a/tests/data/test2059 b/tests/data/test2059
index 3170c99a11..4776970d32 100644
--- a/tests/data/test2059
+++ b/tests/data/test2059
@@ -98,7 +98,6 @@ User-Agent: curl/%VERSION
Accept: */*
Proxy-Connection: Keep-Alive
Content-Length: 3
-Expect: 100-continue
st
diff --git a/tests/data/test2060 b/tests/data/test2060
index 11dd155265..9a8057d514 100644
--- a/tests/data/test2060
+++ b/tests/data/test2060
@@ -98,7 +98,6 @@ User-Agent: curl/%VERSION
Accept: */*
Proxy-Connection: Keep-Alive
Content-Length: 3
-Expect: 100-continue
st
diff --git a/tests/data/test208 b/tests/data/test208
index d081b5131f..a6c0eea492 100644
--- a/tests/data/test208
+++ b/tests/data/test208
@@ -58,7 +58,6 @@ User-Agent: curl/%VERSION
Accept: */*
Proxy-Connection: Keep-Alive
Content-Length: 78
-Expect: 100-continue
Weird
file
diff --git a/tests/data/test218 b/tests/data/test218
index dc71442e87..08ee8c6d45 100644
--- a/tests/data/test218
+++ b/tests/data/test218
@@ -45,7 +45,6 @@ Host: %HOSTIP:%HTTPPORT
User-Agent: curl/%VERSION
Accept: */*
Transfer-Encoding: chunked
-Expect: 100-continue
%if hyper
1E
diff --git a/tests/data/test281 b/tests/data/test281
index 4210f7b8f0..f92b753af2 100644
--- a/tests/data/test281
+++ b/tests/data/test281
@@ -49,7 +49,6 @@ Host: %HOSTIP:%HTTPPORT
User-Agent: curl/%VERSION
Accept: */*
Content-Length: 38
-Expect: 100-continue
Weird
file
diff --git a/tests/data/test33 b/tests/data/test33
index 1b9c898ef9..56024842cc 100644
--- a/tests/data/test33
+++ b/tests/data/test33
@@ -49,7 +49,6 @@ Content-Range: bytes 50-99/100
User-Agent: curl/%VERSION
Accept: */*
Content-Length: 50
-Expect: 100-continue
012345678
012345678
diff --git a/tests/data/test357 b/tests/data/test357
index 8ddcdc90d1..4c204f60ef 100644
--- a/tests/data/test357
+++ b/tests/data/test357
@@ -53,16 +53,9 @@ HTTP PUT with Expect: 100-continue and 417 response
http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER -T log/test%TESTNUMBER.txt
+# 1053700 x 'x', large enough to invoke the 100-continue behaviour
-Weird
- file
- to
- upload
-for
- testing
-the
- PUT
- feature
+%repeat[1053700 x x]%
@@ -73,24 +66,16 @@ PUT /we/want/%TESTNUMBER HTTP/1.1
Host: %HOSTIP:%HTTPPORT
User-Agent: curl/%VERSION
Accept: */*
-Content-Length: 78
+Content-Length: 1053701
Expect: 100-continue
PUT /we/want/%TESTNUMBER HTTP/1.1
Host: %HOSTIP:%HTTPPORT
User-Agent: curl/%VERSION
Accept: */*
-Content-Length: 78
+Content-Length: 1053701
-Weird
- file
- to
- upload
-for
- testing
-the
- PUT
- feature
+%repeat[1053700 x x]%
diff --git a/tests/data/test364 b/tests/data/test364
index 5afb8c96d8..a5c9265903 100644
--- a/tests/data/test364
+++ b/tests/data/test364
@@ -43,7 +43,6 @@ Host: %HOSTIP:%HTTPSPORT
User-Agent: curl/%VERSION
Accept: */*
Content-Length: 1201
-Expect: 100-continue
%repeat[200 x banana]%
diff --git a/tests/data/test490 b/tests/data/test490
index 2d4cf1604a..3fcd0f3d50 100644
--- a/tests/data/test490
+++ b/tests/data/test490
@@ -51,7 +51,6 @@ Host: %HOSTIP:%HTTPPORT
User-Agent: curl/%VERSION
Accept: */*
Content-Length: 10
-Expect: 100-continue
surprise!
PUT /%TESTNUMBER HTTP/1.1
@@ -59,7 +58,6 @@ Host: %HOSTIP:%HTTPPORT
User-Agent: curl/%VERSION
Accept: */*
Content-Length: 10
-Expect: 100-continue
surprise!
diff --git a/tests/data/test491 b/tests/data/test491
index 5f2c27d6a2..a2191ffe58 100644
--- a/tests/data/test491
+++ b/tests/data/test491
@@ -51,7 +51,6 @@ Host: %HOSTIP:%HTTPPORT
User-Agent: curl/%VERSION
Accept: */*
Content-Length: 10
-Expect: 100-continue
surprise!
diff --git a/tests/data/test492 b/tests/data/test492
index aedaf5b8a4..6c704000db 100644
--- a/tests/data/test492
+++ b/tests/data/test492
@@ -55,7 +55,6 @@ User-Agent: curl/%VERSION
Accept: */*
Testno: %TESTNUMBER
Content-Length: 19
-Expect: 100-continue
first %TESTNUMBER contents
PUT /two/first%TESTNUMBER HTTP/1.1
@@ -64,7 +63,6 @@ User-Agent: curl/%VERSION
Accept: */*
Testno: %TESTNUMBER
Content-Length: 19
-Expect: 100-continue
first %TESTNUMBER contents
PUT /one/second%TESTNUMBER HTTP/1.1
@@ -73,7 +71,6 @@ User-Agent: curl/%VERSION
Accept: */*
Testno: %TESTNUMBER
Content-Length: 20
-Expect: 100-continue
second %TESTNUMBER contents
PUT /two/second%TESTNUMBER HTTP/1.1
@@ -82,7 +79,6 @@ User-Agent: curl/%VERSION
Accept: */*
Testno: %TESTNUMBER
Content-Length: 20
-Expect: 100-continue
second %TESTNUMBER contents
diff --git a/tests/data/test58 b/tests/data/test58
index 75765b224f..9322ecca7b 100644
--- a/tests/data/test58
+++ b/tests/data/test58
@@ -41,7 +41,6 @@ Host: %HOSTIP:%HTTPPORT
User-Agent: curl/%VERSION
Accept: */*
Content-Length: 12
-Expect: 100-continue
a few bytes
diff --git a/tests/data/test88 b/tests/data/test88
index b7c6207628..842031a858 100644
--- a/tests/data/test88
+++ b/tests/data/test88
@@ -88,7 +88,6 @@ Authorization: Digest username="testuser", realm="testrealm", nonce="1053604145"
User-Agent: curl/%VERSION
Accept: */*
Content-Length: 85
-Expect: 100-continue
This is data we upload with PUT
a second line