forked from nodejs/node-v0.x-archive
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-http-write-empty-string.js
More file actions
40 lines (31 loc) · 898 Bytes
/
test-http-write-empty-string.js
File metadata and controls
40 lines (31 loc) · 898 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
common = require("../common");
assert = common.assert
http = require('http');
assert = require('assert');
server = http.createServer(function (request, response) {
console.log('responding to ' + request.url);
response.writeHead(200, {'Content-Type': 'text/plain'});
response.write('1\n');
response.write('');
response.write('2\n');
response.write('');
response.end('3\n');
this.close();
})
var response="";
process.addListener('exit', function () {
assert.equal('1\n2\n3\n', response);
});
server.listen(common.PORT, function () {
var client = http.createClient(common.PORT);
var req = client.request("/");
req.end();
req.addListener('response', function (res) {
assert.equal(200, res.statusCode);
res.setEncoding("ascii");
res.addListener('data', function (chunk) {
response += chunk;
});
common.error("Got /hello response");
});
});