saucelabs / forwarder

Forwarder is a production-ready, fast MITM proxy with PAC support. It's suitable for debugging, intercepting and manipulating HTTP traffic. It's used as a core component of Sauce Labs Sauce Connect Proxy.
https://forwarder-proxy.io
Mozilla Public License 2.0
218 stars 13 forks source link

martian: res.Close should not be passed downstream #684

Closed mmatczuk closed 6 months ago

mmatczuk commented 6 months ago

We should always clear res.Close status flag and never close downstream connection due to upstream connection closing.

Example

proxy-1    | GET http://httpbin:8080/status/200 HTTP/1.1
proxy-1    | Host: httpbin:8080
proxy-1    | Content-Length: 0
proxy-1    | Accept-Encoding: gzip
proxy-1    | User-Agent: Go-http-client/1.1
proxy-1    | Via: 1.1 forwarder-d1cf0cb277b1325ce65b
proxy-1    | X-Forwarded-For: 10.89.0.241
proxy-1    | X-Forwarded-Host: httpbin:8080
proxy-1    | X-Forwarded-Proto: http
proxy-1    | X-Forwarded-Url: http://httpbin:8080/status/200
proxy-1    | 
proxy-1    | HTTP/1.0 400 Bad Request
proxy-1    | Test-Resp-Add: test-resp-value
proxy-1    | 
proxy-1    | 
proxy-1    | 2024/02/08 13:59:28.163077 [proxy] [DEBUG] [5-d3741bcd] received close request: 10.89.0.241:42202
proxy-1    | 2024/02/08 13:59:28.163155 [proxy] [DEBUG] closing connection: 10.89.0.241:42202

Upstream and Downstream connections are separate and we should not propagate the close.