Skip to content

http: Strip illegal headers from CONNECT responses#1698

Merged
olix0r merged 1 commit intover/justfrom
ver/h1-strip-connect
May 23, 2022
Merged

http: Strip illegal headers from CONNECT responses#1698
olix0r merged 1 commit intover/justfrom
ver/h1-strip-connect

Conversation

@olix0r
Copy link
Member

@olix0r olix0r commented May 23, 2022

When the proxy transports CONNECT requests, the client silently
ignores content-length and transport-encoding response headers, as
it should. When the proxy passees these headers to the hyper server, it
errors (as is dictated by the RFC).

This change updates the HTTP client to remove these headers from
responses so that the proxy no longer propagates these illegal headers.

Fixes linkerd/linkerd2#8539

Signed-off-by: Oliver Gould [email protected]

@olix0r olix0r requested a review from a team as a code owner May 23, 2022 17:43
When the proxy transports `CONNECT` requests, the client silently
ignores `content-length` and `transport-encoding` response headers, as
it should. When the proxy passees these headers to the hyper server, it
errors (as is dictated by the RFC).

This change updates the HTTP client to remove these headers from
responses so that the proxy no longer propagates these illegal headers.

Fixes linkerd/linkerd2#8539

Signed-off-by: Oliver Gould <[email protected]>
@olix0r olix0r force-pushed the ver/h1-strip-connect branch from 011e574 to b836f89 Compare May 23, 2022 17:44
@olix0r olix0r force-pushed the ver/just branch 2 times, most recently from f2bf43a to f7dadad Compare May 23, 2022 17:56
Copy link
Contributor

@hawkw hawkw left a comment

Choose a reason for hiding this comment

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

looks good to me! tiny nit on the test

}

/// Tests that the proxy drops headers that can't be used in CONNECT responses.
///
Copy link
Contributor

Choose a reason for hiding this comment

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

nit/tioli: maybe also worth having a

Suggested change
///
///
/// Reproduces https://github.com/linkerd/linkerd2/issues/8539
///

here?

Comment on lines +765 to +768
.map(|res: std::io::Result<()>| match res {
Ok(()) => {}
Err(e) => panic!("tcp server error: {}", e),
})
Copy link
Contributor

Choose a reason for hiding this comment

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

tiny nit, TIOLI: i believe this could avoid matching the Ok(()) case if it used the unwrap_or_elsecombinator rather than map:

Suggested change
.map(|res: std::io::Result<()>| match res {
Ok(()) => {}
Err(e) => panic!("tcp server error: {}", e),
})
.unwrap_or_else(|e| panic!("tcp server error: {}", e))

Copy link
Member Author

Choose a reason for hiding this comment

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

this is copy/paste from above. would love help cleaning up the tests in a separate PR

@olix0r olix0r merged commit 61aa55f into ver/just May 23, 2022
@olix0r olix0r deleted the ver/h1-strip-connect branch May 23, 2022 21:10
@olix0r
Copy link
Member Author

olix0r commented May 23, 2022

ugh this was based on the wrong branch :/. will resubmit

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