Mercurial > hg > mercurial-source
comparison mercurial/keepalive.py @ 31701: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 | dc5b594f41e9 |
children | aa836f56c3cc |
comparison
equal
deleted
inserted
replaced
31700:1f151a33af8e | 31701:1beeb5185930 |
---|---|
308 if n in headers: | 308 if n in headers: |
309 skipheaders['skip_' + n.replace('-', '_')] = 1 | 309 skipheaders['skip_' + n.replace('-', '_')] = 1 |
310 try: | 310 try: |
311 if req.has_data(): | 311 if req.has_data(): |
312 data = req.get_data() | 312 data = req.get_data() |
313 h.putrequest('POST', req.get_selector(), **skipheaders) | 313 h.putrequest( |
314 req.get_method(), req.get_selector(), **skipheaders) | |
314 if 'content-type' not in headers: | 315 if 'content-type' not in headers: |
315 h.putheader('Content-type', | 316 h.putheader('Content-type', |
316 'application/x-www-form-urlencoded') | 317 'application/x-www-form-urlencoded') |
317 if 'content-length' not in headers: | 318 if 'content-length' not in headers: |
318 h.putheader('Content-length', '%d' % len(data)) | 319 h.putheader('Content-length', '%d' % len(data)) |
319 else: | 320 else: |
320 h.putrequest('GET', req.get_selector(), **skipheaders) | 321 h.putrequest( |
322 req.get_method(), req.get_selector(), **skipheaders) | |
321 except socket.error as err: | 323 except socket.error as err: |
322 raise urlerr.urlerror(err) | 324 raise urlerr.urlerror(err) |
323 for k, v in headers.items(): | 325 for k, v in headers.items(): |
324 h.putheader(k, v) | 326 h.putheader(k, v) |
325 h.endheaders() | 327 h.endheaders() |