Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Custom agent #44

Open
rauchg opened this Issue · 3 comments

4 participants

Guillermo Rauch Justin Matthews accelerated EugenDueck
Guillermo Rauch

Since agent: false I've lost the ability to track the net sockets that correspond with each request. This is hugely important for testing what happens to polling requests when the underlying sockets close in engine.io/socket.io when running the clients from Node.

A couple things would help me:

  • As I suggested before, the ability to generate a custom XMLHttpRequest:

    var XMLHTTPRequest = require('xmlhttprequest')({ agent: myCustomAgent });
  • The ability to access the Node request object. This requires adding some private property to the XMLHttpRequest instances.

Justin Matthews

+1. guille's solution is the most flexible, but in addition I think it would be beneficial/convenient to globally set the agent (which would also allow tweaking only maxSockets, another open issue).

require('xmlhttprequest').setHttpAgent(myCustomAgent);
require('xmlhttprequest').getHttpAgent().maxSockets = 100;
accelerated

Because of this issue in Node which changed rejectUnauthorized from default false to true (see joyent/node#3949), the TLS negotiation fails for self-signed certificates. This is very important when testing and before any CA signed certificates are installed in production. Currently there is no way to pass HTTP/HTTPS options into this module. Please consider enhancing the above agent option with a more generic option object (similar to the one used by HTTP/HTTPS requests) which also contains a custom Agent. This way users can set the "rejectUnauthorized" to false.

See examples for options format in http://nodejs.org/api/https.html.

I will open a separate issue for this so it can be tracked. I would however suggest passing the options in the Request function rather than constructor to be more in line with HTTP/HTTPS paradigm.

EugenDueck

@guille My proposed pull request (see above) would also address your issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.