Skip to content

Commit

Permalink
fix Host header in request correctly (#1004)
Browse files Browse the repository at this point in the history
  • Loading branch information
balamurugana authored Oct 19, 2020
1 parent 0a048a7 commit 4de316b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions minio/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,11 @@ def _handle_redirect_response(

return code, message

def _build_headers(self, headers, body, creds):
def _build_headers(self, host, headers, body, creds):
"""Build headers with given parameters."""
headers = headers or {}
md5sum_added = headers.get("Content-MD5")
headers["Host"] = self._base_url.host
headers["Host"] = host
headers["User-Agent"] = self._user_agent
sha256 = None
md5sum = None
Expand Down Expand Up @@ -226,14 +226,14 @@ def _url_open( # pylint: disable=too-many-branches
creds = self._provider.retrieve() if self._provider else None
trace_body = isinstance(body, str)
body = body.encode() if trace_body else body
headers, date = self._build_headers(headers, body, creds)
url = self._base_url.build(
method,
region,
bucket_name=bucket_name,
object_name=object_name,
query_params=query_params,
)
headers, date = self._build_headers(url.netloc, headers, body, creds)
if creds:
headers = sign_v4_s3(
method,
Expand Down
2 changes: 1 addition & 1 deletion minio/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def build(
(method == "PUT" and not object_name and not query_params) or

# GetBucketLocation API requires path style in Amazon AWS S3.
(query_params and query_params.get("location")) or
(query_params and "location" in query_params) or

# Use path style for bucket name containing '.' which causes
# SSL certificate validation error.
Expand Down

0 comments on commit 4de316b

Please sign in to comment.