node-http-proxy icon indicating copy to clipboard operation
node-http-proxy copied to clipboard

Is it possible to read the proxy's response?

Open DictumMortuum opened this issue 10 years ago • 4 comments

I recently built a small webserver that basically uses node-http-proxy to help me for development purposes.

I wanted to cache the RESTful API's response as a plaintext file to edit it and serve the edited content, if it exists.

However, in order to do this, I had to get pass gzip content. I ended up making another GET request to the API, unzipped the response and saved it to a file, here.

I've read the entry on modifying the proxy's response, however this is not what I want, because I want this to work for JSON, too (which is problematic for trumpet - which uses css selectors) and I don't want to make any modifications on-the-fly with server-side logic.

Is there an easy way to avoid the second request to my API?

DictumMortuum avatar Jun 01 '16 18:06 DictumMortuum

@DictumMortuum Hi, you can try this node-http-proxy-json

langjt avatar Jun 04 '16 15:06 langjt

@langjt is it possible to read proxy's response if the response is in chunked, gzipped and eventually the buffer will be html.

ravitadi avatar Aug 25 '16 05:08 ravitadi

@ravitadi If you need to deal with html, you can try harmon. If you only deal with json, you can try node-http-proxy-json

langjt avatar Sep 11 '16 12:09 langjt

@langjt As @DictumMortuum said he don't need to modify response. So node-http-proxy-json is overkill and small bottleneck because it gunziping and gziping response.

He only needs get original response (raw JSON, not gzip) and save it to file.

radeno avatar Aug 24 '17 19:08 radeno