Python httplib: getting outbound request headers

I do:

con = HTTPConnection(SERVER_NAME)
con.request('GET', PATH, HEADERS)
resp = con.getresponse()

For debugging reasons, I want to see the query that I used (these are fields, path, method, ..). I would expect that there will be some or something con.getRequest()like that, but did not find anything. Ideas?

+3
source share
1 answer

Try

con.setdebuglevel(1)

This will allow debugging output, which, among other things, will print all the data sent.

, ( ), HTTPConnection _output, ( ). - :

class MyHTTPConnection(HTTPConnection):
    def _output(self, s):
        print repr(s)
        super(MyHTTPConnection, self)._output(s)

, , , . httplib.

+3

Source: https://habr.com/ru/post/1751530/


All Articles