Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,8 @@ Client.prototype.request = function(method, path, headers) {
exports.Client = internalUtil.deprecate(Client, 'http.Client is deprecated.');

exports.createClient = internalUtil.deprecate(function(port, host) {
return new Client(port, host);
const client = new Client(port, host);
// Need to set the prototype of the deprecated class to fix `instanceof`.
Object.setPrototypeOf(client, exports.Client.prototype);
return client;
}, 'http.createClient is deprecated. Use http.request instead.');
1 change: 1 addition & 0 deletions test/parallel/test-http-legacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ var server = http.createServer(function(req, res) {

server.listen(0, common.mustCall(function() {
var client = http.createClient(this.address().port);
assert(client instanceof http.Client);
var req = client.request('/hello', {'Accept': '*/*', 'Foo': 'bar'});
setTimeout(function() {
req.end();
Expand Down