Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http: deprecate Agent.prototype.addRequest() legacy sig #11353

Closed
wants to merge 1 commit into from
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
6 changes: 6 additions & 0 deletions doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,12 @@ Type: Runtime
of V8 5.8. It is replaced by Inspector which is activated with `--inspect`
instead.

### DEP0063: http.Agent.prototype.addRequest() Legacy API

The legacy `http.Agent.prototype.addRequest(req, host, port, localAddress)`
variation has been deprecated in favor of
`http.Agent.prototype.addRequest(req, options)`.

[alloc]: buffer.html#buffer_class_method_buffer_alloc_size_fill_encoding
[alloc_unsafe_size]: buffer.html#buffer_class_method_buffer_allocunsafe_size
[`Buffer.allocUnsafeSlow(size)`]: buffer.html#buffer_class_method_buffer_allocunsafeslow_size
Expand Down
11 changes: 8 additions & 3 deletions lib/_http_agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,18 @@ Agent.prototype.getName = function getName(options) {
return name;
};

Agent.prototype.addRequest = function addRequest(req, options) {
Agent.prototype.addRequest = function addRequest(req, options,
port, localAddress) {
// Legacy API: addRequest(req, host, port, localAddress)
if (typeof options === 'string') {
process.emitWarning(
'The Agent.prototype.addRequest(req, host, port, localAddress) ' +
'API has been deprecated. Please use Agent.prototype.addRequest(' +
'req, options) instead.', 'DeprecationWarning', 'DEP0063');
options = {
host: options,
port: arguments[2],
localAddress: arguments[3]
port: port,
localAddress: localAddress
};
}

Expand Down