urllib2.UserAgent [was: Re: [Web-SIG] So what's missing?]

John J Lee jjl at pobox.com
Wed Oct 29 06:56:59 EST 2003


OK, having slept on it, I just had a tiny epiphany.  I haven't been
listening to my own arguments.  Since OpenerDirector is *already* a
UserAgent-type thing, but not a very friendly one, we should just create a
new OpenerDirector, and name it UserAgent.  I don't see that as a wrapper,
so my delicate sensibilities aren't offended by it ;-) So, I'm persuaded:
sorry it took me so long...

Problems to be solved:

 - awkward to dynamically change behaviour of user-agent -- you have
   to build a OpenerDirector every time you want to change things
 - unhelpful separation by default of HTTP and HTTPS
 - unhelpful separation by default of various server authentication
   schemes
 - no ability to do partial fetches
 - no ability to do HEAD and PUT

...any more?

The last two need changes in the rest of urllib2, of course.

I'll have a look at some of the Perl & Java UserAgent-type classes for
ideas, and probably write a class to base discussions on.


On Wed, 29 Oct 2003, Ian Bicking wrote:
[...about my processors patch to urllib2...]
> The processors really sound like wrappers to me.
[...]

No, they work rather like handlers, and are definitely internal to
urllib2.


> >> Seems like it would also make sense as a OpenerDirectory
> >> subclass/wrapper.
> >
> > IIRC, there are issues with redirection that prevent that.
>
> How so?  For instance, with referer, don't you essentially just want to
> do something like:

I've forgotten the details, but I'm pretty confident they're not very
interesting :-)  They're in my bug tracker item, I think.


John



More information about the Web-SIG mailing list