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

[Test-Proxy] Enforce Http 1.1 only #3216

Merged
merged 3 commits into from
Apr 26, 2022

Conversation

scbedd
Copy link
Member

@scbedd scbedd commented Apr 26, 2022

On both go 1.17 and go 1.18 we generate some wonky headers.

  • :authority
  • :method

It is an artifact of the client, as per my understanding these aren't actually used by the service. Correct me if I'm wrong @seankane-msft

In the past, we were actually silently omitting them, but we got explicit with this PR.

This PR brings it back to excluding them by default.

Kestrel by default listens for both http/1.1 and http/2 communication. The issue is that because we were allowing both, the go clients don't know which to select. This is why we are seemingly randomly getting :authority and :method headers. The go client thinks it's talking http/2!

By disallowing test-proxy from listening on http/2, we don't get those wonky headers sent anymore. The go client selects the correct protocol based on what our server tells it.

@scbedd scbedd requested a review from mikeharder as a code owner April 26, 2022 00:11
@scbedd scbedd changed the title Discard broken headers instead of explicitly throwing [Test-Proxy[ Discard broken headers instead of explicitly throwing Apr 26, 2022
@scbedd scbedd changed the title [Test-Proxy[ Discard broken headers instead of explicitly throwing [Test-Proxy] Discard broken headers instead of explicitly throwing Apr 26, 2022
@mikeharder
Copy link
Member

In HTTP v1, Header names are not allowed to contain the : character per the spec:

       message-header = field-name ":" [ field-value ]
       field-name     = token

https://datatracker.ietf.org/doc/html/rfc2616#section-4.2

       token          = 1*<any CHAR except CTLs or separators>
       separators     = "(" | ")" | "<" | ">" | "@"
                      | "," | ";" | ":" | "\" | <">
                      | "/" | "[" | "]" | "?" | "="
                      | "{" | "}" | SP | HT

https://datatracker.ietf.org/doc/html/rfc2616#section-2.2

Header names like ":authority" and ":method" appear to be valid in HTTP/2, so maybe Go is accidentally adding HTTP/2 headers to an HTTP v1 request?

I think the Go SDK should fix this issue and stop sending the invalid headers. It's possible services could reject the requests since they are invalid. I consider it a good thing that test-proxy detected this issue for us.

If we really need to allow test-proxy to accept these headers, I would put it behind an optional flag. It should only be enabled as a temporary measure until the SDK can be fixed to remove invalid headers.

@scbedd scbedd changed the title [Test-Proxy] Discard broken headers instead of explicitly throwing [Test-Proxy] Enforce Http 1.1 only Apr 26, 2022
@scbedd scbedd merged commit 28b158c into Azure:main Apr 26, 2022
benbp pushed a commit to benbp/azure-sdk-tools that referenced this pull request May 6, 2022
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.

3 participants