[Web-SIG] Making HEAD request using urllib2 module
John J Lee
jjl at pobox.com
Mon Sep 6 23:44:59 CEST 2004
On Mon, 6 Sep 2004, Lloyd Kvam wrote:
> I wrote a URL checker to verify that a website is up and responding.
> For this, a HEAD request rather than GET seems better. The urllib2
> module provides a Request class with a get_method method. I derived my
> HeadRequest class overriding get_method to return HEAD if there was no
> POST data. Then I discovered that AbstractHTTPHandler.do_open did not
> use Request.get_method, but simply used GET if there was no POST data.
> I changed do_open to use Request.get_method and that's working for me.
> Should I be reporting a bug and offering a patch? Or am I missing the
> boat on other issues?
Don't think it's a bug -- it's simply not implemented. But do go ahead
and upload it as a patch to the SF patch tracker!
I don't like the idea of a subclass just for HEAD requests (but then I
don't much like the Request class at all). How about an additional
optional arg to the Request constructor, named 'method', instead?
> Is anyone making changes to urllib2?
More information about the Web-SIG