Skip to content
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

reverse_proxy: fix bi-h2stream breaking gzip encode handle(#3606). #3620

Merged
merged 3 commits into from
Aug 4, 2020

Conversation

masknu
Copy link
Contributor

@masknu masknu commented Jul 30, 2020

Sorry for breaking the encode handle. This PR fixes #3606 . Add an integration test.

Copy link
Member

@mholt mholt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix and the test! Tests are super appreciated with changes like this in this part of the code. 💯

// in that case, if body size larger than enc.MinLength,
// upper level encode handle might have Content-Encoding header to write.
// (see https://github.com/caddyserver/caddy/issues/3606 for use case)
if req.ProtoMajor == 2 && res.ContentLength == -1 && req.Header.Get("Accept-Encoding") == "identity" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If Accept-Encoding is empty (not specified by the client), would that also be permissible for flushing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to rfc2616-sec14, it's permissible.
Should we consider dealing with the following form? It means accepting all but "identity".

Accept-Encoding: identity;q=0, *;q=1

modules/caddyhttp/reverseproxy/streaming.go Outdated Show resolved Hide resolved
@mholt mholt added this to the v2.2.0 milestone Aug 1, 2020
return -1
}

// TODO: more specific cases? e.g. res.ContentLength == -1? (this TODO is from the std lib)
return time.Duration(h.FlushInterval)
}

// biStream returns whether we should work in bi-directional stream mode.
func (h Handler) biStream(req *http.Request, res *http.Response) bool {
Copy link
Member

@francislavoie francislavoie Aug 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the function name should be isBidirectionalStream. Clarifies that the result is a boolean, and "bistream" doesn't have meaning on its own.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good.

@mholt
Copy link
Member

mholt commented Aug 3, 2020

@masknu This looks great! I took the liberty of applying the last few minor cleanups. If it looks good to you I'm ready to merge this.

@masknu
Copy link
Contributor Author

masknu commented Aug 4, 2020

That looks great to me.

@mholt mholt merged commit 904f149 into caddyserver:master Aug 4, 2020
@mholt
Copy link
Member

mholt commented Aug 4, 2020

Thank you so much for your contribution and for the discussion! Please contribute again. 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

after e9b1d7d commit, reverse proxy to the web page of GOGS will become garbled
3 participants