Skip to content

Commit

Permalink
fix Host header value for IPv6 (#1328)
Browse files Browse the repository at this point in the history
Signed-off-by: Bala.FA <[email protected]>
  • Loading branch information
balamurugana authored May 13, 2022
1 parent 462a950 commit 0c736df
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions api/src/main/java/io/minio/http/HttpUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,18 @@ public static HttpUrl getBaseUrl(String endpoint) {
}

public static String getHostHeader(HttpUrl url) {
String host = url.host();
if (InetAddressValidator.getInstance().isValidInet6Address(host)) {
host = "[" + host + "]";
}

// ignore port when port and service matches i.e HTTP -> 80, HTTPS -> 443
if ((url.scheme().equals("http") && url.port() == 80)
|| (url.scheme().equals("https") && url.port() == 443)) {
return url.host();
return host;
}

return url.host() + ":" + url.port();
return host + ":" + url.port();
}

/**
Expand Down

0 comments on commit 0c736df

Please sign in to comment.