Created
October 26, 2011 10:42
-
-
Save rahrens/1316008 to your computer and use it in GitHub Desktop.
request can't follow redirect URLs with inline ports in them
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Making the following amendment to options.start in main.js causes this issue to cease. | |
I believe this is due to some kind of caching taking place in the agent layer. I also believe | |
that we have a situation here where each callback is getting invoked multiple times. | |
*/ | |
options.start = function () { | |
options._started = true | |
options.method = options.method || 'GET' | |
var req_opts_fix = { | |
host: options.host, | |
port: options.port, | |
path: options.path, | |
method: options.method, | |
agent: options.agent | |
}; | |
// options.req = options.httpModule.request(options, function (response) { | |
options.req = options.httpModule.request(req_opts_fix, function (response) { | |
// ... | |
}) | |
// ... | |
}) | |
// ... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var callback = function (err, req, body) { | |
console.log("err: " + err); | |
console.log("req: " + req); | |
console.log("body: " + body); | |
}; | |
var request = require('request'); | |
/* This will loop n times, where n is the sum from 1 to maxRedirects. See parent bug description for a suggestion as to why. | |
*/ | |
request('https://app.compete.com:443/login', callback); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment