ncr / rack-proxy

A request/response rewriting HTTP proxy. A Rack app.
MIT License
269 stars 94 forks source link

Set headers propery for non-streaming requests #29

Closed sdhull closed 10 years ago

sdhull commented 10 years ago

I'm not exactly sure why streaming is default -- it seems to cause strange errors in different environments for me, and is fully incompatible with WebMock and VCR (as noted in the readme). However, non-streaming requests work fine with WebMock and VCR.

As a result, I've recently begun setting streaming = false, but then I found that non-streaming responses don't respond to the headers method, meaning all headers from the response are essentially dropped (and not proxied).

If you check out the net/http docs, it's clear that to_hash is the intended method for attaining headers.

I've included a test that fails if you change the proxy.rb request back to what it was before.

ncr commented 10 years ago

Hello Steve. I created rack-proxy for the purpose of proxying large responses, thus streaming was the default. Now it seems that people use it primarily to proxy APIs and stuff like that. I think the default should be changed or even the whole streaming should be dropped as it is a nasty ugly monkeypatch that probably works on 1.8 only.

I would happily megre such PR.

ncr commented 10 years ago

Thanks!

sdhull commented 10 years ago

Thanks for being so quick to review & merge! I'll definitely consider revising the streaming situation :smile: