blob: cabd32871965dc8999f279f523d27ee526139fd2 (
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
|
var common = require('../common');
var assert = require('assert');
var net = require('net');
var http = require('http');
var url = require('url');
// Make sure no exceptions are thrown when receiving malformed HTTP
// requests.
var nrequests_completed = 0;
var nrequests_expected = 1;
var server = http.createServer(function(req, res) {
console.log('req: ' + JSON.stringify(url.parse(req.url)));
res.writeHead(200, {'Content-Type': 'text/plain'});
res.write('Hello World');
res.end();
if (++nrequests_completed == nrequests_expected) server.close();
});
server.listen(common.PORT);
server.addListener('listening', function() {
var c = net.createConnection(common.PORT);
c.addListener('connect', function() {
c.write('GET /hello?foo=%99bar HTTP/1.1\r\n\r\n');
c.end();
});
// TODO add more!
});
process.addListener('exit', function() {
assert.equal(nrequests_expected, nrequests_completed);
});
|