Hi,

the attached patch allows overriding the two hardcoded methods "GET" and
"POST" in keepalive.py.

This makes it possible to use keepalive.py like this:

req = urllib2.Request(url)
req.get_method = lambda: "DELETE"
f = urllib2.urlopen(req)

or with a subclassed urllib2.Request, which overwrites get_method, like

    def get_method(self):
        if self.has_data():
            return "PUT"
        else:
            return "DELETE"

as described here:
http://www.agileprogrammer.com/eightytwenty/archive/2006/04/07/13258.aspx

Could you please apply it? Thanks!

Peter
-- 
Allen Gewalten zum Trutz sich erhalten.
 
SUSE LINUX Products GmbH
Research & Development
--- /usr/lib64/python2.4/site-packages/urlgrabber/keepalive.py	2006-09-22 02:58:05.000000000 +0200
+++ keepalive.py	2007-04-18 09:48:15.633262000 +0200
@@ -304,14 +304,14 @@
         try:
             if req.has_data():
                 data = req.get_data()
-                h.putrequest('POST', req.get_selector())
+                h.putrequest(req.get_method(), req.get_selector())
                 if not req.headers.has_key('Content-type'):
                     h.putheader('Content-type',
                                 'application/x-www-form-urlencoded')
                 if not req.headers.has_key('Content-length'):
                     h.putheader('Content-length', '%d' % len(data))
             else:
-                h.putrequest('GET', req.get_selector())
+                h.putrequest(req.get_method(), req.get_selector())
         except (socket.error, httplib.HTTPException), err:
             raise urllib2.URLError(err)
 

Attachment: pgp2PEv7fWRrn.pgp
Description: PGP signature

_______________________________________________
Yum-devel mailing list
[email protected]
https://lists.dulug.duke.edu/mailman/listinfo/yum-devel

Reply via email to