Skip to content

Instantly share code, notes, and snippets.

@rahrens
Created October 26, 2011 10:42
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 rahrens/1316008 to your computer and use it in GitHub Desktop.
Save rahrens/1316008 to your computer and use it in GitHub Desktop.
request can't follow redirect URLs with inline ports in them
/* 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) {
// ...
})
// ...
})
// ...
}
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