Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix Host header in request correctly #1004

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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