http_proxy: remove ambiguity in connect headers configuration#787
http_proxy: remove ambiguity in connect headers configuration#787
Conversation
ce03b1c to
be99516
Compare
|
I think that we lost the ability to set the connect headers with this patch. Please add an e2e test for this flag. |
Yes, we did and I did it on purpose. It turns out we can't reuse regular RequestHeaders as they contain basic auth and some other modifiers that should not apply to dialvia's CONNECT request. In order to do that we would need to add some extra logic, which would definitely increase complexity. WDYT? @mmatczuk |
|
AFAIMC the only mussing bit is to copy the processed headers if any to dialvia in martian. |
2e584e0 to
9bdfaad
Compare
EDIT: MITM is a valid use case. After the tls is terminated, forwarder receives https requests that issue CONNECTs via http.Transport. |
|
I agree that --connect-headers are better name can we have --proxy-headers as deprecated alias for backwards compatibility. |
internal/martian/proxy_connect.go
Outdated
| d = dialvia.HTTPProxy(p.DialContext, proxyURL) | ||
| } | ||
| d.ConnectRequestModifier = p.ConnectRequestModifier | ||
| d.ConnectRequestModifier = func(req *http.Request) error { |
There was a problem hiding this comment.
Can we invert it, set only if p.RequestModifier != nil
dialvia/http.go
Outdated
| conn.Close() | ||
| return nil, nil, err | ||
| } | ||
| for k, v := range d.ProxyConnectHeader { |
There was a problem hiding this comment.
now you can have maps.Copy from stdlib
|
LGTM |
This patch is introducing a connect-header modifier that will be applied to all connect headers. This will streamline the logic. Previous flag --proxy-headers didn't have clear use case (connects to upstream proxy).
This allows to remove separate ConnectRequestModifier from proxy and always use RequestModifiers.
Connect requests will be modified by the very same RequestModifiers as all other requests.
Proxy should use RequestModifiers everywhere.
This allows adding custom headers from --connect-header flag to CONNECT requests in http.Transport.RoundTrip() (HTTP requests via HTTPS proxy).
9bdfaad to
8e62816
Compare
This patch:
--proxy-headerto--connect-headeras it was confusingFixes #782