Handle HEAD/GET requests for virtual DNS requests (#7839)

r.URL.Path is empty when HEAD bucket with virtual
DNS requests come in since bucket is now part of
r.Host, we should use our domain names and fetch
the right bucket/object names.

This fixes an really old issue in our federation
setups.
This commit is contained in:
Harshavardhana
2019-06-26 18:21:54 -07:00
committed by kannappanr
parent be72609d1f
commit c1d2b3d5c3
2 changed files with 16 additions and 3 deletions

View File

@@ -71,8 +71,20 @@ func cloneHeader(h http.Header) http.Header {
return h2
}
func request2BucketObjectName(r *http.Request) (bucketName, objectName string) {
path, err := getResource(r.URL.Path, r.Host, globalDomainNames)
if err != nil {
logger.CriticalIf(context.Background(), err)
}
return urlPath2BucketObjectName(path)
}
// Convert url path into bucket and object name.
func urlPath2BucketObjectName(path string) (bucketName, objectName string) {
if path == "" || path == slashSeparator {
return "", ""
}
// Trim any preceding slash separator.
urlPath := strings.TrimPrefix(path, slashSeparator)