You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is it possible to directly access the request (python requests) object for low level HTTP handling?
I am writing a logger plugin and wanted to also log raw HTTP-related things, such as the method, request headers, request body, response headers, response body.
The text was updated successfully, but these errors were encountered:
You can generally turn on logging by the requests module like this
importloggingfromhttp.clientimportHTTPConnectiondefdebug_requests_on():
"""Switches on logging of the requests module."""HTTPConnection.debuglevel=1logging.basicConfig()
logging.getLogger().setLevel(logging.DEBUG)
requests_log=logging.getLogger("requests.packages.urllib3")
requests_log.setLevel(logging.DEBUG)
requests_log.propagate=Truedebug_requests_on()
Sadly I don't have the link from where I got it, but it's proven very useful
Another way you can do this is by creating request/response hooks for a session and using that session as transport
Is it possible to directly access the request (python
requests
) object for low level HTTP handling?I am writing a logger plugin and wanted to also log raw HTTP-related things, such as the method, request headers, request body, response headers, response body.
The text was updated successfully, but these errors were encountered: