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

http: changing mutate[request|response] to special case all upgrade headers #3735

Merged
merged 5 commits into from
Jul 2, 2018

Conversation

alyssawilk
Copy link
Contributor

@alyssawilk alyssawilk commented Jun 26, 2018

Extending the mutateRequestHeaders to special case all upgrades, not just WebSocket.

Adding special handling for mutateResponse headers to do similar special casing of upgrade responses.

Changing the utility we use to determine if there is an upgrade header. The now removed caseInsensitiveContains had a bug where it would parse "upgrade: Websocket Keep-Alive" as a websocket upgrade. The existing Envoy::StringUtil::caseFindToken will parse that as one token but still handles "upgrade: Webocket, keep-alive" correctly.

Risk Level: Medium (changing existing websocket handling)
Testing: new unit tests, regression test for fixed bug.
Docs Changes: n/a
Release Notes: not added. We could note the bugfix if we think it noteworthy.
Part of #3301

…eaders

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
@mattklein123 mattklein123 self-assigned this Jun 26, 2018
Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
@alyssawilk
Copy link
Contributor Author

So I noticed that I was stripping the transferEncoding header on the response path and not the request path, which was clearly inconsistent and wrong. After some poking around and a question posited on #3301 I'm leaning towards just properly handling the transfer encoding header as I proposed there.

For now, I'm leaving both mutate functions as-is with respect to the T-E header but simply adding tests of the existing behavior and TODOs to fix it.

Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Cool, nice cleanup. One question.

const bool no_body =
(!response_headers.TransferEncoding() && !response_headers.ContentLength());
if (no_body) {
response_headers.insertContentLength().value(uint64_t(0));
Copy link
Member

Choose a reason for hiding this comment

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

Why is this needed in the upgrade path but not other cases? I think I'm just ignorant of the standard here...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For response headers I believe you can frame by connection close. That won't work for WebSocket upgrades because you can't close between HTTP and WebSocket payload.

@alyssawilk alyssawilk merged commit 52de772 into envoyproxy:master Jul 2, 2018
@alyssawilk alyssawilk deleted the websocket_utility branch October 10, 2018 20:15
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.

2 participants