2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2016-05-29 09:06:56 +02:00
|
|
|
require('../common');
|
2016-12-31 00:38:06 +01:00
|
|
|
const assert = require('assert');
|
|
|
|
const http = require('http');
|
|
|
|
const url = require('url');
|
2011-10-15 02:10:49 +02:00
|
|
|
|
|
|
|
function check(request) {
|
|
|
|
// a path should come over
|
|
|
|
assert.strictEqual(request.url, '/asdf');
|
|
|
|
}
|
|
|
|
|
2017-01-08 14:19:00 +01:00
|
|
|
const server = http.createServer(function(request, response) {
|
2011-10-15 02:10:49 +02:00
|
|
|
// run the check function
|
|
|
|
check.call(this, request, response);
|
|
|
|
response.writeHead(200, {});
|
|
|
|
response.end('ok');
|
|
|
|
server.close();
|
|
|
|
});
|
|
|
|
|
2016-05-29 09:06:56 +02:00
|
|
|
server.listen(0, function() {
|
2017-01-08 14:19:00 +01:00
|
|
|
const testURL = url.parse(`http://localhost:${this.address().port}/asdf`);
|
2016-05-29 09:06:56 +02:00
|
|
|
|
2011-10-15 02:10:49 +02:00
|
|
|
// make the request
|
|
|
|
http.request(testURL).end();
|
|
|
|
});
|