diff options
author | Isaac Boukris <iboukris@gmail.com> | 2017-02-03 14:30:26 +0200 |
---|---|---|
committer | Jay Satiro <raysatiro@yahoo.com> | 2017-02-17 02:32:16 -0500 |
commit | 13e3a18b345af1a15b892b0bbedfbbff06e10a39 (patch) | |
tree | 287181977e87aab9d983c6ed118d3d8d86cb146e /tests/data | |
parent | 3cc30e8207b5ab3a9a381c0ff3584d1af8dc54a1 (diff) |
http: fix missing 'Content-Length: 0' while negotiating auth
- While negotiating auth during PUT/POST if a user-specified
Content-Length header is set send 'Content-Length: 0'.
This is what we do already in HTTPREQ_POST_FORM and what we did in the
HTTPREQ_POST case (regression since afd288b).
Prior to this change no Content-Length header would be sent in such a
case.
Bug: https://curl.haxx.se/mail/lib-2017-02/0006.html
Reported-by: Dominik Hölzl
Closes https://github.com/curl/curl/pull/1242
Diffstat (limited to 'tests/data')
-rw-r--r-- | tests/data/Makefile.inc | 2 | ||||
-rw-r--r-- | tests/data/test1284 | 89 | ||||
-rw-r--r-- | tests/data/test1285 | 97 |
3 files changed, 187 insertions, 1 deletions
diff --git a/tests/data/Makefile.inc b/tests/data/Makefile.inc index c8334c8f3..953916d97 100644 --- a/tests/data/Makefile.inc +++ b/tests/data/Makefile.inc @@ -130,7 +130,7 @@ test1236 test1237 test1238 test1239 test1240 test1241 test1242 test1243 \ test1244 test1245 test1246 test1247 test1248 test1249 test1250 test1251 \ test1252 test1253 test1254 test1255 test1256 test1257 test1258 test1259 \ \ -test1280 test1281 test1282 test1283 \ +test1280 test1281 test1282 test1283 test1284 test1285 \ \ test1300 test1301 test1302 test1303 test1304 test1305 test1306 test1307 \ test1308 test1309 test1310 test1311 test1312 test1313 test1314 test1315 \ diff --git a/tests/data/test1284 b/tests/data/test1284 new file mode 100644 index 000000000..8437a4082 --- /dev/null +++ b/tests/data/test1284 @@ -0,0 +1,89 @@ +<testcase> +<info> +<keywords> +HTTP +HTTP POST +HTTP Digest auth +</keywords> +</info> + +# Server-side +<reply> +<data> +HTTP/1.1 401 authentication please swsbounce
+Server: Microsoft-IIS/6.0
+WWW-Authenticate: Digest realm="testrealm", nonce="1053604144"
+Content-Type: text/html; charset=iso-8859-1
+Content-Length: 0
+
+</data> +<data1000> +HTTP/1.1 200 A OK
+Server: Microsoft-IIS/6.0
+Content-Type: text/html; charset=iso-8859-1
+Content-Length: 3
+
+ok +</data1000> + +<datacheck> +HTTP/1.1 401 authentication please swsbounce
+Server: Microsoft-IIS/6.0
+WWW-Authenticate: Digest realm="testrealm", nonce="1053604144"
+Content-Type: text/html; charset=iso-8859-1
+Content-Length: 0
+
+HTTP/1.1 200 A OK
+Server: Microsoft-IIS/6.0
+Content-Type: text/html; charset=iso-8859-1
+Content-Length: 3
+
+ok +</datacheck> + +</reply> + +# Client-side +<client> +# +<server> +http +</server> +<features> +!SSPI +crypto +</features> +<name> +HTTP POST --digest with user-specified Content-Length header +</name> +# This test is to ensure 'Content-Length: 0' is sent while negotiating auth +# even when there is a user-specified Content-Length header. +# https://github.com/curl/curl/pull/1242 +<command> +-H "Content-Length: 11" -u auser:apasswd --digest -d "junkelijunk" http://%HOSTIP:%HTTPPORT/1284 +</command> +</client> + +# Verify data after the test has been "shot" +<verify> +<strip> +^User-Agent:.* +</strip> +<protocol nonewline="yes"> +POST /1284 HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+Accept: */*
+Content-Length: 0
+Content-Type: application/x-www-form-urlencoded
+
+POST /1284 HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+Authorization: Digest username="auser", realm="testrealm", nonce="1053604144", uri="/1284", response="5763079608de439072861a59ac733515"
+Accept: */*
+Content-Length: 11
+Content-Type: application/x-www-form-urlencoded
+
+junkelijunk +</protocol> +</verify> +</testcase> diff --git a/tests/data/test1285 b/tests/data/test1285 new file mode 100644 index 000000000..16c66238a --- /dev/null +++ b/tests/data/test1285 @@ -0,0 +1,97 @@ +<testcase> +<info> +<keywords> +HTTP +HTTP PUT +HTTP Digest auth +</keywords> +</info> + +# Server-side +<reply> +<data> +HTTP/1.1 401 authentication please swsbounce
+Server: Microsoft-IIS/6.0
+WWW-Authenticate: Digest realm="testrealm", nonce="1053604144"
+Content-Type: text/html; charset=iso-8859-1
+Content-Length: 0
+
+</data> +<data1000> +HTTP/1.1 200 A OK
+Server: Microsoft-IIS/6.0
+Content-Type: text/html; charset=iso-8859-1
+Content-Length: 3
+
+ok +</data1000> + +<datacheck> +HTTP/1.1 401 authentication please swsbounce
+Server: Microsoft-IIS/6.0
+WWW-Authenticate: Digest realm="testrealm", nonce="1053604144"
+Content-Type: text/html; charset=iso-8859-1
+Content-Length: 0
+
+HTTP/1.1 200 A OK
+Server: Microsoft-IIS/6.0
+Content-Type: text/html; charset=iso-8859-1
+Content-Length: 3
+
+ok +</datacheck> + +</reply> + +# Client-side +<client> +# +<server> +http +</server> +<features> +!SSPI +crypto +</features> +<name> +HTTP PUT --digest with user-specified Content-Length header +</name> +# This test is to ensure 'Content-Length: 0' is sent while negotiating auth +# even when there is a user-specified Content-Length header. +# https://github.com/curl/curl/pull/1242 +<command> +-H "Content-Length: 85" -u auser:apasswd --digest -T log/put1285 http://%HOSTIP:%HTTPPORT/1285 +</command> +<file name="log/put1285"> +This is data we upload with PUT +a second line +line three +four is the number of lines +</file> +</client> + +# Verify data after the test has been "shot" +<verify> +<strip> +^User-Agent:.* +</strip> +<protocol> +PUT /1285 HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+Accept: */*
+Content-Length: 0
+
+PUT /1285 HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+Authorization: Digest username="auser", realm="testrealm", nonce="1053604144", uri="/1285", response="dc185587d5e8391b347eef194c2a3cd6"
+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 +</protocol> +</verify> +</testcase> |