How to get HTTP status message in (py)curl?
Posted
by mykhal
on Stack Overflow
See other posts from Stack Overflow
or by mykhal
Published on 2010-04-27T18:02:39Z
Indexed on
2010/04/28
9:53 UTC
Read the original article
Hit count: 406
spending some time studying pycurl and libcurl documentation, i still can't find a (simple) way, how to get HTTP status message (reason-phrase) in pycurl.
status code is easy:
import pycurl
import cStringIO
curl = pycurl.Curl()
buff = cStringIO.StringIO()
curl.setopt(pycurl.URL, 'http://example.org')
curl.setopt(pycurl.WRITEFUNCTION, buff.write)
curl.perform()
print "status code: %s" % curl.getinfo(pycurl.HTTP_CODE)
# -> 200
# print "status message: %s" % ???
# -> "OK"
© Stack Overflow or respective owner