Question

From looking at their source it appears that the method member attribute is what I want.

https://github.com/kennethreitz/requests/blob/master/requests/models.py

To summarise by example, this is what I want:

>>> r = requests.get("http://httpbin.org/get")
>>> print r.method
'GET'

However I can't figure out if there's a way to get it (without writing my own hacky wrapper)...

Was it helpful?

Solution

It's stored in the request attribute of the response:

>>> r = requests.head('http://www.example.com')
>>> r.request.method
'HEAD'

>>> r = requests.get('http://www.example.com')
>>> r.request.method
'GET'
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top