mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 21:58:48 +02:00

PR-URL: https://github.com/nodejs/node/pull/10638 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Michal Zasso <targos@protonmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
22 lines
585 B
JavaScript
22 lines
585 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const http = require('http');
|
|
const url = require('url');
|
|
const URL = url.URL;
|
|
|
|
var server = http.createServer(common.mustCall(function(req, res) {
|
|
assert.equal('GET', req.method);
|
|
assert.equal('/foo?bar', req.url);
|
|
res.writeHead(200, {'Content-Type': 'text/plain'});
|
|
res.write('hello\n');
|
|
res.end();
|
|
server.close();
|
|
}, 3));
|
|
|
|
server.listen(0, function() {
|
|
const u = `http://127.0.0.1:${this.address().port}/foo?bar`;
|
|
http.get(u);
|
|
http.get(url.parse(u));
|
|
http.get(new URL(u));
|
|
});
|