httplib slow read

Kjetil Jacobsen setattr at yahoo.no
Fri Dec 7 04:24:26 EST 2001


John Hunter <jdhunter at nitace.bsd.uchicago.edu> wrote in message news:<m2u1v4w55n.fsf at mother.paradise.lost>...
> >>>>> "Kjetil" == Kjetil Jacobsen <setattr at yahoo.no> writes:
> 
>     Kjetil> another option may be to use the pycurl module which wraps
>     Kjetil> the curl library:
> 
> Thanks for the tip.  I have installed it and it looks nice.  One thing
> I have not been able to figure out is how to direct pycurl to print
> the HTTP header it would send were I too invoke 'perform'.  
> 
> Something like
> 
> import pycurl
> c = pycurl.init()
> c.setopt(pycurl.URL, 'http://www.python.org')
> c.setopt(pycurl.REFERER, 'http://www.yahoo.com)
> 
> # tried this but it ain't right.
> print pycurl.HTTPHEADER
> 
> How can I do this?

pycurl.HTTPHEADER is used to set additional headers which will be used
when doing the request.  see e.g. tests/basicfirst.py on how to use
the HTTPHEADER option to set custom headers.

afaik there is no way to get the header _before_ doing the actual
perform().
however, you can turn on the verbose flag:

c.setopt(pycurl.VERBOSE, 1)

which will print the header when perform() is invoked.

you may also use the pycurl.CUSTOMREQUEST to hand-craft your own
header to be used when doing the perform().

> Aside from the internal __doc__ and the cURL pages and the
> pycurl/tests files, is there any documentation I should be aware of?

pycurl closely follows the behaviour of libcurl. just remove the
CURLOPT_ prefix for setopt() and the CURLINFO_ prefix for getinfo().

i am not aware of any other documentation.

regards,
        - kjetil



More information about the Python-list mailing list