11from __future__ import annotations
22
3- from typing import IO , Any , Mapping , cast
3+ from typing import IO , Any , Union , Mapping , cast
44from contextlib import contextmanager , asynccontextmanager
55from collections .abc import Iterable , Iterator , AsyncIterator
66
77import httpx
88
99from .util import sanitize_curl_raw_params
1010from .routing import BrowserRoute
11- from ..._types import Body , Timeout , NotGiven , BinaryTypes , not_given
11+ from ..._types import Body , Timeout , NotGiven , not_given
1212from ..._models import FinalRequestOptions
1313
14+ BrowserRawContent = Union [bytes , bytearray , memoryview , str , IO [bytes ], Iterable [bytes ]]
15+
1416
1517def request_via_browser_route (
1618 parent : Any ,
1719 route : BrowserRoute ,
1820 method : str ,
1921 url : str ,
2022 * ,
21- content : BinaryTypes | None = None ,
23+ content : BrowserRawContent | None = None ,
2224 json : Body | None = None ,
2325 headers : Mapping [str , str ] | None = None ,
2426 params : Mapping [str , object ] | None = None ,
@@ -34,7 +36,7 @@ def request_via_browser_route(
3436 headers = headers or {},
3537 content = _normalize_binary_content (content ),
3638 json_data = json ,
37- timeout = timeout ,
39+ timeout = _normalize_timeout ( timeout ) ,
3840 )
3941 return cast (httpx .Response , parent .request (httpx .Response , options ))
4042
@@ -46,7 +48,7 @@ def stream_via_browser_route(
4648 method : str ,
4749 url : str ,
4850 * ,
49- content : BinaryTypes | None = None ,
51+ content : BrowserRawContent | None = None ,
5052 headers : Mapping [str , str ] | None = None ,
5153 params : Mapping [str , object ] | None = None ,
5254 timeout : float | Timeout | None | NotGiven = not_given ,
@@ -78,7 +80,7 @@ async def async_request_via_browser_route(
7880 method : str ,
7981 url : str ,
8082 * ,
81- content : BinaryTypes | None = None ,
83+ content : BrowserRawContent | None = None ,
8284 json : Body | None = None ,
8385 headers : Mapping [str , str ] | None = None ,
8486 params : Mapping [str , object ] | None = None ,
@@ -94,7 +96,7 @@ async def async_request_via_browser_route(
9496 headers = headers or {},
9597 content = _normalize_binary_content (content ),
9698 json_data = json ,
97- timeout = timeout ,
99+ timeout = _normalize_timeout ( timeout ) ,
98100 )
99101 return cast (httpx .Response , await parent .request (httpx .Response , options ))
100102
@@ -106,7 +108,7 @@ async def async_stream_via_browser_route(
106108 method : str ,
107109 url : str ,
108110 * ,
109- content : BinaryTypes | None = None ,
111+ content : BrowserRawContent | None = None ,
110112 headers : Mapping [str , str ] | None = None ,
111113 params : Mapping [str , object ] | None = None ,
112114 timeout : float | Timeout | None | NotGiven = not_given ,
@@ -136,7 +138,7 @@ def _normalize_timeout(timeout: float | Timeout | None | NotGiven) -> float | Ti
136138 return None if isinstance (timeout , NotGiven ) else timeout
137139
138140
139- def _normalize_binary_content (content : BinaryTypes | None ) -> bytes | IO [bytes ] | Iterable [bytes ] | None :
141+ def _normalize_binary_content (content : BrowserRawContent | None ) -> bytes | str | IO [bytes ] | Iterable [bytes ] | None :
140142 if content is None :
141143 return None
142144 if isinstance (content , bytearray ):
0 commit comments