Mercurial > public > mercurial-scm > hg
comparison mercurial/httppeer.py @ 36297:a59ff82154b8
httppeer: headers are native strings
# skip-blame just marking some native strings
Differential Revision: https://phab.mercurial-scm.org/D2313
author | Augie Fackler <augie@google.com> |
---|---|
date | Sun, 18 Feb 2018 00:03:39 -0500 |
parents | 2d513ab7ce94 |
children | 23d12524a202 |
comparison
equal
deleted
inserted
replaced
36296:d18c0cf5f3ab | 36297:a59ff82154b8 |
---|---|
333 | 333 |
334 req = self._requestbuilder(pycompat.strurl(cu), data, headers) | 334 req = self._requestbuilder(pycompat.strurl(cu), data, headers) |
335 | 335 |
336 if data is not None: | 336 if data is not None: |
337 self.ui.debug("sending %d bytes\n" % size) | 337 self.ui.debug("sending %d bytes\n" % size) |
338 req.add_unredirected_header('Content-Length', '%d' % size) | 338 req.add_unredirected_header(r'Content-Length', r'%d' % size) |
339 try: | 339 try: |
340 resp = self._openurl(req) | 340 resp = self._openurl(req) |
341 except urlerr.httperror as inst: | 341 except urlerr.httperror as inst: |
342 if inst.code == 401: | 342 if inst.code == 401: |
343 raise error.Abort(_('authorization failed')) | 343 raise error.Abort(_('authorization failed')) |
432 type = x | 432 type = x |
433 break | 433 break |
434 | 434 |
435 tempname = bundle2.writebundle(self.ui, cg, None, type) | 435 tempname = bundle2.writebundle(self.ui, cg, None, type) |
436 fp = httpconnection.httpsendfile(self.ui, tempname, "rb") | 436 fp = httpconnection.httpsendfile(self.ui, tempname, "rb") |
437 headers = {'Content-Type': 'application/mercurial-0.1'} | 437 headers = {r'Content-Type': r'application/mercurial-0.1'} |
438 | 438 |
439 try: | 439 try: |
440 r = self._call(cmd, data=fp, headers=headers, **args) | 440 r = self._call(cmd, data=fp, headers=headers, **args) |
441 vals = r.split('\n', 1) | 441 vals = r.split('\n', 1) |
442 if len(vals) < 2: | 442 if len(vals) < 2: |
463 fh.write(d) | 463 fh.write(d) |
464 d = fp.read(4096) | 464 d = fp.read(4096) |
465 fh.close() | 465 fh.close() |
466 # start http push | 466 # start http push |
467 fp_ = httpconnection.httpsendfile(self.ui, filename, "rb") | 467 fp_ = httpconnection.httpsendfile(self.ui, filename, "rb") |
468 headers = {'Content-Type': 'application/mercurial-0.1'} | 468 headers = {r'Content-Type': r'application/mercurial-0.1'} |
469 return self._callstream(cmd, data=fp_, headers=headers, **args) | 469 return self._callstream(cmd, data=fp_, headers=headers, **args) |
470 finally: | 470 finally: |
471 if fp_ is not None: | 471 if fp_ is not None: |
472 fp_.close() | 472 fp_.close() |
473 if fh is not None: | 473 if fh is not None: |