@@ -741,6 +741,37 @@ def send(
741
741
742
742
return response
743
743
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 response
766
+ except BaseException as exc :
767
+ response .close ()
768
+ raise exc from None
769
+ else :
770
+ response .history = list (history )
771
+ response .read ()
772
+ request = next_request
773
+ history .append (response )
774
+
744
775
def _send_handling_redirects (
745
776
self ,
746
777
request : Request ,
@@ -775,37 +806,6 @@ def _send_handling_redirects(
775
806
)
776
807
return response
777
808
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 response
800
- except BaseException as exc :
801
- response .close ()
802
- raise exc from None
803
- else :
804
- response .history = list (history )
805
- response .read ()
806
- request = next_request
807
- history .append (response )
808
-
809
809
def _send_single_request (self , request : Request , timeout : Timeout ) -> Response :
810
810
"""
811
811
Sends a single request, without handling any redirections.
@@ -1364,6 +1364,37 @@ async def send(
1364
1364
1365
1365
return response
1366
1366
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 response
1389
+ except BaseException as exc :
1390
+ await response .aclose ()
1391
+ raise exc from None
1392
+ else :
1393
+ response .history = list (history )
1394
+ await response .aread ()
1395
+ request = next_request
1396
+ history .append (response )
1397
+
1367
1398
async def _send_handling_redirects (
1368
1399
self ,
1369
1400
request : Request ,
@@ -1398,37 +1429,6 @@ async def _send_handling_redirects(
1398
1429
)
1399
1430
return response
1400
1431
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 response
1423
- except BaseException as exc :
1424
- await response .aclose ()
1425
- raise exc from None
1426
- else :
1427
- response .history = list (history )
1428
- await response .aread ()
1429
- request = next_request
1430
- history .append (response )
1431
-
1432
1432
async def _send_single_request (
1433
1433
self , request : Request , timeout : Timeout
1434
1434
) -> Response :
0 commit comments