This repository has been archived by the owner on Apr 22, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bugfix: Don't use chunked encoding for 1.0 requests.
- Loading branch information
Showing
2 changed files
with
49 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
process.mixin(require("./common")); | ||
tcp = require("tcp"); | ||
http = require("http"); | ||
|
||
var port = 7333; | ||
|
||
var body = "hello world\n"; | ||
var server_response = ""; | ||
var client_got_eof = false; | ||
|
||
var server = http.createServer(function (req, res) { | ||
res.sendHeader(200, {"Content-Type": "text/plain"}); | ||
res.sendBody(body); | ||
res.finish(); | ||
}) | ||
server.listen(port); | ||
|
||
var c = tcp.createConnection(port); | ||
|
||
c.setEncoding("utf8"); | ||
|
||
c.addListener("connect", function () { | ||
c.send( "GET / HTTP/1.0\r\n\r\n" ); | ||
}); | ||
|
||
c.addListener("receive", function (chunk) { | ||
puts(chunk); | ||
server_response += chunk; | ||
}); | ||
|
||
c.addListener("eof", function () { | ||
client_got_eof = true; | ||
c.close(); | ||
server.close(); | ||
}); | ||
|
||
process.addListener("exit", function () { | ||
var m = server_response.split("\r\n\r\n"); | ||
assert.equal(m[1], body); | ||
assert.equal(true, client_got_eof); | ||
}); |