Package: python-urlgrabber
Version: 3.1.0-3
Severity: normal
Tags: patch


urlgrabber.keepalive.HTTPHandler don't use Request.get_method() to determine the appropriate HTTP method.


$ cat buggy.py
#!/usr/bin/python
from urllib2 import Request, AbstractHTTPHandler, build_opener
from urlgrabber.keepalive import HTTPHandler as KeepaliveHTTPHandler

class HeadRequest(Request):
    def get_method(self):
      return 'HEAD'

u2_opener = build_opener()
ka_opener = build_opener(KeepaliveHTTPHandler)

URL = 'http://www.us.debian.org/'

for opener in u2_opener, ka_opener:
    print \
      [h for h in opener.handlers if isinstance(h, AbstractHTTPHandler)], \
      len(opener.open(HeadRequest(URL)).read())


$ python buggy.py
[<urllib2.HTTPHandler instance at 0xb78bfc6c>, <urllib2.HTTPSHandler instance at 
0xb78d214c>] 0
[<urllib2.HTTPSHandler instance at 0xb78d23cc>, <urlgrabber.keepalive.HTTPHandler 
instance at 0xb78d24cc>] 14213


The attached patch solves this problem.


-- System Information:
Debian Release: lenny/sid
    APT prefers testing
    APT policy: (900, 'testing'), (600, 'unstable'), (500, 'experimental')
Architecture: i386 (i686)

Kernel: Linux 2.6.21-2-686 (SMP w/1 CPU core)
Locale: LANG=C, LC_CTYPE=pl_PL (charmap=ISO-8859-2)
Shell: /bin/sh linked to /bin/dash

Versions of packages python-urlgrabber depends on:
ii  python-support                0.6.4      automated rebuilding support for p
ii  python2.4                     2.4.4-4    An interactive high-level object-o

python-urlgrabber recommends no packages.

-- no debconf information

--
Jakub Wilk

Attachment: keepalive.py.diff.gz
Description: Binary data

Reply via email to