The question is fairly simple. I want to use a Node.js server as a proxy to log, authenticate, and forward HTTP queries to a backend HTTP server (PUT, GET, and DELETE requests).
What library should I use for that purpose? I'm afraid I can't find one.
Your code is non-blocking because it uses non-blocking I/O with the request() function. This means that node. js is free to service other requests while your series of http requests is being fetched.
destroy() really works, uncomment it, and the response object will keep emitting events until it closes itself (at which point node will exit this script).
NodeJS supports http.request as a standard module: http://nodejs.org/docs/v0.4.11/api/http.html#http.request
var http = require('http'); var options = { host: 'example.com', port: 80, path: '/foo.html' }; http.get(options, function(resp){ resp.on('data', function(chunk){ //do something with chunk }); }).on("error", function(e){ console.log("Got error: " + e.message); });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With