Responses
suggest changeResponse codes can be viewed from a post operation:
from requests import post
foo = post('http://httpbin.org/post', data={'data' : 'value'})
print(foo.status_code)
Returned Data
Accessing data that is returned:
foo = post('http://httpbin.org/post', data={'data' : 'value'})
print(foo.text)
Raw Responses
In the instances where you need to access the underlying urllib3 response.HTTPResponse object, this can be done by the following:
foo = post('http://httpbin.org/post', data={'data' : 'value'})
res = foo.raw
print(res.read())
raw is the urllib3 response when the request was made with stream=True. Without that, the body has already been read and res.read() is empty. The later snippets also assume post was imported.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents