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

Check HTTP2 headers for correctness #3603

Merged

Conversation

johanandren
Copy link
Member

References #812

Tried to read RFC7540 for MUST rules around headers and crosscheck with the HTTP/1.1 message parsing, but not super confident I did not miss something or get something wrong.

@akka-ci akka-ci added validating PR that is currently being validated by Jenkins tested PR that was successfully built and tested by Jenkins and removed validating PR that is currently being validated by Jenkins labels Nov 4, 2020
@akka-ci
Copy link

akka-ci commented Nov 4, 2020

Test PASSed.

Copy link
Member

@jrudolph jrudolph left a comment

Choose a reason for hiding this comment

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

One potential problem with application/octet-stream content types but otherwise LGTM

@akka-ci akka-ci added validating PR that is currently being validated by Jenkins and removed tested PR that was successfully built and tested by Jenkins labels Nov 4, 2020
@akka-ci akka-ci added tested PR that was successfully built and tested by Jenkins and removed validating PR that is currently being validated by Jenkins labels Nov 4, 2020
@akka-ci
Copy link

akka-ci commented Nov 4, 2020

Test PASSed.

@akka-ci akka-ci added validating PR that is currently being validated by Jenkins and removed tested PR that was successfully built and tested by Jenkins labels Nov 4, 2020
Copy link
Member

@raboof raboof 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, I think 'TE' just means 'Transfer-Encoding'

Comment on lines +177 to +182
case "transfer-encoding" =>
// https://tools.ietf.org/html/rfc7540#section-8.1.2.2
malformedRequest("Header 'Transfer-Encoding' must not be used with HTTP/2")
case "te" =>
// https://tools.ietf.org/html/rfc7540#section-8.1.2.2
if (httpHeader.value.compareToIgnoreCase("trailers") != 0) malformedRequest(s"Header 'TE' must not contain value other than 'trailers', value was '${httpHeader.value}")
Copy link
Member

Choose a reason for hiding this comment

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

I think TE is used as short for Transfer-Encoding in the spec here, so:

Suggested change
case "transfer-encoding" =>
// https://tools.ietf.org/html/rfc7540#section-8.1.2.2
malformedRequest("Header 'Transfer-Encoding' must not be used with HTTP/2")
case "te" =>
// https://tools.ietf.org/html/rfc7540#section-8.1.2.2
if (httpHeader.value.compareToIgnoreCase("trailers") != 0) malformedRequest(s"Header 'TE' must not contain value other than 'trailers', value was '${httpHeader.value}")
case "transfer-encoding" =>
// https://tools.ietf.org/html/rfc7540#section-8.1.2.2
if (httpHeader.value.compareToIgnoreCase("trailers") != 0) malformedRequest(s"Header 'TE' must not contain value other than 'trailers', value was '${httpHeader.value}")

Copy link
Member Author

Choose a reason for hiding this comment

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

I may be wrong but I think it actually is a distinct header: https://tools.ietf.org/html/rfc7230#section-4.3

Copy link
Member

Choose a reason for hiding this comment

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

huh, looks like you're completely right, sorry about he noise :(

Copy link
Member Author

Choose a reason for hiding this comment

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

No worries, it sure is confusing with two headers meaning the same but not quite the same...

@@ -110,6 +110,29 @@ class RequestParsingSpec extends AkkaSpec() with Inside with Inspectors {
}
}

"not accept TE with other values than 'trailers'" in {
Copy link
Member

Choose a reason for hiding this comment

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

(also needs to be reflected here)

@akka-ci akka-ci added tested PR that was successfully built and tested by Jenkins and removed validating PR that is currently being validated by Jenkins labels Nov 4, 2020
@akka-ci
Copy link

akka-ci commented Nov 4, 2020

Test PASSed.

Copy link
Member

@jrudolph jrudolph left a comment

Choose a reason for hiding this comment

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

LGTM

@jrudolph
Copy link
Member

jrudolph commented Nov 5, 2020

@raboof good to go from your side?

Copy link
Member

@raboof raboof left a comment

Choose a reason for hiding this comment

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

Yes, looks good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tested PR that was successfully built and tested by Jenkins
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants