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

Convert scheme to lower case when parsing URI #2938

Merged
merged 3 commits into from
Jun 2, 2024

Conversation

0x1306e6d
Copy link
Contributor

@0x1306e6d 0x1306e6d commented May 19, 2024

Motivation:

HttpRequestMetaData#scheme() javadocs state the result will be lowercase, but this is not always the case because Uri3986 parses the scheme as-is. As a result, DefaultMultiAddressUrlHttpClientBuilder may have more than 1 client instance for the same address if users use URI with different scheme letters case.
See #1423 for details.

Modifications:

  • Convert scheme to lower case when parsing Uri3986 reusing well-known schemes ("http" and "https")

Result:

Fixes #1423.

Copy link
Member

@idelpivnitskiy idelpivnitskiy left a comment

Choose a reason for hiding this comment

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

Hi Gihwan,
Thanks for the interest in our project and sorry for the delayed review.
Please see my comments below:

Verified

This commit was signed with the committer’s verified signature. The key has expired.
bryce-anderson Bryce Anderson
@0x1306e6d 0x1306e6d changed the title Introduce HttpScheme Convert scheme to lower case when parsing URI May 29, 2024

Verified

This commit was signed with the committer’s verified signature. The key has expired.
bryce-anderson Bryce Anderson
Copy link
Member

@idelpivnitskiy idelpivnitskiy left a comment

Choose a reason for hiding this comment

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

Looks much better, thanks for refactoring!

Copy link
Member

@idelpivnitskiy idelpivnitskiy left a comment

Choose a reason for hiding this comment

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

Many thanks! Appreciate your contribution

@idelpivnitskiy idelpivnitskiy merged commit bc6c3c4 into apple:main Jun 2, 2024
15 checks passed
idelpivnitskiy added a commit to idelpivnitskiy/servicetalk that referenced this pull request Jun 16, 2024
Motivation:

In apple#2938 we made it guaranteed that `HttpRequestMetaData#scheme()`
result is always in lowercase. We can use that to simplify scheme checks
inside `DefaultMultiAddressUrlHttpClientBuilder`.

Modifications:
- Replace all scheme checks from `equalsIgnoreCase` to `equals`;

Result:

No need to worry about cases for scheme check.
idelpivnitskiy added a commit to idelpivnitskiy/servicetalk that referenced this pull request Jun 17, 2024
Motivation:

In apple#2938 we made it guaranteed that `HttpRequestMetaData#scheme()`
result is always in lowercase. We can use that to simplify scheme checks
inside `DefaultMultiAddressUrlHttpClientBuilder`.

Modifications:
- Replace all scheme checks from `equalsIgnoreCase` to `equals`;

Result:

No need to worry about cases for scheme check.
idelpivnitskiy added a commit that referenced this pull request Jun 17, 2024
Motivation:

In #2938 we made it guaranteed that `HttpRequestMetaData#scheme()` result is always in lowercase. We can use that to simplify scheme checks inside `DefaultMultiAddressUrlHttpClientBuilder`.

Modifications:
- Replace all scheme checks from `equalsIgnoreCase` to `equals`;
- Extract exact same instance of `https` string from `Uri3986` to speed up `equals` check;

Result:

No need to worry about cases for scheme check.
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.

HttpRequestMetaData scheme case sensitivity
2 participants