Venkat Akella found out that libcurl did not like HTTP responses that simply
authorDaniel Stenberg <daniel@haxx.se>
Sat, 25 Nov 2006 13:32:04 +0000 (13:32 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Sat, 25 Nov 2006 13:32:04 +0000 (13:32 +0000)
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.

61 files changed:
CHANGES
RELEASE-NOTES
lib/transfer.c
tests/data/test11
tests/data/test150
tests/data/test153
tests/data/test155
tests/data/test159
tests/data/test163
tests/data/test166
tests/data/test167
tests/data/test168
tests/data/test173
tests/data/test174
tests/data/test175
tests/data/test176
tests/data/test186
tests/data/test187
tests/data/test233
tests/data/test234
tests/data/test239
tests/data/test243
tests/data/test257
tests/data/test26
tests/data/test264
tests/data/test267
tests/data/test27
tests/data/test273
tests/data/test276
tests/data/test277
tests/data/test278
tests/data/test279
tests/data/test28
tests/data/test281
tests/data/test282 [new file with mode: 0644]
tests/data/test43
tests/data/test44
tests/data/test45
tests/data/test515
tests/data/test516
tests/data/test56
tests/data/test59
tests/data/test62
tests/data/test63
tests/data/test64
tests/data/test67
tests/data/test69
tests/data/test71
tests/data/test73
tests/data/test79
tests/data/test80
tests/data/test81
tests/data/test83
tests/data/test84
tests/data/test85
tests/data/test89
tests/data/test9
tests/data/test90
tests/data/test91
tests/data/test95
tests/server/sws.c

diff --git a/CHANGES b/CHANGES
index 080ffed..c19e62b 100644 (file)
--- 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.
 
index 31fb48e..5bccf5c 100644 (file)
@@ -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)
index 2d5d0df..6b7b819 100644 (file)
@@ -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:
index e34a366..84baa90 100644 (file)
@@ -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
 
index 7ae812d..60e6b91 100644 (file)
@@ -21,6 +21,7 @@ This is not the real page either!
 HTTP/1.1 200 Things are fine in server land swsclose\r
 Server: Microsoft-IIS/5.0\r
 Content-Type: text/html; charset=iso-8859-1\r
+Content-Length: 32\r
 \r
 Finally, this is the real page!
 </data1002>
@@ -35,6 +36,7 @@ WWW-Authenticate: NTLM TlRMTVNTUAACAAAAAgACADAAAAAGgoEAc51AYVDgyNcAAAAAAAAAAG4Ab
 HTTP/1.1 200 Things are fine in server land swsclose\r
 Server: Microsoft-IIS/5.0\r
 Content-Type: text/html; charset=iso-8859-1\r
+Content-Length: 32\r
 \r
 Finally, this is the real page!
 </datacheck>
index 1fd54a1..51137b3 100644 (file)
@@ -6,6 +6,7 @@ HTTP/1.1 401 Authorization Required swsclose
 Server: Apache/1.3.27 (Darwin) PHP/4.1.2\r
 WWW-Authenticate: Digest realm="testrealm", nonce="1053604145"\r
 Content-Type: text/html; charset=iso-8859-1\r
+Content-Length: 26\r
 \r
 This is not the real page
 </data1>
@@ -95,6 +96,7 @@ HTTP/1.1 401 Authorization Required swsclose
 Server: Apache/1.3.27 (Darwin) PHP/4.1.2\r
 WWW-Authenticate: Digest realm="testrealm", nonce="1053604145"\r
 Content-Type: text/html; charset=iso-8859-1\r
+Content-Length: 26\r
 \r
 HTTP/1.1 200 OK\r
 Server: Apache/1.3.27 (Darwin) PHP/4.1.2\r
index 91ed13a..871b026 100644 (file)
@@ -33,6 +33,7 @@ This is not the real page either!
 HTTP/1.1 200 Type-3 Recevied and all Things are fine swsclose\r
 Server: Microsoft-IIS/5.0\r
 Content-Type: text/html; charset=iso-8859-1\r
+Content-Length: 32\r
 \r
 Finally, this is the real page!
 </data1002>
@@ -55,6 +56,7 @@ WWW-Authenticate: NTLM TlRMTVNTUAACAAAAAgACADAAAAAGgoEAc51AYVDgyNcAAAAAAAAAAG4Ab
 HTTP/1.1 200 Type-3 Recevied and all Things are fine swsclose\r
 Server: Microsoft-IIS/5.0\r
 Content-Type: text/html; charset=iso-8859-1\r
+Content-Length: 32\r
 \r
 Finally, this is the real page!
 </datacheck>
index 2fcd7d5..8513c30 100644 (file)
@@ -21,6 +21,7 @@ This is not the real page either!
 HTTP/1.1 200 Things are fine in server land swsclose\r
 Server: Microsoft-IIS/5.0\r
 Content-Type: text/html; charset=iso-8859-1\r
+Content-Length: 32\r
 \r
 Finally, this is the real page!
 </data1002>
@@ -35,6 +36,7 @@ WWW-Authenticate: NTLM TlRMTVNTUAACAAAAAgACADAAAAAGgoEAc51AYVDgyNcAAAAAAAAAAG4Ab
 HTTP/1.1 200 Things are fine in server land swsclose\r
 Server: Microsoft-IIS/5.0\r
 Content-Type: text/html; charset=iso-8859-1\r
+Content-Length: 32\r
 \r
 Finally, this is the real page!
 </datacheck>
index c51adfc..b87504e 100644 (file)
@@ -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
 </data>
index edc184a..0e915f9 100644 (file)
@@ -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
 </data>
index a23d94b..6fa5b1b 100644 (file)
@@ -9,6 +9,7 @@ WWW-Authenticate: Digest realm="weirdorealm", nonce="12345"
 <data1000>
 HTTP/1.1 200 OK swsclose\r
 Server: no
+Content-Length: 15
 \r
 Nice auth sir!
 </data1000>
@@ -19,6 +20,7 @@ WWW-Authenticate: Digest realm="weirdorealm", nonce="12345"
 \r
 HTTP/1.1 200 OK swsclose\r
 Server: no
+Content-Length: 15
 \r
 Nice auth sir!
 </datacheck>
index dbaf667..6f93eba 100644 (file)
@@ -20,6 +20,7 @@ you should ignore this data too
 <data1001>
 HTTP/1.1 200 OK swsclose\r
 Server: no
+Content-Length: 15
 \r
 Nice auth sir!
 </data1001>
@@ -33,6 +34,7 @@ WWW-Authenticate: Digest realm="realmweirdo", nonce="123456"
 \r
 HTTP/1.1 200 OK swsclose\r
 Server: no
+Content-Length: 15
 \r
 Nice auth sir!
 </datacheck>
index 130fa9e..0050e5c 100644 (file)
@@ -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
 
index 32130f1..b14d39b 100644 (file)
@@ -5,6 +5,7 @@ HTTP/1.1 200 beng swsclose
 Server: Microsoft-IIS/6.0\r
 Authentication-Info: Passport1.4 tname=MSPAuth,tname=MSPProf,tname=MSPConsent,tname=MSPSecAuth\r
 Content-Type: text/html; charset=iso-8859-1\r
+Content-Length: 26
 \r
 This is not the real page
 </data>
index 3a979af..db8f8a8 100644 (file)
@@ -13,6 +13,7 @@ This is not the real page
 HTTP/1.1 200 moo swsclose\r
 Server: Microsoft-IIS/6.0\r
 Content-Type: text/html; charset=iso-8859-1\r
+Content-Length: 16
 \r
 content for you
 </data1>
@@ -26,6 +27,7 @@ Content-Type: text/html; charset=iso-8859-1
 HTTP/1.1 200 moo swsclose\r
 Server: Microsoft-IIS/6.0\r
 Content-Type: text/html; charset=iso-8859-1\r
+Content-Length: 16
 \r
 content for you
 </datacheck>
index e7ed3ec..f197367 100644 (file)
@@ -14,6 +14,7 @@ Content-Type: text/html; charset=iso-8859-1
 HTTP/1.1 200 moo swsclose\r
 Server: Microsoft-IIS/6.0\r
 Content-Type: text/html; charset=iso-8859-1\r
+Content-Length: 16
 \r
 content for you
 </data>
@@ -27,6 +28,7 @@ Content-Type: text/html; charset=iso-8859-1
 HTTP/1.1 200 moo swsclose\r
 Server: Microsoft-IIS/6.0\r
 Content-Type: text/html; charset=iso-8859-1\r
+Content-Length: 16
 \r
 content for you
 </datacheck>
index e878bca..763c6c8 100644 (file)
@@ -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
 
index 67aace5..2919164 100644 (file)
@@ -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
 
index ca19364..b11aabb 100644 (file)
@@ -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
 </data2>
@@ -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
 </datacheck>
index 9c7d8c1..c8775c5 100644 (file)
@@ -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
 </data2>
@@ -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
 </datacheck>
index 7a789b6..77e7ae2 100644 (file)
@@ -16,7 +16,7 @@ Hey you, authenticate or go away!
 HTTP/1.1 200 Things are fine in proxy land swsclose\r
 Server: Microsoft-IIS/5.0\r
 Content-Type: text/html; charset=iso-8859-1\r
-Content-Length; 42\r
+Content-Length: 42\r
 \r
 Contents of that page you requested, sir.
 </data1002>
@@ -29,7 +29,7 @@ Content-Length: 34
 HTTP/1.1 200 Things are fine in proxy land swsclose\r
 Server: Microsoft-IIS/5.0\r
 Content-Type: text/html; charset=iso-8859-1\r
-Content-Length; 42\r
+Content-Length: 42\r
 \r
 Contents of that page you requested, sir.
 </datacheck>
index f8ef686..614dfc0 100644 (file)
@@ -36,7 +36,7 @@ Hey you, authenticate or go away!
 HTTP/1.1 200 Things are fine in proxy land swsclose\r
 Server: Microsoft-IIS/5.0\r
 Content-Type: text/html; charset=iso-8859-1\r
-Content-Length; 42\r
+Content-Length: 42\r
 \r
 Contents of that page you requested, sir.
 </data1002>
@@ -57,7 +57,7 @@ Content-Length: 34
 HTTP/1.1 200 Things are fine in proxy land swsclose\r
 Server: Microsoft-IIS/5.0\r
 Content-Type: text/html; charset=iso-8859-1\r
-Content-Length; 42\r
+Content-Length: 42\r
 \r
 Contents of that page you requested, sir.
 </datacheck>
index 5c81409..90680f3 100644 (file)
@@ -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
 
index 01b1bd7..f92cf23 100644 (file)
@@ -7,7 +7,7 @@ HTTP GET
 # Server-side
 <reply>
 <data>
-HTTP/1.1 200 Mooo swsclose
+HTTP/1.0 200 Mooo swsclose
 Server: test-server/fake
 Connection: close
 
index 23bd99a..55f79b6 100644 (file)
@@ -12,6 +12,7 @@ HTTP proxy Basic auth
 HTTP/1.1 200 OK swsclose\r
 Date: Thu, 09 Nov 2010 14:49:00 GMT\r
 Content-Type: text/html\r
+Content-Length: 26\r
 \r
 the content would go here
 </data>
index 56d2a0a..c379d48 100644 (file)
@@ -28,6 +28,7 @@ This is not the real page either!
 HTTP/1.1 200 Things are fine in server land swsclose\r
 Server: Microsoft-IIS/5.0\r
 Content-Type: text/html; charset=iso-8859-1\r
+Content-Length: 32\r
 \r
 Finally, this is the real page!
 </data1002>
@@ -42,6 +43,7 @@ WWW-Authenticate: NTLM TlRMTVNTUAACAAAAAgACADAAAAAGgoEAc51AYVDgyNcAAAAAAAAAAG4Ab
 HTTP/1.1 200 Things are fine in server land swsclose\r
 Server: Microsoft-IIS/5.0\r
 Content-Type: text/html; charset=iso-8859-1\r
+Content-Length: 32\r
 \r
 Finally, this is the real page!
 </datacheck>
index 60a474a..85b087a 100644 (file)
@@ -11,6 +11,7 @@ cookies
 HTTP/1.1 200 Mooo swsclose
 Connection: close
 Set-Cookie: path=/; thewinneris=nowayyouwin;
+Content-Length: 8
 
 *flopp*
 </data>
index dbc8f84..6aabfdc 100644 (file)
@@ -23,6 +23,7 @@ This is not the real page
 HTTP/1.1 200 OK swsclose\r
 Server: Apache/1.3.27 (Darwin) PHP/4.1.2\r
 Content-Type: text/html; charset=iso-8859-1\r
+Content-Length: 23\r
 \r
 This IS the real page!
 </data1000>
@@ -37,6 +38,7 @@ Content-Type: text/html; charset=iso-8859-1
 HTTP/1.1 200 OK swsclose\r
 Server: Apache/1.3.27 (Darwin) PHP/4.1.2\r
 Content-Type: text/html; charset=iso-8859-1\r
+Content-Length: 23\r
 \r
 This IS the real page!
 </datacheck>
index 7090ec5..aa56090 100644 (file)
@@ -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
 
index 1828203..f19e342 100644 (file)
@@ -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
 
index 77e8045..795b090 100644 (file)
@@ -12,6 +12,7 @@ HTTP proxy Basic auth
 HTTP/1.1 200 OK swsclose\r
 Date: Thu, 09 Nov 2010 14:49:00 GMT\r
 Content-Type: text/html\r
+Content-Length: 27\r
 \r
 the content would go here\r
 </data>\r
index 716a99e..2483e39 100644 (file)
@@ -12,6 +12,7 @@ HTTP proxy Basic auth
 HTTP/1.1 200 OK swsclose\r
 Date: Thu, 09 Nov 2010 14:49:00 GMT\r
 Content-Type: text/html\r
+Content-Length: 27\r
 \r
 the content would go here\r
 </data>\r
index 355924f..98d19c5 100644 (file)
@@ -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
 
index ffbebbe..f228d2d 100644 (file)
@@ -50,7 +50,7 @@ Weird
 </strip>
 <protocol>
 PUT /we/want/281 HTTP/1.1\r
-Host: 127.0.0.1:%HTTPPORT\r
+Host: %HOSTIP:%HTTPPORT\r
 Accept: */*\r
 Content-Length: 38\r
 Expect: 100-continue\r
diff --git a/tests/data/test282 b/tests/data/test282
new file mode 100644 (file)
index 0000000..b15745b
--- /dev/null
@@ -0,0 +1,43 @@
+<info>
+<keywords>
+HTTP
+HTTP GET
+</keywords>
+</info>
+
+#
+# Server-side
+<reply>
+<data>
+HTTP/1.1 200 OK
+
+</data>
+</reply>
+
+#
+# Client-side
+<client>
+<server>
+http
+</server>
+ <name>
+HTTP GET with no response body or headers
+ </name>
+ <command>
+http://%HOSTIP:%HTTPPORT/282
+</command>
+</client>
+
+#
+# Verify data after the test has been "shot"
+<verify>
+<strip>
+^User-Agent:.*
+</strip>
+<protocol>
+GET /282 HTTP/1.1\r
+Host: %HOSTIP:%HTTPPORT\r
+Accept: */*\r
+\r
+</protocol>
+</verify>
index 1ee0e2f..fe6c54e 100644 (file)
@@ -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
 
index ab66d11..beea1cf 100644 (file)
@@ -8,7 +8,7 @@ HTTP replaced headers
 # Server-side
 <reply>
 <data>
-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
 
index b8d7620..b8d96f7 100644 (file)
@@ -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
 
index 566da84..c2dd48f 100644 (file)
@@ -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
 </data>
@@ -36,7 +37,7 @@ http://%HOSTIP:%HTTPPORT/515
 </strip>
 <protocol>
 POST /515 HTTP/1.1\r
-Host: 127.0.0.1:%HTTPPORT\r
+Host: %HOSTIP:%HTTPPORT\r
 Accept: */*\r
 Content-Length: 0\r
 Content-Type: application/x-www-form-urlencoded\r
index cd45b31..3a8210f 100644 (file)
@@ -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
 </data>
@@ -36,7 +37,7 @@ http://%HOSTIP:%HTTPPORT/516
 </strip>
 <protocol>
 POST /516 HTTP/1.1\r
-Host: 127.0.0.1:%HTTPPORT\r
+Host: %HOSTIP:%HTTPPORT\r
 Accept: */*\r
 Content-Length: 0\r
 \r
index d4f3699..d84b86d 100644 (file)
@@ -9,7 +9,7 @@ chunked Transfer-Encoding
 # Server-side
 <reply>
 <data>
-HTTP/1.1 200 OK swsclose
+HTTP/1.0 200 OK swsclose
 Funny-head: yesyes
 
 This is the proof it works
index 5e0e694..7ea59af 100644 (file)
@@ -8,7 +8,7 @@ HTTP GET
 # Server-side
 <reply name="1">
 <data>
-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
 
index 48eca08..fd08f7e 100644 (file)
@@ -8,7 +8,7 @@ HTTP replaced headers
 # Server-side
 <reply>
 <data>
-HTTP/1.1 200 OK swsclose\r
+HTTP/1.0 200 OK swsclose\r
 Date: Thu, 09 Nov 2010 14:49:00 GMT\r
 Content-Type: text/html\r
 \r
index bcd5a18..179b9e6 100644 (file)
@@ -12,6 +12,7 @@ HTTP proxy Basic auth
 HTTP/1.1 200 OK swsclose\r
 Date: Thu, 09 Nov 2010 14:49:00 GMT\r
 Content-Type: text/html\r
+Content-Length: 26
 \r
 the content would go here
 </data>
index 9521102..e2ba87d 100644 (file)
@@ -12,6 +12,7 @@ HTTP/1.1 401 Authorization Required swsclose
 Server: Apache/1.3.27 (Darwin) PHP/4.1.2\r
 WWW-Authenticate: Digest realm="testrealm", nonce="1053604145"\r
 Content-Type: text/html; charset=iso-8859-1\r
+Content-Length: 26\r
 \r
 This is not the real page
 </data>
@@ -22,6 +23,7 @@ This is not the real page
 HTTP/1.1 200 OK swsclose\r
 Server: Apache/1.3.27 (Darwin) PHP/4.1.2\r
 Content-Type: text/html; charset=iso-8859-1\r
+Content-Length: 23\r
 \r
 This IS the real page!
 </data1000>
@@ -31,10 +33,12 @@ HTTP/1.1 401 Authorization Required swsclose
 Server: Apache/1.3.27 (Darwin) PHP/4.1.2\r
 WWW-Authenticate: Digest realm="testrealm", nonce="1053604145"\r
 Content-Type: text/html; charset=iso-8859-1\r
+Content-Length: 26\r
 \r
 HTTP/1.1 200 OK swsclose\r
 Server: Apache/1.3.27 (Darwin) PHP/4.1.2\r
 Content-Type: text/html; charset=iso-8859-1\r
+Content-Length: 23\r
 \r
 This IS the real page!
 </datacheck>
index da43a7d..19aeeec 100644 (file)
@@ -28,6 +28,7 @@ This is not the real page either!
 HTTP/1.1 200 Things are fine in server land swsclose\r
 Server: Microsoft-IIS/5.0\r
 Content-Type: text/html; charset=iso-8859-1\r
+Content-Length: 32\r
 \r
 Finally, this is the real page!
 </data1002>
@@ -42,6 +43,7 @@ WWW-Authenticate: NTLM TlRMTVNTUAACAAAAAgACADAAAAAGgoEAc51AYVDgyNcAAAAAAAAAAG4Ab
 HTTP/1.1 200 Things are fine in server land swsclose\r
 Server: Microsoft-IIS/5.0\r
 Content-Type: text/html; charset=iso-8859-1\r
+Content-Length: 32\r
 \r
 Finally, this is the real page!
 </datacheck>
index 333ec2c..7102342 100644 (file)
@@ -14,6 +14,7 @@ WWW-Authenticate: Basic
 WWW-Authenticate: Wild-and-crazy\r
 WWW-Authenticate: NTLM\r
 Content-Type: text/html; charset=iso-8859-1\r
+Content-Length: 26\r
 \r
 This is not the real page
 </data>
@@ -36,6 +37,7 @@ This is not the real page either!
 HTTP/1.1 200 Things are fine in server land swsclose\r
 Server: Microsoft-IIS/5.0\r
 Content-Type: text/html; charset=iso-8859-1\r
+Content-Length: 32\r
 \r
 Finally, this is the real page!
 </data1002>
@@ -47,6 +49,7 @@ WWW-Authenticate: Basic
 WWW-Authenticate: Wild-and-crazy\r
 WWW-Authenticate: NTLM\r
 Content-Type: text/html; charset=iso-8859-1\r
+Content-Length: 26\r
 \r
 HTTP/1.1 401 Now gimme that second request of crap\r
 Server: Microsoft-IIS/5.0\r
@@ -57,6 +60,7 @@ WWW-Authenticate: NTLM TlRMTVNTUAACAAAAAgACADAAAAAGgoEAc51AYVDgyNcAAAAAAAAAAG4Ab
 HTTP/1.1 200 Things are fine in server land swsclose\r
 Server: Microsoft-IIS/5.0\r
 Content-Type: text/html; charset=iso-8859-1\r
+Content-Length: 32\r
 \r
 Finally, this is the real page!
 </datacheck>
index 733db35..baedaab 100644 (file)
@@ -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
 
index 516784e..6e612ee 100644 (file)
@@ -12,6 +12,7 @@ HTTP/1.1 200 OK swsclose
 Date: Thu, 09 Nov 2010 14:49:00 GMT\r
 Content-Type: text/html\r
 Set-Cookie: IPCZQX01af0fca5c=000010008168c200d25dfc4b; path=/; domain=.NOT_DISCLOSED.se\r
+Content-Length: 4\r
 \r
 boo
 </data>
index 6d080bd..8954360 100644 (file)
@@ -10,7 +10,7 @@ HTTP proxy
 # Server-side
 <reply>
 <data>
-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
index dcf153d..4165681 100644 (file)
@@ -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
 </data>
@@ -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
 </datacheck>
index 732f9dc..eabd9ff 100644 (file)
@@ -26,6 +26,7 @@ This is not the real page either!
 HTTP/1.1 200 Things are fine in server land swsclose\r
 Server: Microsoft-IIS/5.0\r
 Content-Type: text/html; charset=iso-8859-1\r
+Content-Length: 32\r
 \r
 Finally, this is the real page!
 </data1002>
@@ -40,6 +41,7 @@ Proxy-Authenticate: NTLM TlRMTVNTUAACAAAAAgACADAAAAAGgoEAc51AYVDgyNcAAAAAAAAAAG4
 HTTP/1.1 200 Things are fine in server land swsclose\r
 Server: Microsoft-IIS/5.0\r
 Content-Type: text/html; charset=iso-8859-1\r
+Content-Length: 32\r
 \r
 Finally, this is the real page!
 </datacheck>
index d68a042..7c17696 100644 (file)
@@ -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
 </data>
@@ -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
 </datacheck>
index 387d0e0..9d5e678 100644 (file)
@@ -10,7 +10,7 @@ HTTP proxy
 # Server-side
 <reply>
 <data>
-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
index 50629e0..a821107 100644 (file)
@@ -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
 </data>
index 3ed2439..40b3074 100644 (file)
@@ -50,6 +50,7 @@ This is not the real page either!
 HTTP/1.1 200 Things are fine in server land swsclose\r
 Server: Microsoft-IIS/5.0\r
 Content-Type: text/html; charset=iso-8859-1\r
+Content-Length: 32\r
 \r
 Finally, this is the real page!
 </data1012>
@@ -75,6 +76,7 @@ WWW-Authenticate: NTLM TlRMTVNTUAACAAAAAgACADAAAAAGgoEAc51AYVDgyNcAAAAAAAAAAG4Ab
 HTTP/1.1 200 Things are fine in server land swsclose\r
 Server: Microsoft-IIS/5.0\r
 Content-Type: text/html; charset=iso-8859-1\r
+Content-Length: 32\r
 \r
 Finally, this is the real page!
 </datacheck>
index 7476278..034a605 100644 (file)
@@ -8,7 +8,7 @@ HTTP file upload
 # Server-side
 <reply>
 <data>
-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
 
index df1bb69..70e7764 100644 (file)
@@ -17,6 +17,7 @@ WWW-Authenticate: Basic
 WWW-Authenticate: Wild-and-crazy\r
 WWW-Authenticate: NTLM\r
 Content-Type: text/html; charset=iso-8859-1\r
+Content-Length: 26\r
 \r
 This is not the real page
 </data>
@@ -51,6 +52,7 @@ WWW-Authenticate: Basic
 WWW-Authenticate: Wild-and-crazy\r
 WWW-Authenticate: NTLM\r
 Content-Type: text/html; charset=iso-8859-1\r
+Content-Length: 26\r
 \r
 This is not the real page
 </data10>
@@ -71,6 +73,7 @@ This is not the real page either!
 HTTP/1.1 200 Things are fine in server land swsclose\r
 Server: Microsoft-IIS/5.0\r
 Content-Type: text/html; charset=iso-8859-1\r
+Content-Length: 32\r
 \r
 Finally, this is the real page!
 </data1012>
@@ -82,6 +85,7 @@ WWW-Authenticate: Basic
 WWW-Authenticate: Wild-and-crazy\r
 WWW-Authenticate: NTLM\r
 Content-Type: text/html; charset=iso-8859-1\r
+Content-Length: 26\r
 \r
 HTTP/1.1 401 Now gimme that second request of crap\r
 Server: Microsoft-IIS/5.0\r
@@ -100,6 +104,7 @@ WWW-Authenticate: Basic
 WWW-Authenticate: Wild-and-crazy\r
 WWW-Authenticate: NTLM\r
 Content-Type: text/html; charset=iso-8859-1\r
+Content-Length: 26\r
 \r
 HTTP/1.1 401 Now gimme that second round of crap\r
 Server: Microsoft-IIS/5.0\r
@@ -110,6 +115,7 @@ WWW-Authenticate: NTLM TlRMTVNTUAACAAAAAgACADAAAAAGgoEAc51AYVDgyNcAAAAAAAAAAG4Ab
 HTTP/1.1 200 Things are fine in server land swsclose\r
 Server: Microsoft-IIS/5.0\r
 Content-Type: text/html; charset=iso-8859-1\r
+Content-Length: 32\r
 \r
 Finally, this is the real page!
 </datacheck>
index ad05459..ae64b16 100644 (file)
@@ -37,6 +37,7 @@ This is not the real page either!
 HTTP/1.1 200 Things are fine in server land swsclose\r
 Server: Microsoft-IIS/5.0\r
 Content-Type: text/html; charset=iso-8859-1\r
+Content-Length: 32\r
 \r
 Finally, this is the real page!
 </data1002>
@@ -60,6 +61,7 @@ WWW-Authenticate: NTLM TlRMTVNTUAACAAAAAgACADAAAAAGgoEAc51AYVDgyNcAAAAAAAAAAG4Ab
 HTTP/1.1 200 Things are fine in server land swsclose\r
 Server: Microsoft-IIS/5.0\r
 Content-Type: text/html; charset=iso-8859-1\r
+Content-Length: 32\r
 \r
 Finally, this is the real page!
 </datacheck>
index 5a5aebc..d2cd2c4 100644 (file)
@@ -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
 </data>
@@ -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
 </datacheck>
index 9e63e50..a2d81c7 100644 (file)
@@ -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: