Skip to content
Open
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
15 changes: 9 additions & 6 deletions oras/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ def put_upload(
# Location should be in the header
session_url = self._get_location(r, container)
if not session_url:
raise ValueError(f"Issue retrieving session url: {r.json()}")
raise ValueError(f"Issue retrieving session url (HTTP {r.status_code}): Check auth credentials and registry permissions")

# PUT to upload blob url
headers = {
Expand Down Expand Up @@ -587,7 +587,8 @@ def _get_location(
:param container: parsed container URI
:type container: oras.container.Container or str
"""
session_url = r.headers.get("location", "")
# Try both lowercase and capitalized Location header
session_url = r.headers.get("location") or r.headers.get("Location") or ""
if not session_url:
return session_url

Expand Down Expand Up @@ -629,7 +630,7 @@ def chunked_upload(
# Location should be in the header
session_url = self._get_location(r, container)
if not session_url:
raise ValueError(f"Issue retrieving session url: {r.json()}")
raise ValueError(f"Issue retrieving session url (HTTP {r.status_code}): Check auth credentials and registry permissions")

# Read the blob in chunks, for each do a patch
start = 0
Expand All @@ -654,7 +655,7 @@ def chunked_upload(
)
session_url = self._get_location(r, container)
if not session_url:
raise ValueError(f"Issue retrieving session url: {r.json()}")
raise ValueError(f"Issue retrieving session url (HTTP {r.status_code}): Check auth credentials and registry permissions")

# Finally, issue a PUT request to close blob
session_url = oras.utils.append_url_params(
Expand Down Expand Up @@ -992,8 +993,10 @@ def do_request(
headers = {}

# Make the request and return to calling function, but attempt to use auth token if previously obtained
if isinstance(self.auth, oras.auth.TokenAuth) and self.auth.token is not None:
headers.update(self.auth.get_auth_header())
if self.auth and hasattr(self.auth, 'get_auth_header'):
auth_headers = self.auth.get_auth_header()
if auth_headers: # Only update if we got actual headers
headers.update(auth_headers)
response = self.session.request(
method,
url,
Expand Down