Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7679805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:57:51+00:00 2026-05-31T17:57:51+00:00

I am using node-http-proxy . However, in addition to relaying HTTP requests, I also

  • 0

I am using node-http-proxy. However, in addition to relaying HTTP requests, I also need to listen to the incoming and outgoing data.

Intercepting the response data is where I’m struggling. Node’s ServerResponse object (and more generically the WritableStream interface) doesn’t broadcast a 'data' event. http-proxy seems to create it’s own internal request, which produces a ClientResponse object (which does broadcast the 'data' event) however this object is not exposed publically outside the proxy.

Any ideas how to solve this without monkey-patching node-http-proxy or creating a wrapper around the response object?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T17:57:52+00:00Added an answer on May 31, 2026 at 5:57 pm

    Related issue in issues of node-http-proxy on Github seems to imply this is not possible. For future attempts by others, here is how I hacked the issue:

    • you’ll quickly find out that the proxy is only calling writeHead(), write() and end() methods of the res object
    • since res is already an EventEmitter, you can start emitting new custom events
    • listen for these new events to assemble the response data and then use it
    var eventifyResponse = function(res) {
      var methods = ['writeHead', 'write', 'end'];
      methods.forEach(function(method){
        var oldMethod = res[method]; // remember original method
        res[method] = function() {   // replace with a wrapper
          oldMethod.apply(this, arguments); // call original method
          arguments = Array.prototype.slice.call(arguments, 0);
          arguments.unshift("method_" + method);
          this.emit.apply(this, arguments); // broadcast the event
        };
      });
    };
    
    res = eventifyResponse(res), outputData = '';
    
    res.on('method_writeHead', function(statusCode, headers) { saveHeaders(); });
    res.on('method_write',     function(data) { outputData += data; });
    res.on('method_end',       function(data) { use_data(outputData + data); });
    proxy.proxyRequest(req, res, options)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using node.js and express to handle HTTP requests and responses. By using the
I'm using node.js and socket.io. I'm using http-proxy to use port 80 on a
I want to make an outgoing HTTP call from node.js, using the standard http.Client
I need to implement a HTTP server in node.js without using http module. How
I'm creating a reverse HTTP proxy using Node.js for fun. The code is pretty
I'm using node.js to make a http request to a host. I found the
hi I'm trying create chat using node.js I see example in http://chat.nodejs.org/ I have
From http://metacpan.org/pod/XML::LibXML::Node : find evaluates the XPath 1.0 expression using the current node as
I'm using node, express and connect for a simple app and have basic HTTP
I'm running Nodejs and Apache alongside each other. node-http-proxy is listening on port 80

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.