Handling cookies without urllib2 and cookielib
Joshua Kugler
jkugler at bigfoot.com
Mon Dec 17 19:19:17 EST 2007
Gabriel Genellina wrote:
> On 14 dic, 23:44, Joshua Kugler <jkug... at bigfoot.com> wrote:
>
>> I'm using HTTPlib to construct some functional tests for a web app we're
>> writing. We're not using urllib2 because we need support for PUT and
>> DELETE methods, which urllib2 does not do.
>>
>> We also need client-side cookie handling. So, I start reading about
>> cookielib and run across a problem. It's cookie handling is tied quite
>> tightly to urllib2's request object. httplib has somewhat different
>> semantics in its request object. So, you can use cookielib with httplib.
>> And cookie lib has no simple function (that I could find) for passing in
>> a set-cookie header and getting back a CookieJar object (or even a list
>> of Cookie objects).
>
> What about correcting the first thing, making urllib2 support HEAD/PUT/
> DELETE?
<SNIP>
We may have to do that, and then hack on the Redirect handler too so it will
properly keep the request method. But that's not our preference, for
obvious reasons. :)
I just find it hard to believe that no one has ever needed to do cookie
handling in a generic way (i.e. input: set-cookie header, output: cookie
objects) before. May have to write my own. Or sublcass/extend cookielib.
j
More information about the Python-list
mailing list