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
Move validation of connection headers in HTTP/2 back to HpackDecoder
#12975
Merged
normanmaurer
merged 2 commits into
netty:4.1
from
idelpivnitskiy:h2-connection-headers-validation
Nov 9, 2022
Merged
Move validation of connection headers in HTTP/2 back to HpackDecoder
#12975
normanmaurer
merged 2 commits into
netty:4.1
from
idelpivnitskiy:h2-connection-headers-validation
Nov 9, 2022
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Motivation: netty#12755 added validation for presence of connection-related headers while `HpackDecoder` decodes the incoming frame. Then netty#12760 moved this validation from `HpackDecoder` to `DefaultHttp2Headers`. As the result, existing use-case that could use `DefaultHttp2Headers` for HTTP/2 and HTTP/1.X broke when users add any of the mentioned prohibited headers. The HTTP/1.X to HTTP/2 translation logic usually has sanitization process that removes connection-related headers. It's enough to run this validation only for incoming messages and we should preserve backward compatibility for 4.1. Modifications: - Move `isConnectionHeader` and `te` validations from `DefaultHttp2Headers` back to `HpackDecoder`; - Add tests to verify `HpackDecoder` fails incoming headers as expected; - Add tests to verify mentioned headers can be added to `DefaultHttp2Headers`; Result: Backward compatibility is preserved, while validation for connection-related headers is done in `HpackDecoder`.
chrisvest
reviewed
Nov 8, 2022
codec-http2/src/main/java/io/netty/handler/codec/http2/DefaultHttp2Headers.java
Show resolved
Hide resolved
chrisvest
approved these changes
Nov 8, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise looks good. Just keep a validateValue
override around that delegates to the superclass.
normanmaurer
approved these changes
Nov 9, 2022
normanmaurer
approved these changes
Nov 9, 2022
@idelpivnitskiy can you please also do a PR against main ? |
idelpivnitskiy
added a commit
to idelpivnitskiy/servicetalk
that referenced
this pull request
Nov 9, 2022
With the recent Netty fix netty/netty#12975 we can test HTTP/2 use-cases with both variants of the header factory.
idelpivnitskiy
added a commit
to idelpivnitskiy/servicetalk
that referenced
this pull request
Nov 10, 2022
With the recent Netty fix netty/netty#12975 we can test HTTP/2 use-cases with both variants of the header factory.
idelpivnitskiy
added a commit
to apple/servicetalk
that referenced
this pull request
Nov 10, 2022
With the recent Netty fix netty/netty#12975 we can test HTTP/2 use-cases with both variants of the header factory.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation:
#12755 added validation for presence of connection-related headers while
HpackDecoder
decodes the incoming frame. Then #12760 moved this validation fromHpackDecoder
toDefaultHttp2Headers
. As the result, existing use-case that could useDefaultHttp2Headers
for HTTP/2 and HTTP/1.X broke when users add any of the mentioned prohibited headers. The HTTP/1.X to HTTP/2 translation logic usually has sanitization process that removes connection-related headers. It's enough to run this validation only for incoming messages and we should preserve backward compatibility for 4.1.Modifications:
isConnectionHeader
andte
validations fromDefaultHttp2Headers
back toHpackDecoder
;HpackDecoder
fails incoming headers as expected;DefaultHttp2Headers
;Result:
Backward compatibility is preserved, while validation for connection-related headers is done in
HpackDecoder
.