Skip to content

Commit 68418bf

Browse files
authored
fix: Send correct host header when an endpoint is IPv4 (#1835)
Currently, when the specified endpoint is an IP v4 address and the port is 80/443, minio-go sends a Host header with a bracket, which is wrong. An ipV4 can be converted to ip6 in Golang library, therefore using ip.To4() should return nil if the passed IP is v6.
1 parent ba04019 commit 68418bf

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

api.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,7 @@ func (c *Client) makeTargetURL(bucketName, objectName, bucketLocation string, is
919919
if h, p, err := net.SplitHostPort(host); err == nil {
920920
if scheme == "http" && p == "80" || scheme == "https" && p == "443" {
921921
host = h
922-
if ip := net.ParseIP(h); ip != nil && ip.To16() != nil {
922+
if ip := net.ParseIP(h); ip != nil && ip.To4() == nil {
923923
host = "[" + h + "]"
924924
}
925925
}

0 commit comments

Comments
 (0)