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

Response broken after modification

Open art1c0 opened this issue 9 years ago • 5 comments

I have investigated the issue already, but cannot fix it yet... The problem is that when response is modified - the content-length header remains the same, and when response length is somewhat different - client fails to render the response. I have tried to change it a bit like this: body.value = 1; it works. but if you change more - it fails: body.value = 111111;

art1c0 avatar Jul 19 '17 16:07 art1c0

Actually I guess that when the modified response is shorter than the original one - it will work, because the content-length header has bigger value than the actual data length. But it fails otherwise - if actual length exceeds the value of content-length header (try a few bytes gap to be sure). Once testing in a browser I have seen truncated response - that confirms my theory.

art1c0 avatar Jul 20 '17 07:07 art1c0

@articobandurini I've already replied to you in the mail

langjt avatar Jul 26 '17 01:07 langjt

@articobandurini This repository handles only for JSON, and usually the interface returns JSON dynamically, without specifying the length, and the format is best specified to 'Content-Type:application/json', if it is in other formats, you can try harmon. Now callback can return a promise

langjt avatar Aug 22 '17 14:08 langjt

Actually this is absolutely normal to have Content-Length header in the response of JSON APIs - even dynamic or static - it does not matter. It has nothing to do with Content-Type header and other formats, harmon and promises. Have you fixed Content-Length header to be equal to the length of the response?

art1c0 avatar Aug 25 '17 08:08 art1c0

@articobandurini I've supported the Content-Length in v0.1.5.

langjt avatar Sep 26 '17 11:09 langjt