Debian Codegraph @

examples/quickstart/response_info.py

raw
1 #! /usr/bin/env python
2 # vi:ts=4:et
3
4 import pycurl
5 from io import BytesIO
6
7 buffer = BytesIO()
8 c = pycurl.Curl()
9 c.setopt(c.URL, 'http://pycurl.io/')
10 c.setopt(c.WRITEDATA, buffer)
11 c.perform()
12
13 # HTTP response code, e.g. 200.
14 print('Status: %d' % c.getinfo(c.RESPONSE_CODE))
15 # Elapsed time for the transfer.
16 print('Time: %f' % c.getinfo(c.TOTAL_TIME))
17
18 # getinfo must be called before close.
19 c.close()