-
Notifications
You must be signed in to change notification settings - Fork 248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HTTP (not HTTPS) response has no Content-Length #288
Comments
Thanks for the repro! This looks bad, we'll have someone take a look soon. |
I was unable to reproduce the issue, but I had to take the following steps because Martian wasn't set up.
And curl returns the expected response. |
It does not terminate though. curl does not know when the response body is complete. Try this: |
@itaisod What's the version of Go you're using? |
1.12.5 |
After investigating, seems that example.com just doesn't respond with a Content-Length header, so Martian just faithfully proxies whatever it got. Try the same thing with another website without https, such as http://www.baidu.com/ and they return a Content-Length. Thanks for reporting this, and let us know if you find any more bugs in the future. |
You're right. During testing I somehow mistook the proxied output for the no proxy output and that was missing the Content-Length header. I'm starting to suspect there's some order dependency in the header processing, and perhaps anything after the X-Cache header is getting dropped, which in the case of example.com was the Content-Length header. Will take a closer look soon. |
This is the behavior of Go's If we want to retain the I want to create a PR, but should I add the |
I don't think that setting `DisableCompression` to `true` should be the
default behavior. If you need this behavior, I would suggest writing your
own `main.go` implementation and swapping in your own `http.Transport` with
`SetRoundTripper` like here:
https://github.com/google/martian/blob/master/cmd/proxy/main.go#L270
…On Tue, Jun 16, 2020 at 11:49 PM Thanh Nguyen ***@***.***> wrote:
This is the behavior of Go's Transport, according to this issue
<golang/go#18132>.
If we want to retain the Content-Length header, we must set
DisableCompression of http.Transport to true.
I want to create a PR, but should I add the Accept-Encoding: gzip header
for every request like Go do, or I just let users decide if they want gzip
or not?
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#288 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAMR6NAUWS3LXPIBB3NAGDRXA4NZANCNFSM4HK3P3XA>
.
|
So we just leave this bug there? |
If martian can't provide Content-Length header in the response, at the very least it should close the connection when it's done and not just leave it hanging forever... Otherwise, it can either pipe the original data unmodified along with the original Content-Length and Content-Encoding, or read the whole data into a buffer first, and then set Content-Length in the response to whatever size it wants, compressed/uncompressed. I'm 100% sure it's fixable. Not that I mind though, I'm not using martian. |
Yeah I think @itaisod is correct. The fix is to "pipe the original data unmodified along with the original Content-Length and Content-Encoding". My concern with setting |
Setting
With setting I thinks that martian, as a proxy, should respect the client's request and let them decide if they want the |
Steps to reproduce (tested on both mac and ubuntu):
go get github.com/google/martian/ && go install github.com/google/martian/cmd/proxy
~/go/bin/proxy
curl -v "http://www.example.com/" --proxy localhost:8080
Result: curl hangs forever.
The text was updated successfully, but these errors were encountered: