Skip to content

HTTPCLIENT-2372 - Normalize HttpHost port comparison to treat implicit default ports as equal#643

Merged
arturobernalg merged 1 commit intoapache:masterfrom
arturobernalg:HTTPCLIENT-2372
Jun 5, 2025
Merged

HTTPCLIENT-2372 - Normalize HttpHost port comparison to treat implicit default ports as equal#643
arturobernalg merged 1 commit intoapache:masterfrom
arturobernalg:HTTPCLIENT-2372

Conversation

@arturobernalg
Copy link
Copy Markdown
Member

This change ensures that hosts with implicit default ports (e.g., http://example.com) are treated the same as those explicitly specifying port 80 or 443. It introduces a helper method to derive the “effective” port and updates the authority check to use this normalized value. As a result, sensitive headers are no longer stripped when redirecting between example.com and example.com:80 (or :443 for HTTPS).

@arturobernalg arturobernalg requested a review from ok2c June 4, 2025 19:05
return port1 == port2;
}

private int getEffectivePort(final HttpHost endpoint) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@arturobernalg Please use SchemePortResolver to resolve the port of a protocol scheme. Please also use the one created by the builder. See HttpClientBuilder

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@ok2c please do another pass

@arturobernalg arturobernalg force-pushed the HTTPCLIENT-2372 branch 2 times, most recently from 9867b91 to c89277e Compare June 5, 2025 10:28
@arturobernalg arturobernalg requested a review from ok2c June 5, 2025 10:54
@arturobernalg arturobernalg merged commit 5cef6ed into apache:master Jun 5, 2025
10 checks passed
ok2c pushed a commit that referenced this pull request Jun 6, 2025
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