From: Daniel Stenberg Date: Sat, 25 Nov 2006 13:32:04 +0000 (+0000) Subject: Venkat Akella found out that libcurl did not like HTTP responses that simply X-Git-Tag: curl-7_16_1~140 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=da58d03ff7be9fc5e0219d95ce2f9932e2272473;p=thirdparty%2Fcurl.git Venkat Akella found out that libcurl did not like HTTP responses that simply responded with a single status line and no headers nor body. Starting now, a HTTP response on a persistent connection (i.e not set to be closed after the response has been taken care of) must have Content-Length or chunked encoding set, or libcurl will simply assume that there is no body. To my horror I learned that we had no less than 57(!) test cases that did bad HTTP responses like this, and even the test http server (sws) responded badly when queried by the test system if it is the test system. So although the actual fix for the problem was tiny, going through all the newly failing test cases got really painful and boring. --- diff --git a/CHANGES b/CHANGES index 080ffed0bf..c19e62b96d 100644 --- a/CHANGES +++ b/CHANGES @@ -6,6 +6,19 @@ Changelog +Daniel (25 November 2006) +- Venkat Akella found out that libcurl did not like HTTP responses that simply + responded with a single status line and no headers nor body. Starting now, a + HTTP response on a persistent connection (i.e not set to be closed after the + response has been taken care of) must have Content-Length or chunked + encoding set, or libcurl will simply assume that there is no body. + + To my horror I learned that we had no less than 57(!) test cases that did bad + HTTP responses like this, and even the test http server (sws) responded badly + when queried by the test system if it is the test system. So although the + actual fix for the problem was tiny, going through all the newly failing test + cases got really painful and boring. + Daniel (24 November 2006) - James Housley did lots of work and introduced SFTP downloads. diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 31fb48e3cf..5bccf5cde0 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -23,6 +23,8 @@ This release includes the following bugfixes: o SIGSEGV when disconnecting on a transfer on a re-used handle when the host name didn't resolve o stack overwrite on 64bit Windows in the chunked decoding department + o HTTP responses on persistent connections without Content-Length nor chunked + encoding are now considered to be without response body Other curl-related news: @@ -38,6 +40,6 @@ This release would not have looked like this without help, code, reports and advice from friends like these: James Housley, Olaf Stueben, Yang Tse, Gisle Vanem, Bradford Bruce, - Ciprian Badescu, Dmitriy Sergeyev, Nir Soffer + Ciprian Badescu, Dmitriy Sergeyev, Nir Soffer, Venkat Akella Thanks! (and sorry if I forgot to mention someone) diff --git a/lib/transfer.c b/lib/transfer.c index 2d5d0dfe8c..6b7b819781 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -501,9 +501,19 @@ CURLcode Curl_readwrite(struct connectdata *conn, k->keepon |= KEEP_WRITE; } } - else + else { k->header = FALSE; /* no more header to parse! */ + if((k->size == -1) && !conn->bits.chunk && !conn->bits.close) + /* When connection is not to get closed, but no + Content-Length nor Content-Encoding chunked have been + received, there is no body in this response. We don't set + stop_reading TRUE since that would also prevent necessary + authentication actions to take place. */ + conn->bits.no_body = TRUE; + + } + if (417 == k->httpcode) { /* * we got: "417 Expectation Failed" this means: diff --git a/tests/data/test11 b/tests/data/test11 index e34a366466..84baa90760 100644 --- a/tests/data/test11 +++ b/tests/data/test11 @@ -21,6 +21,7 @@ This server reply is for testing a simple Location: following HTTP/1.1 200 Followed here fine swsclose Date: Thu, 09 Nov 2010 14:49:00 GMT Server: test-server/fake +Content-Length: 52 If this is received, the location following worked @@ -35,6 +36,7 @@ Connection: close HTTP/1.1 200 Followed here fine swsclose Date: Thu, 09 Nov 2010 14:49:00 GMT Server: test-server/fake +Content-Length: 52 If this is received, the location following worked diff --git a/tests/data/test150 b/tests/data/test150 index 7ae812d93d..60e6b912d4 100644 --- a/tests/data/test150 +++ b/tests/data/test150 @@ -21,6 +21,7 @@ This is not the real page either! HTTP/1.1 200 Things are fine in server land swsclose Server: Microsoft-IIS/5.0 Content-Type: text/html; charset=iso-8859-1 +Content-Length: 32 Finally, this is the real page! @@ -35,6 +36,7 @@ WWW-Authenticate: NTLM TlRMTVNTUAACAAAAAgACADAAAAAGgoEAc51AYVDgyNcAAAAAAAAAAG4Ab HTTP/1.1 200 Things are fine in server land swsclose Server: Microsoft-IIS/5.0 Content-Type: text/html; charset=iso-8859-1 +Content-Length: 32 Finally, this is the real page! diff --git a/tests/data/test153 b/tests/data/test153 index 1fd54a1f90..51137b38f9 100644 --- a/tests/data/test153 +++ b/tests/data/test153 @@ -6,6 +6,7 @@ HTTP/1.1 401 Authorization Required swsclose Server: Apache/1.3.27 (Darwin) PHP/4.1.2 WWW-Authenticate: Digest realm="testrealm", nonce="1053604145" Content-Type: text/html; charset=iso-8859-1 +Content-Length: 26 This is not the real page @@ -95,6 +96,7 @@ HTTP/1.1 401 Authorization Required swsclose Server: Apache/1.3.27 (Darwin) PHP/4.1.2 WWW-Authenticate: Digest realm="testrealm", nonce="1053604145" Content-Type: text/html; charset=iso-8859-1 +Content-Length: 26 HTTP/1.1 200 OK Server: Apache/1.3.27 (Darwin) PHP/4.1.2 diff --git a/tests/data/test155 b/tests/data/test155 index 91ed13abd0..871b0267ae 100644 --- a/tests/data/test155 +++ b/tests/data/test155 @@ -33,6 +33,7 @@ This is not the real page either! HTTP/1.1 200 Type-3 Recevied and all Things are fine swsclose Server: Microsoft-IIS/5.0 Content-Type: text/html; charset=iso-8859-1 +Content-Length: 32 Finally, this is the real page! @@ -55,6 +56,7 @@ WWW-Authenticate: NTLM TlRMTVNTUAACAAAAAgACADAAAAAGgoEAc51AYVDgyNcAAAAAAAAAAG4Ab HTTP/1.1 200 Type-3 Recevied and all Things are fine swsclose Server: Microsoft-IIS/5.0 Content-Type: text/html; charset=iso-8859-1 +Content-Length: 32 Finally, this is the real page! diff --git a/tests/data/test159 b/tests/data/test159 index 2fcd7d502e..8513c30739 100644 --- a/tests/data/test159 +++ b/tests/data/test159 @@ -21,6 +21,7 @@ This is not the real page either! HTTP/1.1 200 Things are fine in server land swsclose Server: Microsoft-IIS/5.0 Content-Type: text/html; charset=iso-8859-1 +Content-Length: 32 Finally, this is the real page! @@ -35,6 +36,7 @@ WWW-Authenticate: NTLM TlRMTVNTUAACAAAAAgACADAAAAAGgoEAc51AYVDgyNcAAAAAAAAAAG4Ab HTTP/1.1 200 Things are fine in server land swsclose Server: Microsoft-IIS/5.0 Content-Type: text/html; charset=iso-8859-1 +Content-Length: 32 Finally, this is the real page! diff --git a/tests/data/test163 b/tests/data/test163 index c51adfccbe..b87504e440 100644 --- a/tests/data/test163 +++ b/tests/data/test163 @@ -4,6 +4,7 @@ HTTP/1.1 200 OK swsclose Date: Thu, 09 Nov 2010 14:49:00 GMT Server: test-server/fake +Content-Length: 10 blablabla diff --git a/tests/data/test166 b/tests/data/test166 index edc184abf0..0e915f9e02 100644 --- a/tests/data/test166 +++ b/tests/data/test166 @@ -4,6 +4,7 @@ HTTP/1.1 200 OK swsclose Date: Thu, 09 Nov 2010 14:49:00 GMT Server: test-server/fake +Content-Length: 10 blablabla diff --git a/tests/data/test167 b/tests/data/test167 index a23d94ba7a..6fa5b1bd34 100644 --- a/tests/data/test167 +++ b/tests/data/test167 @@ -9,6 +9,7 @@ WWW-Authenticate: Digest realm="weirdorealm", nonce="12345" HTTP/1.1 200 OK swsclose Server: no +Content-Length: 15 Nice auth sir! @@ -19,6 +20,7 @@ WWW-Authenticate: Digest realm="weirdorealm", nonce="12345" HTTP/1.1 200 OK swsclose Server: no +Content-Length: 15 Nice auth sir! diff --git a/tests/data/test168 b/tests/data/test168 index dbaf667c94..6f93ebab80 100644 --- a/tests/data/test168 +++ b/tests/data/test168 @@ -20,6 +20,7 @@ you should ignore this data too HTTP/1.1 200 OK swsclose Server: no +Content-Length: 15 Nice auth sir! @@ -33,6 +34,7 @@ WWW-Authenticate: Digest realm="realmweirdo", nonce="123456" HTTP/1.1 200 OK swsclose Server: no +Content-Length: 15 Nice auth sir! diff --git a/tests/data/test173 b/tests/data/test173 index 130fa9e075..0050e5cccb 100644 --- a/tests/data/test173 +++ b/tests/data/test173 @@ -4,6 +4,7 @@ HTTP/1.1 200 OK swsclose Date: Thu, 09 Nov 2010 14:49:00 GMT Server: test-server/fake +Content-Length: 11 blablabla diff --git a/tests/data/test174 b/tests/data/test174 index 32130f1be2..b14d39b1ce 100644 --- a/tests/data/test174 +++ b/tests/data/test174 @@ -5,6 +5,7 @@ HTTP/1.1 200 beng swsclose Server: Microsoft-IIS/6.0 Authentication-Info: Passport1.4 tname=MSPAuth,tname=MSPProf,tname=MSPConsent,tname=MSPSecAuth Content-Type: text/html; charset=iso-8859-1 +Content-Length: 26 This is not the real page diff --git a/tests/data/test175 b/tests/data/test175 index 3a979af983..db8f8a88a5 100644 --- a/tests/data/test175 +++ b/tests/data/test175 @@ -13,6 +13,7 @@ This is not the real page HTTP/1.1 200 moo swsclose Server: Microsoft-IIS/6.0 Content-Type: text/html; charset=iso-8859-1 +Content-Length: 16 content for you @@ -26,6 +27,7 @@ Content-Type: text/html; charset=iso-8859-1 HTTP/1.1 200 moo swsclose Server: Microsoft-IIS/6.0 Content-Type: text/html; charset=iso-8859-1 +Content-Length: 16 content for you diff --git a/tests/data/test176 b/tests/data/test176 index e7ed3ecbb0..f197367d70 100644 --- a/tests/data/test176 +++ b/tests/data/test176 @@ -14,6 +14,7 @@ Content-Type: text/html; charset=iso-8859-1 HTTP/1.1 200 moo swsclose Server: Microsoft-IIS/6.0 Content-Type: text/html; charset=iso-8859-1 +Content-Length: 16 content for you @@ -27,6 +28,7 @@ Content-Type: text/html; charset=iso-8859-1 HTTP/1.1 200 moo swsclose Server: Microsoft-IIS/6.0 Content-Type: text/html; charset=iso-8859-1 +Content-Length: 16 content for you diff --git a/tests/data/test186 b/tests/data/test186 index e878bca809..763c6c805c 100644 --- a/tests/data/test186 +++ b/tests/data/test186 @@ -4,6 +4,7 @@ HTTP/1.1 200 OK swsclose Date: Thu, 09 Nov 2010 14:49:00 GMT Server: test-server/fake +Content-Length: 11 blablabla diff --git a/tests/data/test187 b/tests/data/test187 index 67aace5d1d..2919164f5d 100644 --- a/tests/data/test187 +++ b/tests/data/test187 @@ -14,6 +14,7 @@ This server reply is for testing a simple Location: following HTTP/1.1 200 Followed here fine swsclose Date: Thu, 09 Nov 2010 14:49:00 GMT Server: test-server/fake +Content-Length: 52 If this is received, the location following worked @@ -28,6 +29,7 @@ Connection: close HTTP/1.1 200 Followed here fine swsclose Date: Thu, 09 Nov 2010 14:49:00 GMT Server: test-server/fake +Content-Length: 52 If this is received, the location following worked diff --git a/tests/data/test233 b/tests/data/test233 index ca19364be0..b11aabbbd2 100644 --- a/tests/data/test233 +++ b/tests/data/test233 @@ -28,6 +28,7 @@ Date: Thu, 09 Nov 2010 14:49:00 GMT Server: test-server/fake swsclose Content-Type: text/html Funny-head: yesyes +Content-Length: 9 contents @@ -47,6 +48,7 @@ Date: Thu, 09 Nov 2010 14:49:00 GMT Server: test-server/fake swsclose Content-Type: text/html Funny-head: yesyes +Content-Length: 9 contents diff --git a/tests/data/test234 b/tests/data/test234 index 9c7d8c14ec..c8775c5438 100644 --- a/tests/data/test234 +++ b/tests/data/test234 @@ -19,6 +19,7 @@ Date: Thu, 09 Nov 2010 14:49:00 GMT Server: test-server/fake swsclose Content-Type: text/html Funny-head: yesyes +Content-Length: 9 contents @@ -38,6 +39,7 @@ Date: Thu, 09 Nov 2010 14:49:00 GMT Server: test-server/fake swsclose Content-Type: text/html Funny-head: yesyes +Content-Length: 9 contents diff --git a/tests/data/test239 b/tests/data/test239 index 7a789b600c..77e7ae2965 100644 --- a/tests/data/test239 +++ b/tests/data/test239 @@ -16,7 +16,7 @@ Hey you, authenticate or go away! HTTP/1.1 200 Things are fine in proxy land swsclose Server: Microsoft-IIS/5.0 Content-Type: text/html; charset=iso-8859-1 -Content-Length; 42 +Content-Length: 42 Contents of that page you requested, sir. @@ -29,7 +29,7 @@ Content-Length: 34 HTTP/1.1 200 Things are fine in proxy land swsclose Server: Microsoft-IIS/5.0 Content-Type: text/html; charset=iso-8859-1 -Content-Length; 42 +Content-Length: 42 Contents of that page you requested, sir. diff --git a/tests/data/test243 b/tests/data/test243 index f8ef686e72..614dfc0fe6 100644 --- a/tests/data/test243 +++ b/tests/data/test243 @@ -36,7 +36,7 @@ Hey you, authenticate or go away! HTTP/1.1 200 Things are fine in proxy land swsclose Server: Microsoft-IIS/5.0 Content-Type: text/html; charset=iso-8859-1 -Content-Length; 42 +Content-Length: 42 Contents of that page you requested, sir. @@ -57,7 +57,7 @@ Content-Length: 34 HTTP/1.1 200 Things are fine in proxy land swsclose Server: Microsoft-IIS/5.0 Content-Type: text/html; charset=iso-8859-1 -Content-Length; 42 +Content-Length: 42 Contents of that page you requested, sir. diff --git a/tests/data/test257 b/tests/data/test257 index 5c81409cfa..90680f3951 100644 --- a/tests/data/test257 +++ b/tests/data/test257 @@ -31,6 +31,7 @@ If this is received, the location following worked HTTP/1.1 200 Followed here fine swsclose Date: Thu, 09 Nov 2010 14:49:00 GMT Server: test-server/fake +Content-Length: 52 If this is received, the location following worked @@ -50,6 +51,7 @@ Location: http://athird.com/2570003 HTTP/1.1 200 Followed here fine swsclose Date: Thu, 09 Nov 2010 14:49:00 GMT Server: test-server/fake +Content-Length: 52 If this is received, the location following worked diff --git a/tests/data/test26 b/tests/data/test26 index 01b1bd7f3b..f92cf2326d 100644 --- a/tests/data/test26 +++ b/tests/data/test26 @@ -7,7 +7,7 @@ HTTP GET # Server-side -HTTP/1.1 200 Mooo swsclose +HTTP/1.0 200 Mooo swsclose Server: test-server/fake Connection: close diff --git a/tests/data/test264 b/tests/data/test264 index 23bd99aa4f..55f79b6d23 100644 --- a/tests/data/test264 +++ b/tests/data/test264 @@ -12,6 +12,7 @@ HTTP proxy Basic auth HTTP/1.1 200 OK swsclose Date: Thu, 09 Nov 2010 14:49:00 GMT Content-Type: text/html +Content-Length: 26 the content would go here diff --git a/tests/data/test267 b/tests/data/test267 index 56d2a0a672..c379d48650 100644 --- a/tests/data/test267 +++ b/tests/data/test267 @@ -28,6 +28,7 @@ This is not the real page either! HTTP/1.1 200 Things are fine in server land swsclose Server: Microsoft-IIS/5.0 Content-Type: text/html; charset=iso-8859-1 +Content-Length: 32 Finally, this is the real page! @@ -42,6 +43,7 @@ WWW-Authenticate: NTLM TlRMTVNTUAACAAAAAgACADAAAAAGgoEAc51AYVDgyNcAAAAAAAAAAG4Ab HTTP/1.1 200 Things are fine in server land swsclose Server: Microsoft-IIS/5.0 Content-Type: text/html; charset=iso-8859-1 +Content-Length: 32 Finally, this is the real page! diff --git a/tests/data/test27 b/tests/data/test27 index 60a474aef8..85b087aab7 100644 --- a/tests/data/test27 +++ b/tests/data/test27 @@ -11,6 +11,7 @@ cookies HTTP/1.1 200 Mooo swsclose Connection: close Set-Cookie: path=/; thewinneris=nowayyouwin; +Content-Length: 8 *flopp* diff --git a/tests/data/test273 b/tests/data/test273 index dbc8f8429c..6aabfdcbd3 100644 --- a/tests/data/test273 +++ b/tests/data/test273 @@ -23,6 +23,7 @@ This is not the real page HTTP/1.1 200 OK swsclose Server: Apache/1.3.27 (Darwin) PHP/4.1.2 Content-Type: text/html; charset=iso-8859-1 +Content-Length: 23 This IS the real page! @@ -37,6 +38,7 @@ Content-Type: text/html; charset=iso-8859-1 HTTP/1.1 200 OK swsclose Server: Apache/1.3.27 (Darwin) PHP/4.1.2 Content-Type: text/html; charset=iso-8859-1 +Content-Length: 23 This IS the real page! diff --git a/tests/data/test276 b/tests/data/test276 index 7090ec581a..aa56090f47 100644 --- a/tests/data/test276 +++ b/tests/data/test276 @@ -21,6 +21,7 @@ This server reply is for testing a simple Location: following HTTP/1.1 200 Followed here fine swsclose Date: Thu, 09 Nov 2010 14:49:00 GMT Server: test-server/fake +Content-Length: 52 If this is received, the location following worked @@ -35,6 +36,7 @@ Connection: close HTTP/1.1 200 Followed here fine swsclose Date: Thu, 09 Nov 2010 14:49:00 GMT Server: test-server/fake +Content-Length: 52 If this is received, the location following worked diff --git a/tests/data/test277 b/tests/data/test277 index 1828203be2..f19e3423d6 100644 --- a/tests/data/test277 +++ b/tests/data/test277 @@ -10,6 +10,7 @@ HTTP FORMPOST HTTP/1.1 200 OK swsclose Date: Thu, 09 Nov 2010 14:49:00 GMT Server: test-server/fake +Content-Length: 11 blablabla diff --git a/tests/data/test278 b/tests/data/test278 index 77e80456a5..795b090ce6 100644 --- a/tests/data/test278 +++ b/tests/data/test278 @@ -12,6 +12,7 @@ HTTP proxy Basic auth HTTP/1.1 200 OK swsclose Date: Thu, 09 Nov 2010 14:49:00 GMT Content-Type: text/html +Content-Length: 27 the content would go here diff --git a/tests/data/test279 b/tests/data/test279 index 716a99ea64..2483e39d29 100644 --- a/tests/data/test279 +++ b/tests/data/test279 @@ -12,6 +12,7 @@ HTTP proxy Basic auth HTTP/1.1 200 OK swsclose Date: Thu, 09 Nov 2010 14:49:00 GMT Content-Type: text/html +Content-Length: 27 the content would go here diff --git a/tests/data/test28 b/tests/data/test28 index 355924fa61..98d19c59d9 100644 --- a/tests/data/test28 +++ b/tests/data/test28 @@ -20,6 +20,7 @@ This server reply is for testing a simple Location: following HTTP/1.1 200 Followed here fine swsclose Date: Thu, 09 Nov 2010 14:49:00 GMT Server: test-server/fake +Content-Length: 52 If this is received, the location following worked @@ -34,6 +35,7 @@ Connection: close HTTP/1.1 200 Followed here fine swsclose Date: Thu, 09 Nov 2010 14:49:00 GMT Server: test-server/fake +Content-Length: 52 If this is received, the location following worked diff --git a/tests/data/test281 b/tests/data/test281 index ffbebbe66d..f228d2d0b0 100644 --- a/tests/data/test281 +++ b/tests/data/test281 @@ -50,7 +50,7 @@ Weird PUT /we/want/281 HTTP/1.1 -Host: 127.0.0.1:%HTTPPORT +Host: %HOSTIP:%HTTPPORT Accept: */* Content-Length: 38 Expect: 100-continue diff --git a/tests/data/test282 b/tests/data/test282 new file mode 100644 index 0000000000..b15745b18a --- /dev/null +++ b/tests/data/test282 @@ -0,0 +1,43 @@ + + +HTTP +HTTP GET + + + +# +# Server-side + + +HTTP/1.1 200 OK + + + + +# +# Client-side + + +http + + +HTTP GET with no response body or headers + + +http://%HOSTIP:%HTTPPORT/282 + + + +# +# Verify data after the test has been "shot" + + +^User-Agent:.* + + +GET /282 HTTP/1.1 +Host: %HOSTIP:%HTTPPORT +Accept: */* + + + diff --git a/tests/data/test43 b/tests/data/test43 index 1ee0e2f89b..fe6c54e18c 100644 --- a/tests/data/test43 +++ b/tests/data/test43 @@ -22,6 +22,7 @@ This server reply is for testing a simple Location: following HTTP/1.1 200 Followed here fine swsclose Date: Thu, 09 Nov 2010 14:49:00 GMT Server: test-server/fake +Content-Length: 52 If this is received, the location following worked @@ -36,6 +37,7 @@ Connection: close HTTP/1.1 200 Followed here fine swsclose Date: Thu, 09 Nov 2010 14:49:00 GMT Server: test-server/fake +Content-Length: 52 If this is received, the location following worked diff --git a/tests/data/test44 b/tests/data/test44 index ab66d11c00..beea1cf6ea 100644 --- a/tests/data/test44 +++ b/tests/data/test44 @@ -8,7 +8,7 @@ HTTP replaced headers # Server-side -HTTP/1.1 200 OK swsclose +HTTP/1.0 200 OK swsclose Date: Thu, 09 Nov 2010 14:49:00 GMT Server: test-server/fake diff --git a/tests/data/test45 b/tests/data/test45 index b8d76201d0..b8d96f7e68 100644 --- a/tests/data/test45 +++ b/tests/data/test45 @@ -21,6 +21,7 @@ This server reply is for testing a simple Location: following HTTP/1.1 200 Followed here fine swsclose Date: Thu, 09 Nov 2010 14:49:00 GMT Server: test-server/fake +Content-Length: 52 If this is received, the location following worked @@ -35,6 +36,7 @@ Connection: close HTTP/1.1 200 Followed here fine swsclose Date: Thu, 09 Nov 2010 14:49:00 GMT Server: test-server/fake +Content-Length: 52 If this is received, the location following worked diff --git a/tests/data/test515 b/tests/data/test515 index 566da84f40..c2dd48fe84 100644 --- a/tests/data/test515 +++ b/tests/data/test515 @@ -5,6 +5,7 @@ HTTP/1.1 200 OK swsclose Date: Thu, 09 Nov 2010 14:49:00 GMT Server: test-server/fake +Content-Length: 3 OK @@ -36,7 +37,7 @@ http://%HOSTIP:%HTTPPORT/515 POST /515 HTTP/1.1 -Host: 127.0.0.1:%HTTPPORT +Host: %HOSTIP:%HTTPPORT Accept: */* Content-Length: 0 Content-Type: application/x-www-form-urlencoded diff --git a/tests/data/test516 b/tests/data/test516 index cd45b3115c..3a8210f224 100644 --- a/tests/data/test516 +++ b/tests/data/test516 @@ -5,6 +5,7 @@ HTTP/1.1 200 OK swsclose Date: Thu, 09 Nov 2010 14:49:00 GMT Server: test-server/fake +Content-Length: 3 OK @@ -36,7 +37,7 @@ http://%HOSTIP:%HTTPPORT/516 POST /516 HTTP/1.1 -Host: 127.0.0.1:%HTTPPORT +Host: %HOSTIP:%HTTPPORT Accept: */* Content-Length: 0 diff --git a/tests/data/test56 b/tests/data/test56 index d4f369907b..d84b86ddcb 100644 --- a/tests/data/test56 +++ b/tests/data/test56 @@ -9,7 +9,7 @@ chunked Transfer-Encoding # Server-side -HTTP/1.1 200 OK swsclose +HTTP/1.0 200 OK swsclose Funny-head: yesyes This is the proof it works diff --git a/tests/data/test59 b/tests/data/test59 index 5e0e694fae..7ea59af86c 100644 --- a/tests/data/test59 +++ b/tests/data/test59 @@ -8,7 +8,7 @@ HTTP GET # Server-side -HTTP/1.1 200 OK swsclose +HTTP/1.0 200 OK swsclose Date: Thu, 09 Nov 2010 14:49:00 GMT Server: test-server/fake diff --git a/tests/data/test62 b/tests/data/test62 index 48eca088e1..fd08f7e5f1 100644 --- a/tests/data/test62 +++ b/tests/data/test62 @@ -8,7 +8,7 @@ HTTP replaced headers # Server-side -HTTP/1.1 200 OK swsclose +HTTP/1.0 200 OK swsclose Date: Thu, 09 Nov 2010 14:49:00 GMT Content-Type: text/html diff --git a/tests/data/test63 b/tests/data/test63 index bcd5a188a9..179b9e6b89 100644 --- a/tests/data/test63 +++ b/tests/data/test63 @@ -12,6 +12,7 @@ HTTP proxy Basic auth HTTP/1.1 200 OK swsclose Date: Thu, 09 Nov 2010 14:49:00 GMT Content-Type: text/html +Content-Length: 26 the content would go here diff --git a/tests/data/test64 b/tests/data/test64 index 9521102c70..e2ba87dcdd 100644 --- a/tests/data/test64 +++ b/tests/data/test64 @@ -12,6 +12,7 @@ HTTP/1.1 401 Authorization Required swsclose Server: Apache/1.3.27 (Darwin) PHP/4.1.2 WWW-Authenticate: Digest realm="testrealm", nonce="1053604145" Content-Type: text/html; charset=iso-8859-1 +Content-Length: 26 This is not the real page @@ -22,6 +23,7 @@ This is not the real page HTTP/1.1 200 OK swsclose Server: Apache/1.3.27 (Darwin) PHP/4.1.2 Content-Type: text/html; charset=iso-8859-1 +Content-Length: 23 This IS the real page! @@ -31,10 +33,12 @@ HTTP/1.1 401 Authorization Required swsclose Server: Apache/1.3.27 (Darwin) PHP/4.1.2 WWW-Authenticate: Digest realm="testrealm", nonce="1053604145" Content-Type: text/html; charset=iso-8859-1 +Content-Length: 26 HTTP/1.1 200 OK swsclose Server: Apache/1.3.27 (Darwin) PHP/4.1.2 Content-Type: text/html; charset=iso-8859-1 +Content-Length: 23 This IS the real page! diff --git a/tests/data/test67 b/tests/data/test67 index da43a7d3ab..19aeeec9bf 100644 --- a/tests/data/test67 +++ b/tests/data/test67 @@ -28,6 +28,7 @@ This is not the real page either! HTTP/1.1 200 Things are fine in server land swsclose Server: Microsoft-IIS/5.0 Content-Type: text/html; charset=iso-8859-1 +Content-Length: 32 Finally, this is the real page! @@ -42,6 +43,7 @@ WWW-Authenticate: NTLM TlRMTVNTUAACAAAAAgACADAAAAAGgoEAc51AYVDgyNcAAAAAAAAAAG4Ab HTTP/1.1 200 Things are fine in server land swsclose Server: Microsoft-IIS/5.0 Content-Type: text/html; charset=iso-8859-1 +Content-Length: 32 Finally, this is the real page! diff --git a/tests/data/test69 b/tests/data/test69 index 333ec2c0fd..7102342a92 100644 --- a/tests/data/test69 +++ b/tests/data/test69 @@ -14,6 +14,7 @@ WWW-Authenticate: Basic WWW-Authenticate: Wild-and-crazy WWW-Authenticate: NTLM Content-Type: text/html; charset=iso-8859-1 +Content-Length: 26 This is not the real page @@ -36,6 +37,7 @@ This is not the real page either! HTTP/1.1 200 Things are fine in server land swsclose Server: Microsoft-IIS/5.0 Content-Type: text/html; charset=iso-8859-1 +Content-Length: 32 Finally, this is the real page! @@ -47,6 +49,7 @@ WWW-Authenticate: Basic WWW-Authenticate: Wild-and-crazy WWW-Authenticate: NTLM Content-Type: text/html; charset=iso-8859-1 +Content-Length: 26 HTTP/1.1 401 Now gimme that second request of crap Server: Microsoft-IIS/5.0 @@ -57,6 +60,7 @@ WWW-Authenticate: NTLM TlRMTVNTUAACAAAAAgACADAAAAAGgoEAc51AYVDgyNcAAAAAAAAAAG4Ab HTTP/1.1 200 Things are fine in server land swsclose Server: Microsoft-IIS/5.0 Content-Type: text/html; charset=iso-8859-1 +Content-Length: 32 Finally, this is the real page! diff --git a/tests/data/test71 b/tests/data/test71 index 733db358c9..baedaab893 100644 --- a/tests/data/test71 +++ b/tests/data/test71 @@ -10,6 +10,7 @@ HTTP FORMPOST HTTP/1.1 200 OK swsclose Date: Thu, 09 Nov 2010 14:49:00 GMT Server: test-server/fake +Content-Length: 11 blablabla diff --git a/tests/data/test73 b/tests/data/test73 index 516784e056..6e612eec63 100644 --- a/tests/data/test73 +++ b/tests/data/test73 @@ -12,6 +12,7 @@ HTTP/1.1 200 OK swsclose Date: Thu, 09 Nov 2010 14:49:00 GMT Content-Type: text/html Set-Cookie: IPCZQX01af0fca5c=000010008168c200d25dfc4b; path=/; domain=.NOT_DISCLOSED.se +Content-Length: 4 boo diff --git a/tests/data/test79 b/tests/data/test79 index 6d080bd5d7..8954360f09 100644 --- a/tests/data/test79 +++ b/tests/data/test79 @@ -10,7 +10,7 @@ HTTP proxy # Server-side -HTTP/1.1 200 OK +HTTP/1.0 200 OK Date: Thu, 09 Nov 2010 14:49:00 GMT Server: test-server/fake swsclose Content-Type: text/html diff --git a/tests/data/test80 b/tests/data/test80 index dcf153dd73..41656810b4 100644 --- a/tests/data/test80 +++ b/tests/data/test80 @@ -16,6 +16,7 @@ Date: Thu, 09 Nov 2010 14:49:00 GMT Server: test-server/fake swsclose Content-Type: text/html Funny-head: yesyes +Content-Length: 9 contents @@ -27,6 +28,7 @@ Date: Thu, 09 Nov 2010 14:49:00 GMT Server: test-server/fake swsclose Content-Type: text/html Funny-head: yesyes +Content-Length: 9 contents diff --git a/tests/data/test81 b/tests/data/test81 index 732f9dc6d0..eabd9fff75 100644 --- a/tests/data/test81 +++ b/tests/data/test81 @@ -26,6 +26,7 @@ This is not the real page either! HTTP/1.1 200 Things are fine in server land swsclose Server: Microsoft-IIS/5.0 Content-Type: text/html; charset=iso-8859-1 +Content-Length: 32 Finally, this is the real page! @@ -40,6 +41,7 @@ Proxy-Authenticate: NTLM TlRMTVNTUAACAAAAAgACADAAAAAGgoEAc51AYVDgyNcAAAAAAAAAAG4 HTTP/1.1 200 Things are fine in server land swsclose Server: Microsoft-IIS/5.0 Content-Type: text/html; charset=iso-8859-1 +Content-Length: 32 Finally, this is the real page! diff --git a/tests/data/test83 b/tests/data/test83 index d68a042be9..7c176969f4 100644 --- a/tests/data/test83 +++ b/tests/data/test83 @@ -16,6 +16,7 @@ Date: Thu, 09 Nov 2010 14:49:00 GMT Server: test-server/fake swsclose Content-Type: text/html Funny-head: yesyes +Content-Length: 9 contents @@ -27,6 +28,7 @@ Date: Thu, 09 Nov 2010 14:49:00 GMT Server: test-server/fake swsclose Content-Type: text/html Funny-head: yesyes +Content-Length: 9 contents diff --git a/tests/data/test84 b/tests/data/test84 index 387d0e08e6..9d5e678b69 100644 --- a/tests/data/test84 +++ b/tests/data/test84 @@ -10,7 +10,7 @@ HTTP proxy # Server-side -HTTP/1.1 200 OK +HTTP/1.0 200 OK Date: Thu, 09 Nov 2010 14:49:00 GMT Server: test-server/fake swsclose Content-Type: text/html diff --git a/tests/data/test85 b/tests/data/test85 index 50629e0dae..a82110769c 100644 --- a/tests/data/test85 +++ b/tests/data/test85 @@ -15,6 +15,7 @@ Date: Thu, 09 Nov 2010 14:49:00 GMT Server: test-server/fake swsclose Content-Type: text/html Funny-head: yesyes +Content-Length: 9 contents diff --git a/tests/data/test89 b/tests/data/test89 index 3ed2439db1..40b3074f42 100644 --- a/tests/data/test89 +++ b/tests/data/test89 @@ -50,6 +50,7 @@ This is not the real page either! HTTP/1.1 200 Things are fine in server land swsclose Server: Microsoft-IIS/5.0 Content-Type: text/html; charset=iso-8859-1 +Content-Length: 32 Finally, this is the real page! @@ -75,6 +76,7 @@ WWW-Authenticate: NTLM TlRMTVNTUAACAAAAAgACADAAAAAGgoEAc51AYVDgyNcAAAAAAAAAAG4Ab HTTP/1.1 200 Things are fine in server land swsclose Server: Microsoft-IIS/5.0 Content-Type: text/html; charset=iso-8859-1 +Content-Length: 32 Finally, this is the real page! diff --git a/tests/data/test9 b/tests/data/test9 index 7476278ec6..034a605175 100644 --- a/tests/data/test9 +++ b/tests/data/test9 @@ -8,7 +8,7 @@ HTTP file upload # Server-side -HTTP/1.1 200 OK swsclose +HTTP/1.0 200 OK swsclose Date: Thu, 09 Nov 2010 14:49:00 GMT Server: test-server/fake diff --git a/tests/data/test90 b/tests/data/test90 index df1bb69430..70e77645ea 100644 --- a/tests/data/test90 +++ b/tests/data/test90 @@ -17,6 +17,7 @@ WWW-Authenticate: Basic WWW-Authenticate: Wild-and-crazy WWW-Authenticate: NTLM Content-Type: text/html; charset=iso-8859-1 +Content-Length: 26 This is not the real page @@ -51,6 +52,7 @@ WWW-Authenticate: Basic WWW-Authenticate: Wild-and-crazy WWW-Authenticate: NTLM Content-Type: text/html; charset=iso-8859-1 +Content-Length: 26 This is not the real page @@ -71,6 +73,7 @@ This is not the real page either! HTTP/1.1 200 Things are fine in server land swsclose Server: Microsoft-IIS/5.0 Content-Type: text/html; charset=iso-8859-1 +Content-Length: 32 Finally, this is the real page! @@ -82,6 +85,7 @@ WWW-Authenticate: Basic WWW-Authenticate: Wild-and-crazy WWW-Authenticate: NTLM Content-Type: text/html; charset=iso-8859-1 +Content-Length: 26 HTTP/1.1 401 Now gimme that second request of crap Server: Microsoft-IIS/5.0 @@ -100,6 +104,7 @@ WWW-Authenticate: Basic WWW-Authenticate: Wild-and-crazy WWW-Authenticate: NTLM Content-Type: text/html; charset=iso-8859-1 +Content-Length: 26 HTTP/1.1 401 Now gimme that second round of crap Server: Microsoft-IIS/5.0 @@ -110,6 +115,7 @@ WWW-Authenticate: NTLM TlRMTVNTUAACAAAAAgACADAAAAAGgoEAc51AYVDgyNcAAAAAAAAAAG4Ab HTTP/1.1 200 Things are fine in server land swsclose Server: Microsoft-IIS/5.0 Content-Type: text/html; charset=iso-8859-1 +Content-Length: 32 Finally, this is the real page! diff --git a/tests/data/test91 b/tests/data/test91 index ad05459264..ae64b16ef3 100644 --- a/tests/data/test91 +++ b/tests/data/test91 @@ -37,6 +37,7 @@ This is not the real page either! HTTP/1.1 200 Things are fine in server land swsclose Server: Microsoft-IIS/5.0 Content-Type: text/html; charset=iso-8859-1 +Content-Length: 32 Finally, this is the real page! @@ -60,6 +61,7 @@ WWW-Authenticate: NTLM TlRMTVNTUAACAAAAAgACADAAAAAGgoEAc51AYVDgyNcAAAAAAAAAAG4Ab HTTP/1.1 200 Things are fine in server land swsclose Server: Microsoft-IIS/5.0 Content-Type: text/html; charset=iso-8859-1 +Content-Length: 32 Finally, this is the real page! diff --git a/tests/data/test95 b/tests/data/test95 index 5a5aebcd38..d2cd2c4299 100644 --- a/tests/data/test95 +++ b/tests/data/test95 @@ -14,6 +14,7 @@ Date: Thu, 09 Nov 2010 14:49:00 GMT Server: test-server/fake swsclose Content-Type: text/html Funny-head: yesyes +Content-Length: 9 contents @@ -25,6 +26,7 @@ Date: Thu, 09 Nov 2010 14:49:00 GMT Server: test-server/fake swsclose Content-Type: text/html Funny-head: yesyes +Content-Length: 9 contents diff --git a/tests/server/sws.c b/tests/server/sws.c index 9e63e507cd..a2d81c709a 100644 --- a/tests/server/sws.c +++ b/tests/server/sws.c @@ -572,6 +572,9 @@ static int send_doc(curl_socket_t sock, struct httprequest *req) req->open = FALSE; if(req->testno < 0) { + size_t msglen; + char msgbuf[64]; + switch(req->testno) { case DOCNUMBER_QUIT: logmsg("Replying to QUIT"); @@ -580,8 +583,10 @@ static int send_doc(curl_socket_t sock, struct httprequest *req) case DOCNUMBER_WERULEZ: /* we got a "friends?" question, reply back that we sure are */ logmsg("Identifying ourselves as friends"); - sprintf(weare, "HTTP/1.1 200 OK\r\n\r\nWE ROOLZ: %d\r\n", - (int)getpid()); + sprintf(msgbuf, "WE ROOLZ: %d\r\n", (int)getpid()); + msglen = strlen(msgbuf); + sprintf(weare, "HTTP/1.1 200 OK\r\nContent-Length: %d\r\n\r\n%s", + msglen, msgbuf); buffer = weare; break; case DOCNUMBER_INTERNAL: