From da58d03ff7be9fc5e0219d95ce2f9932e2272473 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 25 Nov 2006 13:32:04 +0000 Subject: 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. --- CHANGES | 13 +++++++++++++ RELEASE-NOTES | 4 +++- lib/transfer.c | 12 +++++++++++- tests/data/test11 | 2 ++ tests/data/test150 | 2 ++ tests/data/test153 | 2 ++ tests/data/test155 | 2 ++ tests/data/test159 | 2 ++ tests/data/test163 | 1 + tests/data/test166 | 1 + tests/data/test167 | 2 ++ tests/data/test168 | 2 ++ tests/data/test173 | 1 + tests/data/test174 | 1 + tests/data/test175 | 2 ++ tests/data/test176 | 2 ++ tests/data/test186 | 1 + tests/data/test187 | 2 ++ tests/data/test233 | 2 ++ tests/data/test234 | 2 ++ tests/data/test239 | 4 ++-- tests/data/test243 | 4 ++-- tests/data/test257 | 2 ++ tests/data/test26 | 2 +- tests/data/test264 | 1 + tests/data/test267 | 2 ++ tests/data/test27 | 1 + tests/data/test273 | 2 ++ tests/data/test276 | 2 ++ tests/data/test277 | 1 + tests/data/test278 | 1 + tests/data/test279 | 1 + tests/data/test28 | 2 ++ tests/data/test281 | 2 +- tests/data/test282 | 43 +++++++++++++++++++++++++++++++++++++++++++ tests/data/test43 | 2 ++ tests/data/test44 | 2 +- tests/data/test45 | 2 ++ tests/data/test515 | 3 ++- tests/data/test516 | 3 ++- tests/data/test56 | 2 +- tests/data/test59 | 2 +- tests/data/test62 | 2 +- tests/data/test63 | 1 + tests/data/test64 | 4 ++++ tests/data/test67 | 2 ++ tests/data/test69 | 4 ++++ tests/data/test71 | 1 + tests/data/test73 | 1 + tests/data/test79 | 2 +- tests/data/test80 | 2 ++ tests/data/test81 | 2 ++ tests/data/test83 | 2 ++ tests/data/test84 | 2 +- tests/data/test85 | 1 + tests/data/test89 | 2 ++ tests/data/test9 | 2 +- tests/data/test90 | 6 ++++++ tests/data/test91 | 2 ++ tests/data/test95 | 2 ++ tests/server/sws.c | 9 +++++++-- 61 files changed, 174 insertions(+), 19 deletions(-) create mode 100644 tests/data/test282 diff --git a/CHANGES b/CHANGES index 080ffed0b..c19e62b96 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 31fb48e3c..5bccf5cde 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 2d5d0dfe8..6b7b81978 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 e34a36646..84baa9076 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 7ae812d93..60e6b912d 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 1fd54a1f9..51137b38f 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 91ed13abd..871b0267a 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 2fcd7d502..8513c3073 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 c51adfccb..b87504e44 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 edc184abf..0e915f9e0 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 a23d94ba7..6fa5b1bd3 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 dbaf667c9..6f93ebab8 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 130fa9e07..0050e5ccc 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 32130f1be..b14d39b1c 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 3a979af98..db8f8a88a 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 e7ed3ecbb..f197367d7 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 e878bca80..763c6c805 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 67aace5d1..2919164f5 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 ca19364be..b11aabbbd 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 9c7d8c14e..c8775c543 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 7a789b600..77e7ae296 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 f8ef686e7..614dfc0fe 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 5c81409cf..90680f395 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 01b1bd7f3..f92cf2326 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 23bd99aa4..55f79b6d2 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 56d2a0a67..c379d4865 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 60a474aef..85b087aab 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 dbc8f8429..6aabfdcbd 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 7090ec581..aa56090f4 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 1828203be..f19e3423d 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 77e80456a..795b090ce 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 716a99ea6..2483e39d2 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 355924fa6..98d19c59d 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 ffbebbe66..f228d2d0b 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 000000000..b15745b18 --- /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 1ee0e2f89..fe6c54e18 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 ab66d11c0..beea1cf6e 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 b8d76201d..b8d96f7e6 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 566da84f4..c2dd48fe8 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 cd45b3115..3a8210f22 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 d4f369907..d84b86ddc 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 5e0e694fa..7ea59af86 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 48eca088e..fd08f7e5f 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 bcd5a188a..179b9e6b8 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 9521102c7..e2ba87dcd 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 da43a7d3a..19aeeec9b 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 333ec2c0f..7102342a9 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 733db358c..baedaab89 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 516784e05..6e612eec6 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 6d080bd5d..8954360f0 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 dcf153dd7..41656810b 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 732f9dc6d..eabd9fff7 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 d68a042be..7c176969f 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 387d0e08e..9d5e678b6 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 50629e0da..a82110769 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 3ed2439db..40b3074f4 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 7476278ec..034a60517 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 df1bb6943..70e77645e 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 ad0545926..ae64b16ef 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 5a5aebcd3..d2cd2c429 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 9e63e507c..a2d81c709 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: -- cgit v1.2.3