Switch auth/redirect methods to follow flow of execution better (#1273)
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 ed16eb3 · Browse files · 1 file·+62 added−62 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+62 added−62 removed
- other:+62 added−62 removed
Provenance
- Commit
930f377- Tree
a595bf5- Author
Tom Christie <tom@tomchristie.com>- Committer
GitHub <noreply@github.com>- Parent
ed16eb3
1 file changed+62 added−62 removed
modified:httpx/_client.py+62 added-62 removed
739 unmodified lines740 response.close()741 742 return response743 744+ def _send_handling_auth(745+ self,746+ request: Request,747+ auth: Auth,748+ timeout: Timeout,749+ allow_redirects: bool,750+ history: typing.List[Response],751+ ) -> Response:752+ auth_flow = auth.sync_auth_flow(request)753+ request = next(auth_flow)754+755+ while True:756+ response = self._send_handling_redirects(757+ request,758+ timeout=timeout,759+ allow_redirects=allow_redirects,760+ history=history,761+ )762+ try:763+ next_request = auth_flow.send(response)764+ except StopIteration:765+ return response766+ except BaseException as exc:767+ response.close()768+ raise exc from None769+ else:770+ response.history = list(history)771+ response.read()772+ request = next_request773+ history.append(response)774+775 def _send_handling_redirects(776 self,777 request: Request,778 timeout: Timeout,26 unmodified lines805 history=history,806 )807 return response808 778- def _send_handling_auth(779- self,780- request: Request,781- auth: Auth,782- timeout: Timeout,783- allow_redirects: bool,784- history: typing.List[Response],785- ) -> Response:786- auth_flow = auth.sync_auth_flow(request)787- request = next(auth_flow)788-789- while True:790- response = self._send_handling_redirects(791- request,792- timeout=timeout,793- allow_redirects=allow_redirects,794- history=history,795- )796- try:797- next_request = auth_flow.send(response)798- except StopIteration:799- return response800- except BaseException as exc:801- response.close()802- raise exc from None803- else:804- response.history = list(history)805- response.read()806- request = next_request807- history.append(response)808-809 def _send_single_request(self, request: Request, timeout: Timeout) -> Response:810 """811 Sends a single request, without handling any redirections.812 """550 unmodified lines1363 await response.aclose()1364 1365 return response1366 1367+ async def _send_handling_auth(1368+ self,1369+ request: Request,1370+ auth: Auth,1371+ timeout: Timeout,1372+ allow_redirects: bool,1373+ history: typing.List[Response],1374+ ) -> Response:1375+ auth_flow = auth.async_auth_flow(request)1376+ request = await auth_flow.__anext__()1377+1378+ while True:1379+ response = await self._send_handling_redirects(1380+ request,1381+ timeout=timeout,1382+ allow_redirects=allow_redirects,1383+ history=history,1384+ )1385+ try:1386+ next_request = await auth_flow.asend(response)1387+ except StopAsyncIteration:1388+ return response1389+ except BaseException as exc:1390+ await response.aclose()1391+ raise exc from None1392+ else:1393+ response.history = list(history)1394+ await response.aread()1395+ request = next_request1396+ history.append(response)1397+1398 async def _send_handling_redirects(1399 self,1400 request: Request,1401 timeout: Timeout,26 unmodified lines1428 history=history,1429 )1430 return response1431 1401- async def _send_handling_auth(1402- self,1403- request: Request,1404- auth: Auth,1405- timeout: Timeout,1406- allow_redirects: bool,1407- history: typing.List[Response],1408- ) -> Response:1409- auth_flow = auth.async_auth_flow(request)1410- request = await auth_flow.__anext__()1411-1412- while True:1413- response = await self._send_handling_redirects(1414- request,1415- timeout=timeout,1416- allow_redirects=allow_redirects,1417- history=history,1418- )1419- try:1420- next_request = await auth_flow.asend(response)1421- except StopAsyncIteration:1422- return response1423- except BaseException as exc:1424- await response.aclose()1425- raise exc from None1426- else:1427- response.history = list(history)1428- await response.aread()1429- request = next_request1430- history.append(response)1431-1432 async def _send_single_request(1433 self, request: Request, timeout: Timeout1434 ) -> Response:1435 """345 unmodified lines