@@ -510,14 +510,21 @@ def on_request( # pylint: disable=too-many-return-statements
510
510
log_string += "\n No body was attached to the request"
511
511
logger .info (log_string )
512
512
513
- except Exception as err : # pylint: disable=broad-except
514
- logger .warning ("Failed to log request: %s" , repr ( err ) )
513
+ except Exception : # pylint: disable=broad-except
514
+ logger .warning ("Failed to log request." )
515
515
516
516
def on_response (
517
517
self ,
518
518
request : PipelineRequest [HTTPRequestType ],
519
519
response : PipelineResponse [HTTPRequestType , HTTPResponseType ],
520
520
) -> None :
521
+ """Logs HTTP response status and headers.
522
+
523
+ :param request: The PipelineRequest object.
524
+ :type request: ~azure.core.pipeline.PipelineRequest
525
+ :param response: The PipelineResponse object.
526
+ :type response: ~azure.core.pipeline.PipelineResponse
527
+ """
521
528
http_response = response .http_response
522
529
523
530
# Get logger in my context first (request has been retried)
@@ -545,8 +552,8 @@ def on_response(
545
552
value = self ._redact_header (res_header , value )
546
553
log_string += "\n '{}': '{}'" .format (res_header , value )
547
554
logger .info (log_string )
548
- except Exception as err : # pylint: disable=broad-except
549
- logger .warning ("Failed to log response: %s" , repr ( err ) )
555
+ except Exception : # pylint: disable=broad-except
556
+ logger .warning ("Failed to log response." )
550
557
551
558
552
559
class ContentDecodePolicy (SansIOHTTPPolicy [HTTPRequestType , HTTPResponseType ]):
@@ -683,6 +690,11 @@ def deserialize_from_http_generics(
683
690
return cls .deserialize_from_text (response .text (encoding ), mime_type , response = response )
684
691
685
692
def on_request (self , request : PipelineRequest [HTTPRequestType ]) -> None :
693
+ """Set the response encoding in the request context.
694
+
695
+ :param request: The PipelineRequest object.
696
+ :type request: ~azure.core.pipeline.PipelineRequest
697
+ """
686
698
options = request .context .options
687
699
response_encoding = options .pop ("response_encoding" , self ._response_encoding )
688
700
if response_encoding :
@@ -743,6 +755,11 @@ def __init__(
743
755
self .proxies = proxies
744
756
745
757
def on_request (self , request : PipelineRequest [HTTPRequestType ]) -> None :
758
+ """Adds the proxy information to the request context.
759
+
760
+ :param request: The PipelineRequest object
761
+ :type request: ~azure.core.pipeline.PipelineRequest
762
+ """
746
763
ctxt = request .context .options
747
764
if self .proxies and "proxies" not in ctxt :
748
765
ctxt ["proxies" ] = self .proxies
0 commit comments