Skip to content
Myr

Add Client(allow_redirect=<...>) (#1790)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Tom Christie · committed by GitHub · parent ee24e67 · Browse files · 1 file+32 added−20 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+32 added−20 removed

  • other:+32 added−20 removed

1 file+32 added−20 removed

modified:httpx/_client.py+32 added-20 removed
163 unmodified lines
164 params: QueryParamTypes = None,165 headers: HeaderTypes = None,166 cookies: CookieTypes = None,167 timeout: TimeoutTypes = DEFAULT_TIMEOUT_CONFIG,168 allow_redirects: bool = True,169 max_redirects: int = DEFAULT_MAX_REDIRECTS,170 event_hooks: typing.Mapping[str, typing.List[typing.Callable]] = None,171 base_url: URLTypes = "",172 trust_env: bool = True,
6 unmodified lines
179 self._params = QueryParams(params)180 self.headers = Headers(headers)181 self._cookies = Cookies(cookies)182 self._timeout = Timeout(timeout)183 self.allow_redirects = allow_redirects184 self.max_redirects = max_redirects185 self._event_hooks = {186 "request": list(event_hooks.get("request", [])),187 "response": list(event_hooks.get("response", [])),
557 unmodified lines
745 params: QueryParamTypes = None,746 headers: HeaderTypes = None,747 cookies: CookieTypes = None,748 auth: typing.Union[AuthTypes, UseClientDefault] = USE_CLIENT_DEFAULT,747 allow_redirects: bool = True,749 allow_redirects: typing.Union[bool, UseClientDefault] = USE_CLIENT_DEFAULT,750 timeout: typing.Union[TimeoutTypes, UseClientDefault] = USE_CLIENT_DEFAULT,751 ) -> Response:752 """753 Build and send a request.
47 unmodified lines
801 params: QueryParamTypes = None,802 headers: HeaderTypes = None,803 cookies: CookieTypes = None,804 auth: typing.Union[AuthTypes, UseClientDefault] = USE_CLIENT_DEFAULT,803 allow_redirects: bool = True,805 allow_redirects: typing.Union[bool, UseClientDefault] = USE_CLIENT_DEFAULT,806 timeout: typing.Union[TimeoutTypes, UseClientDefault] = USE_CLIENT_DEFAULT,807 ) -> typing.Iterator[Response]:808 """809 Alternative to `httpx.request()` that streams the response body
33 unmodified lines
843 request: Request,844 *,845 stream: bool = False,846 auth: typing.Union[AuthTypes, UseClientDefault] = USE_CLIENT_DEFAULT,845 allow_redirects: bool = True,847 allow_redirects: typing.Union[bool, UseClientDefault] = USE_CLIENT_DEFAULT,848 timeout: typing.Union[TimeoutTypes, UseClientDefault] = USE_CLIENT_DEFAULT,849 ) -> Response:850 """851 Send a request.
14 unmodified lines
866 self._state = ClientState.OPENED867 timeout = (868 self.timeout if isinstance(timeout, UseClientDefault) else Timeout(timeout)869 )870 allow_redirects = (871 self.allow_redirects872 if isinstance(allow_redirects, UseClientDefault)873 else allow_redirects874 )875876 auth = self._build_request_auth(request, auth)877878 response = self._send_handling_auth(
134 unmodified lines
1013 params: QueryParamTypes = None,1014 headers: HeaderTypes = None,1015 cookies: CookieTypes = None,1016 auth: typing.Union[AuthTypes, UseClientDefault] = USE_CLIENT_DEFAULT,1010 allow_redirects: bool = True,1017 allow_redirects: typing.Union[bool, UseClientDefault] = USE_CLIENT_DEFAULT,1018 timeout: typing.Union[TimeoutTypes, UseClientDefault] = USE_CLIENT_DEFAULT,1019 ) -> Response:1020 """1021 Send a `GET` request.
18 unmodified lines
1040 params: QueryParamTypes = None,1041 headers: HeaderTypes = None,1042 cookies: CookieTypes = None,1043 auth: typing.Union[AuthTypes, UseClientDefault] = USE_CLIENT_DEFAULT,1037 allow_redirects: bool = True,1044 allow_redirects: typing.Union[bool, UseClientDefault] = USE_CLIENT_DEFAULT,1045 timeout: typing.Union[TimeoutTypes, UseClientDefault] = USE_CLIENT_DEFAULT,1046 ) -> Response:1047 """1048 Send an `OPTIONS` request.
18 unmodified lines
1067 params: QueryParamTypes = None,1068 headers: HeaderTypes = None,1069 cookies: CookieTypes = None,1070 auth: typing.Union[AuthTypes, UseClientDefault] = USE_CLIENT_DEFAULT,1064 allow_redirects: bool = True,1071 allow_redirects: typing.Union[bool, UseClientDefault] = USE_CLIENT_DEFAULT,1072 timeout: typing.Union[TimeoutTypes, UseClientDefault] = USE_CLIENT_DEFAULT,1073 ) -> Response:1074 """1075 Send a `HEAD` request.
22 unmodified lines
1098 params: QueryParamTypes = None,1099 headers: HeaderTypes = None,1100 cookies: CookieTypes = None,1101 auth: typing.Union[AuthTypes, UseClientDefault] = USE_CLIENT_DEFAULT,1095 allow_redirects: bool = True,1102 allow_redirects: typing.Union[bool, UseClientDefault] = USE_CLIENT_DEFAULT,1103 timeout: typing.Union[TimeoutTypes, UseClientDefault] = USE_CLIENT_DEFAULT,1104 ) -> Response:1105 """1106 Send a `POST` request.
26 unmodified lines
1133 params: QueryParamTypes = None,1134 headers: HeaderTypes = None,1135 cookies: CookieTypes = None,1136 auth: typing.Union[AuthTypes, UseClientDefault] = USE_CLIENT_DEFAULT,1130 allow_redirects: bool = True,1137 allow_redirects: typing.Union[bool, UseClientDefault] = USE_CLIENT_DEFAULT,1138 timeout: typing.Union[TimeoutTypes, UseClientDefault] = USE_CLIENT_DEFAULT,1139 ) -> Response:1140 """1141 Send a `PUT` request.
26 unmodified lines
1168 params: QueryParamTypes = None,1169 headers: HeaderTypes = None,1170 cookies: CookieTypes = None,1171 auth: typing.Union[AuthTypes, UseClientDefault] = USE_CLIENT_DEFAULT,1165 allow_redirects: bool = True,1172 allow_redirects: typing.Union[bool, UseClientDefault] = USE_CLIENT_DEFAULT,1173 timeout: typing.Union[TimeoutTypes, UseClientDefault] = USE_CLIENT_DEFAULT,1174 ) -> Response:1175 """1176 Send a `PATCH` request.
22 unmodified lines
1199 params: QueryParamTypes = None,1200 headers: HeaderTypes = None,1201 cookies: CookieTypes = None,1202 auth: typing.Union[AuthTypes, UseClientDefault] = USE_CLIENT_DEFAULT,1196 allow_redirects: bool = True,1203 allow_redirects: typing.Union[bool, UseClientDefault] = USE_CLIENT_DEFAULT,1204 timeout: typing.Union[TimeoutTypes, UseClientDefault] = USE_CLIENT_DEFAULT,1205 ) -> Response:1206 """1207 Send a `DELETE` request.
246 unmodified lines
1454 params: QueryParamTypes = None,1455 headers: HeaderTypes = None,1456 cookies: CookieTypes = None,1457 auth: typing.Union[AuthTypes, UseClientDefault] = USE_CLIENT_DEFAULT,1451 allow_redirects: bool = True,1458 allow_redirects: typing.Union[bool, UseClientDefault] = USE_CLIENT_DEFAULT,1459 timeout: typing.Union[TimeoutTypes, UseClientDefault] = USE_CLIENT_DEFAULT,1460 ) -> Response:1461 """1462 Build and send a request.
40 unmodified lines
1503 params: QueryParamTypes = None,1504 headers: HeaderTypes = None,1505 cookies: CookieTypes = None,1506 auth: typing.Union[AuthTypes, UseClientDefault] = USE_CLIENT_DEFAULT,1500 allow_redirects: bool = True,1507 allow_redirects: typing.Union[bool, UseClientDefault] = USE_CLIENT_DEFAULT,1508 timeout: typing.Union[TimeoutTypes, UseClientDefault] = USE_CLIENT_DEFAULT,1509 ) -> typing.AsyncIterator[Response]:1510 """1511 Alternative to `httpx.request()` that streams the response body
33 unmodified lines
1545 request: Request,1546 *,1547 stream: bool = False,1548 auth: typing.Union[AuthTypes, UseClientDefault] = USE_CLIENT_DEFAULT,1542 allow_redirects: bool = True,1549 allow_redirects: typing.Union[bool, UseClientDefault] = USE_CLIENT_DEFAULT,1550 timeout: typing.Union[TimeoutTypes, UseClientDefault] = USE_CLIENT_DEFAULT,1551 ) -> Response:1552 """1553 Send a request.
14 unmodified lines
1568 self._state = ClientState.OPENED1569 timeout = (1570 self.timeout if isinstance(timeout, UseClientDefault) else Timeout(timeout)1571 )1572 allow_redirects = (1573 self.allow_redirects1574 if isinstance(allow_redirects, UseClientDefault)1575 else allow_redirects1576 )15771578 auth = self._build_request_auth(request, auth)15791580 response = await self._send_handling_auth(
141 unmodified lines
1722 params: QueryParamTypes = None,1723 headers: HeaderTypes = None,1724 cookies: CookieTypes = None,1725 auth: typing.Union[AuthTypes, UseClientDefault] = USE_CLIENT_DEFAULT,1714 allow_redirects: bool = True,1726 allow_redirects: typing.Union[bool, UseClientDefault] = USE_CLIENT_DEFAULT,1727 timeout: typing.Union[TimeoutTypes, UseClientDefault] = USE_CLIENT_DEFAULT,1728 ) -> Response:1729 """1730 Send a `GET` request.
18 unmodified lines
1749 params: QueryParamTypes = None,1750 headers: HeaderTypes = None,1751 cookies: CookieTypes = None,1752 auth: typing.Union[AuthTypes, UseClientDefault] = USE_CLIENT_DEFAULT,1741 allow_redirects: bool = True,1753 allow_redirects: typing.Union[bool, UseClientDefault] = USE_CLIENT_DEFAULT,1754 timeout: typing.Union[TimeoutTypes, UseClientDefault] = USE_CLIENT_DEFAULT,1755 ) -> Response:1756 """1757 Send an `OPTIONS` request.
18 unmodified lines
1776 params: QueryParamTypes = None,1777 headers: HeaderTypes = None,1778 cookies: CookieTypes = None,1779 auth: typing.Union[AuthTypes, UseClientDefault] = USE_CLIENT_DEFAULT,1768 allow_redirects: bool = True,1780 allow_redirects: typing.Union[bool, UseClientDefault] = USE_CLIENT_DEFAULT,1781 timeout: typing.Union[TimeoutTypes, UseClientDefault] = USE_CLIENT_DEFAULT,1782 ) -> Response:1783 """1784 Send a `HEAD` request.
22 unmodified lines
1807 params: QueryParamTypes = None,1808 headers: HeaderTypes = None,1809 cookies: CookieTypes = None,1810 auth: typing.Union[AuthTypes, UseClientDefault] = USE_CLIENT_DEFAULT,1799 allow_redirects: bool = True,1811 allow_redirects: typing.Union[bool, UseClientDefault] = USE_CLIENT_DEFAULT,1812 timeout: typing.Union[TimeoutTypes, UseClientDefault] = USE_CLIENT_DEFAULT,1813 ) -> Response:1814 """1815 Send a `POST` request.
26 unmodified lines
1842 params: QueryParamTypes = None,1843 headers: HeaderTypes = None,1844 cookies: CookieTypes = None,1845 auth: typing.Union[AuthTypes, UseClientDefault] = USE_CLIENT_DEFAULT,1834 allow_redirects: bool = True,1846 allow_redirects: typing.Union[bool, UseClientDefault] = USE_CLIENT_DEFAULT,1847 timeout: typing.Union[TimeoutTypes, UseClientDefault] = USE_CLIENT_DEFAULT,1848 ) -> Response:1849 """1850 Send a `PUT` request.
26 unmodified lines
1877 params: QueryParamTypes = None,1878 headers: HeaderTypes = None,1879 cookies: CookieTypes = None,1880 auth: typing.Union[AuthTypes, UseClientDefault] = USE_CLIENT_DEFAULT,1869 allow_redirects: bool = True,1881 allow_redirects: typing.Union[bool, UseClientDefault] = USE_CLIENT_DEFAULT,1882 timeout: typing.Union[TimeoutTypes, UseClientDefault] = USE_CLIENT_DEFAULT,1883 ) -> Response:1884 """1885 Send a `PATCH` request.
22 unmodified lines
1908 params: QueryParamTypes = None,1909 headers: HeaderTypes = None,1910 cookies: CookieTypes = None,1911 auth: typing.Union[AuthTypes, UseClientDefault] = USE_CLIENT_DEFAULT,1900 allow_redirects: bool = True,1912 allow_redirects: typing.Union[bool, UseClientDefault] = USE_CLIENT_DEFAULT,1913 timeout: typing.Union[TimeoutTypes, UseClientDefault] = USE_CLIENT_DEFAULT,1914 ) -> Response:1915 """1916 Send a `DELETE` request.
78 unmodified lines