Skip to content

Commit

Permalink
MakeBucket should always use pathStyle (#1129)
Browse files Browse the repository at this point in the history
  • Loading branch information
harshavardhana authored Jun 27, 2019
1 parent f5f036d commit 6d6e637
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -719,10 +719,14 @@ func (c Client) newRequest(method string, metadata requestMetadata) (req *http.R
}

// Look if target url supports virtual host.
isVirtualHost := c.isVirtualHostStyleRequest(*c.endpointURL, metadata.bucketName)
// We explicitly disallow MakeBucket calls to not use virtual DNS style,
// since the resolution may fail.
isMakeBucket := (metadata.objectName == "" && method == "PUT" && len(metadata.queryValues) == 0)
isVirtualHost := c.isVirtualHostStyleRequest(*c.endpointURL, metadata.bucketName) && !isMakeBucket

// Construct a new target URL.
targetURL, err := c.makeTargetURL(metadata.bucketName, metadata.objectName, location, isVirtualHost, metadata.queryValues)
targetURL, err := c.makeTargetURL(metadata.bucketName, metadata.objectName, location,
isVirtualHost, metadata.queryValues)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 6d6e637

Please sign in to comment.