Skip to content

Instantly share code, notes, and snippets.

@isaacs
Created August 7, 2013 17:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isaacs/6176301 to your computer and use it in GitHub Desktop.
Save isaacs/6176301 to your computer and use it in GitHub Desktop.
From fac89367054274d86ccf3fdd0263ade36f1e2bc4 Mon Sep 17 00:00:00 2001
From: isaacs <i@izs.me>
Date: Wed, 7 Aug 2013 10:23:45 -0700
Subject: [PATCH] http: Support legacy agent.addRequest API
There are some agent subclasses using this today.
Despite the addRequest function being undocumented internal API, it's
easy enough to just support the old signature for backwards
compatibility
---
lib/_http_agent.js | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/lib/_http_agent.js b/lib/_http_agent.js
index 3af18a0..f973c34 100644
--- a/lib/_http_agent.js
+++ b/lib/_http_agent.js
@@ -128,6 +128,15 @@ Agent.prototype.getName = function(options) {
};
Agent.prototype.addRequest = function(req, options) {
+ // Legacy API: addRequest(req, host, port, path)
+ if (typeof options === 'string') {
+ options = {
+ host: options,
+ port: arguments[2],
+ path: arguments[3]
+ };
+ }
+
var host = options.host;
var port = options.port;
var localAddress = options.localAddress;
--
1.8.3.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment