Giter Club home page Giter Club logo

Comments (7)

pwnall avatar pwnall commented on August 23, 2024

How about using node_httpAgent and note_httpsAgent properties to set the Agents? You can set them on an instance-by-instance basis, or you can change them in XMLHttpRequest.prototype

Would this work?

from node-xhr2.

asnowfix avatar asnowfix commented on August 23, 2024

This is what I had in mind: In my locally modified xhr2, this is what I am doing, with the following change:

  1. I have created an external interface construct(options.agents) and setAgents() to avoid fiddling directly with internal prototypes & variables
  2. I have renamed @node_httpAgent into @httpAgent (and same for httpsAgent), because it was more consistent with other class members.

If you are Ok with this, then I'll move forward & propose a patch (likely tomorrow in my timezone)

from node-xhr2.

asnowfix avatar asnowfix commented on August 23, 2024

Just uploaded #2

from node-xhr2.

pwnall avatar pwnall commented on August 23, 2024

Thank you for #2, I merged it!

How would you feel about a XMLHttpRequest.nodejsSetAgents() method that would set the prototype properties?

This way, you can use the following in your code that uses dropbox.js

Dropbox.Xhr.Request.nodejsSetAgents(....)

The nice thing about this approach is that if dropbox.js ever switches to another XHR library, proxy-setting code will fail right away during development, instead of silently ignoring the agent-related properties.

from node-xhr2.

asnowfix avatar asnowfix commented on August 23, 2024

In my local copy of Dropbox-js, I rather added a dependency on node-tunnel & gave additional Client instanciation parameter then passed down to xhr2. But I admit that I could rather leaver Dropbox-js un-modified & use the shortcut you propose. (1) Less code is always better than the opposite and (2) that lets dropbox-js of an additional dependency.

I think that the additional interface you propose is fine, but I would rather let you implent it, if you do not mind.

from node-xhr2.

pwnall avatar pwnall commented on August 23, 2024

Sweet, I'll get that in soon, and I will release 0.0.4 once I get some tests for events in.

from node-xhr2.

pwnall avatar pwnall commented on August 23, 2024

I hope this works now!

from node-xhr2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.