Skip to content
Open
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: 5 additions & 1 deletion client/v1/docker_http_.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ def Request(transport,
credentials,
accepted_codes = None,
body = None,
content_type = None):
content_type = None,
extra_headers = None):
"""Wrapper containing much of the boilerplate REST logic for Registry calls.

Args:
Expand All @@ -62,6 +63,7 @@ def Request(transport,
accepted_codes: the list of acceptable http status codes
body: the body to pass into the PUT request (or None for GET)
content_type: the mime-type of the request (or None for JSON)
extra_headers: optional dictionary of additional headers to include

Raises:
BadStatusException: the status codes wasn't among the acceptable set.
Expand All @@ -75,6 +77,8 @@ def Request(transport,
'X-Docker-Token': 'true',
'user-agent': docker_name.USER_AGENT,
}
if extra_headers:
headers.update(extra_headers)
resp, content = transport.request(
url, 'PUT' if body else 'GET', body=body, headers=headers)

Expand Down
7 changes: 6 additions & 1 deletion client/v2/docker_http_.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,8 @@ def Request(
accepted_codes = None,
method = None,
body = None,
content_type = None):
content_type = None,
extra_headers = None):
"""Wrapper containing much of the boilerplate REST logic for Registry calls.

Args:
Expand All @@ -317,6 +318,7 @@ def Request(
body: the body to pass into the PUT request (or None for GET)
content_type: the mime-type of the request (or None for JSON).
content_type is ignored when body is None.
extra_headers: optional dictionary of additional headers to include

Raises:
BadStateException: an unexpected internal state has been encountered.
Expand Down Expand Up @@ -348,6 +350,9 @@ def Request(
if method in ('POST', 'PUT') and not body:
headers['content-length'] = '0'

if extra_headers:
headers.update(extra_headers)

resp, content = self._transport.request(
url, method, body=body, headers=headers)

Expand Down
3 changes: 2 additions & 1 deletion client/v2/docker_session_.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ def _manifest_exists(self, image):
method='GET',
accepted_codes=[
six.moves.http_client.OK, six.moves.http_client.NOT_FOUND
])
],
extra_headers={'Databricks-Arf-Bypass-Redirect': 'true'})

return resp.status == six.moves.http_client.OK # pytype: disable=attribute-error

Expand Down
7 changes: 6 additions & 1 deletion client/v2_2/docker_http_.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,8 @@ def Request(self,
method = None,
body = None,
content_type = None,
accepted_mimes = None
accepted_mimes = None,
extra_headers = None
):
"""Wrapper containing much of the boilerplate REST logic for Registry calls.

Expand All @@ -348,6 +349,7 @@ def Request(self,
content_type: the mime-type of the request (or None for JSON).
content_type is ignored when body is None.
accepted_mimes: the list of acceptable mime-types
extra_headers: optional dictionary of additional headers to include

Raises:
BadStateException: an unexpected internal state has been encountered.
Expand Down Expand Up @@ -382,6 +384,9 @@ def Request(self,
if method in ('POST', 'PUT') and not body:
headers['content-length'] = '0'

if extra_headers:
headers.update(extra_headers)

resp, content = self._transport.request(
url, method, body=body, headers=headers)

Expand Down
3 changes: 2 additions & 1 deletion client/v2_2/docker_session_.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ def _manifest_exists(
accepted_codes=[
six.moves.http_client.OK, six.moves.http_client.NOT_FOUND
],
accepted_mimes=[image.media_type()])
accepted_mimes=[image.media_type()],
extra_headers={'Databricks-Arf-Bypass-Redirect': 'true'})

return resp.status == six.moves.http_client.OK # pytype: disable=attribute-error

Expand Down