changeset 30922:1beeb5185930

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.
author John Mulligan <phlogistonjohn@asynchrono.us>
date Mon, 13 Feb 2017 15:12:17 -0500
parents 1f151a33af8e
children 78de43ab585f
files mercurial/keepalive.py
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/keepalive.py	Fri Feb 10 13:56:31 2017 -0800
+++ b/mercurial/keepalive.py	Mon Feb 13 15:12:17 2017 -0500
@@ -310,14 +310,16 @@
         try:
             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:
                     h.putheader('Content-type',
                                 'application/x-www-form-urlencoded')
                 if 'content-length' not in headers:
                     h.putheader('Content-length', '%d' % len(data))
             else:
-                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():