|
2 | 2 | import asyncio |
3 | 3 | import httpx |
4 | 4 | import jwt |
| 5 | +import re |
5 | 6 |
|
6 | 7 | from ._blob_client import BlobClient |
7 | 8 | from ._logging import LogHandlerSumo |
@@ -49,8 +50,8 @@ def __init__( |
49 | 50 | raise ValueError(f"Invalid environment: {env}") |
50 | 51 |
|
51 | 52 | self._retry_strategy = retry_strategy |
52 | | - self._client = httpx.Client(follow_redirects=True) |
53 | | - self._async_client = httpx.AsyncClient(follow_redirects=True) |
| 53 | + self._client = httpx.Client() |
| 54 | + self._async_client = httpx.AsyncClient() |
54 | 55 |
|
55 | 56 | self._timeout = timeout |
56 | 57 |
|
@@ -197,12 +198,17 @@ def get(self, path: str, params: dict = None) -> dict: |
197 | 198 |
|
198 | 199 | headers.update(self.auth.get_authorization()) |
199 | 200 |
|
| 201 | + follow_redirects = False |
| 202 | + if re.match(r"^/objects\('[0-9a-fA-F-]{8}-[0-9a-fA-F-]{4}-[0-9a-fA-F-]{4}-[0-9a-fA-F-]{4}-[0-9a-fA-F-]{12}'\)/blob$", |
| 203 | + path) is not None: |
| 204 | + follow_redirects = True |
| 205 | + |
200 | 206 | def _get(): |
201 | 207 | return self._client.get( |
202 | 208 | f"{self.base_url}{path}", |
203 | 209 | params=params, |
204 | 210 | headers=headers, |
205 | | - follow_redirects=True, |
| 211 | + follow_redirects=follow_redirects, |
206 | 212 | timeout=self._timeout, |
207 | 213 | ) |
208 | 214 |
|
@@ -424,11 +430,17 @@ async def get_async(self, path: str, params: dict = None): |
424 | 430 |
|
425 | 431 | headers.update(self.auth.get_authorization()) |
426 | 432 |
|
| 433 | + follow_redirects = False |
| 434 | + if re.match(r"^/objects\('[0-9a-fA-F-]{8}-[0-9a-fA-F-]{4}-[0-9a-fA-F-]{4}-[0-9a-fA-F-]{4}-[0-9a-fA-F-]{12}'\)/blob$", |
| 435 | + path) is not None: |
| 436 | + follow_redirects = True |
| 437 | + |
427 | 438 | async def _get(): |
428 | 439 | return await self._async_client.get( |
429 | 440 | f"{self.base_url}{path}", |
430 | 441 | params=params, |
431 | 442 | headers=headers, |
| 443 | + follow_redirects = follow_redirects, |
432 | 444 | timeout=self._timeout, |
433 | 445 | ) |
434 | 446 |
|
|
0 commit comments