Patchwork [1,of,2,RFC] keepalive: honor urllib2 style get_method overrides

mail settings
Submitter John Mulligan
Date Feb. 9, 2017, 8:30 p.m.
Message ID <71debb56ce136086187d.1486672237@giza>
Download mbox | patch
Permalink /patch/18366/
State Accepted
Headers show


John Mulligan - Feb. 9, 2017, 8:30 p.m.
# HG changeset patch
# User John Mulligan <>
# Date 1486671527 18000
#      Thu Feb 09 15:18:47 2017 -0500
# Node ID 71debb56ce136086187d7f9c1986eb7f3b9ee0a9
# Parent  eb78ec9e97b70310e2944f72c29463bedfc21442
keepalive: honor urllib2 style get_method overrides

In urllib2 docs and discussions it can be found that in order
to make a request other than GET or POST the get_method of a
Request object can be overriden. Make Mercurial's internal
version of this honor the return value of get_method.

Please see the followup patch to the bugzilla extension for
the reason for this change. Marking RFC because I'm not entirely
sure this is the right way make the HTTP requests.


diff --git a/mercurial/ b/mercurial/
--- a/mercurial/
+++ b/mercurial/
@@ -310,14 +310,14 @@  class KeepAliveHandler(object):
             if req.has_data():
                 data = req.get_data()
-                h.putrequest('POST', req.get_selector(), **skipheaders)
+                h.putrequest(req.get_method(), req.get_selector(), **skipheaders)
                 if 'content-type' not in headers:
                 if 'content-length' not in headers:
                     h.putheader('Content-length', '%d' % len(data))
-                h.putrequest('GET', req.get_selector(), **skipheaders)
+                h.putrequest(req.get_method(), req.get_selector(), **skipheaders)
         except socket.error as err:
             raise urlerr.urlerror(err)
         for k, v in headers.items():