Skip to content

Commit be97db4

Browse files
feat(client): send X-Stainless-Read-Timeout header
1 parent edd4b15 commit be97db4

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/openlayer/_base_client.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,10 +405,17 @@ def _build_headers(self, options: FinalRequestOptions, *, retries_taken: int = 0
405405
if idempotency_header and options.method.lower() != "get" and idempotency_header not in headers:
406406
headers[idempotency_header] = options.idempotency_key or self._idempotency_key()
407407

408-
# Don't set the retry count header if it was already set or removed by the caller. We check
408+
# Don't set these headers if they were already set or removed by the caller. We check
409409
# `custom_headers`, which can contain `Omit()`, instead of `headers` to account for the removal case.
410-
if "x-stainless-retry-count" not in (header.lower() for header in custom_headers):
410+
lower_custom_headers = [header.lower() for header in custom_headers]
411+
if "x-stainless-retry-count" not in lower_custom_headers:
411412
headers["x-stainless-retry-count"] = str(retries_taken)
413+
if "x-stainless-read-timeout" not in lower_custom_headers:
414+
timeout = self.timeout if isinstance(options.timeout, NotGiven) else options.timeout
415+
if isinstance(timeout, Timeout):
416+
timeout = timeout.read
417+
if timeout is not None:
418+
headers["x-stainless-read-timeout"] = str(timeout)
412419

413420
return headers
414421

0 commit comments

Comments
 (0)