blob: 5f03c60b7518e620dc17bb050707892efe6166c6 (
plain)
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
|
'use strict';
require('../common');
var assert = require('assert');
var http = require('http');
var expected = 'Post Body For Test';
var result = '';
var server = http.Server(function(req, res) {
req.setEncoding('utf8');
req.on('data', function(chunk) {
result += chunk;
});
req.on('end', function() {
server.close();
res.writeHead(200);
res.end('hello world\n');
});
});
server.listen(0, function() {
http.request({
port: this.address().port,
path: '/',
method: 'POST'
}, function(res) {
console.log(res.statusCode);
res.resume();
}).on('error', function(e) {
console.log(e.message);
process.exit(1);
}).end(expected);
});
process.on('exit', function() {
assert.equal(expected, result);
});
|