Giter VIP home page Giter VIP logo

Comments (5)

nfriedly avatar nfriedly commented on July 3, 2024 1

I think that

data.remoteRequest.on('error', next);

Should be

data.remoteResponse.on('error', next);

from node-unblocker.

nfriedly avatar nfriedly commented on July 3, 2024

Hi Cliff, sorry for the delay in responding. Proxy support isn't not something that I think I could implement any time soon. But if you want to put in the work, I'd be interested to see what you come up with and would consider merging it in.

from node-unblocker.

pepzwee avatar pepzwee commented on July 3, 2024

If anyone wants to implement request/request module these are the things I did:

  1. Install the module
  2. Require it in lib/proxy.js
  3. Add uri: uri to the options variable
  4. Replace data.remoteRequest = proto.... with
data.remoteRequest = request(options)

data.remoteRequest.on('response', function(remoteResponse) {
    data.remoteResponse = remoteResponse;
    data.remoteRequest.on('error', next);
    proxyResponse(data)
})

Seems to be working with minimal changes to the file. This gives you the option to add a proxy value to the options variable. Should be safe to remove the proto variable as well.

Gist: https://gist.github.com/pepzwee/7dabaec9c3273a94f099e44a4e49e224

from node-unblocker.

pepzwee avatar pepzwee commented on July 3, 2024

Ah, my bad. 😰 Yeah, it should be remoteResponse instead.

from node-unblocker.

nfriedly avatar nfriedly commented on July 3, 2024

Cool. I like keeping the core of the library fairly low-level, but if you want to send a PR to make that part configurable, and then maybe an example that shows how to use request there, I'd be happy to merge that in.

It could be something like a makeRequest configuration option that can be set to a function - have it accept the data object and a callback. It should make the request, update data, then call the callback. Once the callback is fired, then call proxyResponse(data).

And then if makeRequest isn't set, it can default to something pretty similar to the existing code, only with proxyResponse(data) replaced with the callback.

from node-unblocker.

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.