[Web-SIG] Making HEAD request using urllib2 module

Lloyd Kvam pythonTutor at venix.com
Mon Sep 6 17:55:00 CEST 2004


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?  Is anyone making changes to urllib2?




Lloyd Kvam
Venix Corp.
1 Court Street, Suite 378
Lebanon, NH 03766-1358

voice:	603-653-8139
fax:	320-210-3409 (changed Aug 26, 2004)



More information about the Web-SIG mailing list