Python requests – print entire http request (raw)?
Since v1.2.3 Requests added the PreparedRequest object. As per the documentation “it contains the exact bytes that will be sent to the server”. One can use this to pretty print a request, like so: import requests req = requests.Request(‘POST’,’http://stackoverflow.com’,headers={‘X-Custom’:’Test’},data=”a=1&b=2″) prepared = req.prepare() def pretty_print_POST(req): “”” At this point it is completely built and ready to … Read more