user1947415
user1947415

Reputation: 983

Is there a way to get the full http request in pycurl?

c = pycurl.Curl()
c.setopt(c.URL, 'https://httpbin.org/post')

post_data = {'field': 'value'}
# Form data must be provided already urlencoded.
postfields = urlencode(post_data)
# Sets request method to POST,
# Content-Type header to application/x-www-form-urlencoded
# and data to send in request body.
c.setopt(c.POSTFIELDS, postfields)

c.perform()
c.close()

This is example from official doc. I want to know what would be the http request looks like. Is there a way to do that?

Upvotes: 1

Views: 2463

Answers (1)

georgexsh
georgexsh

Reputation: 16624

You could use the VERBOSE option, works like curl -v, will print request/response headers to stderr:

c.setopt(pycurl.VERBOSE, 1)

see more detail on pycurl doc.

Upvotes: 4

Related Questions