Skip to content

Commit

Permalink
Fast path for non-IPv6
Browse files Browse the repository at this point in the history
  • Loading branch information
schlosna committed Nov 29, 2024
1 parent 1a36d5f commit 76686b4
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,11 @@ static ClassicHttpRequest createRequest(BaseUrl baseUrl, Endpoint endpoint, Requ
@VisibleForTesting
static URIAuthority parseAuthority(URL url) {
try {
String host = url.getHost();
if (host != null && !host.startsWith("[")) {
// fast path for non-IPv6 hosts
return new URIAuthority(url.getUserInfo(), host, url.getPort());
}
return URIAuthority.create(url.getAuthority());
} catch (URISyntaxException e) {
throw new SafeIllegalArgumentException("Invalid URI authority", e, UnsafeArg.of("url", url));
Expand Down

0 comments on commit 76686b4

Please sign in to comment.