Skip to content

Conversation

@arturobernalg
Copy link
Member

refines the ProtocolSwitchStrategy class to improve the parsing of protocol tokens in the Upgrade header, making the implementation more elegant and future-proof.

@arturobernalg arturobernalg requested a review from ok2c March 25, 2025 13:29
@ok2c
Copy link
Member

ok2c commented Mar 26, 2025

@arturobernalg Is there a reason for not using ProtocolVersionParser from core?

@arturobernalg arturobernalg force-pushed the protocolSwitchStrategy branch from efefe21 to 80d6155 Compare March 26, 2025 18:00
@arturobernalg
Copy link
Member Author

@arturobernalg Is there a reason for not using ProtocolVersionParser from core?

@ok2c please do another pass

@arturobernalg arturobernalg force-pushed the protocolSwitchStrategy branch from a7a8993 to d26c7eb Compare March 27, 2025 06:26
@arturobernalg arturobernalg requested a review from ok2c March 27, 2025 06:29
@arturobernalg arturobernalg force-pushed the protocolSwitchStrategy branch from 3485c89 to 17dafc8 Compare March 27, 2025 09:54
@arturobernalg arturobernalg force-pushed the protocolSwitchStrategy branch 2 times, most recently from 8e729c9 to e5660d0 Compare March 31, 2025 11:29
@arturobernalg arturobernalg requested a review from ok2c March 31, 2025 13:01
@arturobernalg
Copy link
Member Author

Please @ok2c do another pass

@arturobernalg arturobernalg force-pushed the protocolSwitchStrategy branch from 37fdd6f to 429759f Compare March 31, 2025 17:36
@arturobernalg arturobernalg requested a review from ok2c March 31, 2025 17:36
Copy link
Member

@ok2c ok2c left a comment

Choose a reason for hiding this comment

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

@arturobernalg So much better in my opinion. Now to make it better still, please consider copying #parseHeaders method from apache/httpcomponents-core@99630f4 and using it to parse the sequence of protocol tokens without making intermediate String objects

Unify HTTP and TLS token parsing in the Upgrade header by replacing custom version parsing with ProtocolVersionParser.
This change removes redundant code and ensures that only supported protocols (HTTP/ and TLS tokens) are accepted,
while all other upgrade protocols are rejected as unsupported.
@arturobernalg arturobernalg force-pushed the protocolSwitchStrategy branch from c88410f to 42c6006 Compare April 6, 2025 19:20
@arturobernalg
Copy link
Member Author

@arturobernalg So much better in my opinion. Now to make it better still, please consider copying #parseHeaders method from apache/httpcomponents-core@99630f4 and using it to parse the sequence of protocol tokens without making intermediate String objects

All right @ok2c I think now i have full in all the remarks

@arturobernalg arturobernalg requested a review from ok2c April 6, 2025 19:21
return null;
}

if (end - start == 3) {
Copy link
Member

Choose a reason for hiding this comment

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

@arturobernalg I think there is a way to make it nicer, but it is good enough for now

@arturobernalg arturobernalg merged commit 188f708 into apache:master Apr 10, 2025
10 checks passed
ok2c pushed a commit that referenced this pull request Apr 10, 2025
…627)

Unify HTTP and TLS token parsing in the Upgrade header by replacing custom version parsing with ProtocolVersionParser.
This change removes redundant code and ensures that only supported protocols (HTTP/ and TLS tokens) are accepted,
while all other upgrade protocols are rejected as unsupported.
@ok2c
Copy link
Member

ok2c commented Apr 10, 2025

@arturobernalg I took a closer look at your code and had to refactor a few things. Please take a look at 0ba6102. I hope you agree implementation is shorter and cleaner. I also had to fix the Exception message asserts in the test case.

@arturobernalg
Copy link
Member Author

@arturobernalg I took a closer look at your code and had to refactor a few things. Please take a look at 0ba6102. I hope you agree implementation is shorter and cleaner. I also had to fix the Exception message asserts in the test case.

HI @ok2c look good. Thank for the review.

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