Mercurial > public > mercurial-scm > hg-stable
diff mercurial/httprepo.py @ 15159:85322c19c831
merge with stable
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Tue, 27 Sep 2011 18:50:18 -0500 |
parents | f4522df38c65 94b200a11cf7 |
children | 7b15dd9125b3 |
line wrap: on
line diff
--- a/mercurial/httprepo.py Thu Sep 22 01:51:36 2011 +0200 +++ b/mercurial/httprepo.py Tue Sep 27 18:50:18 2011 -0500 @@ -73,9 +73,14 @@ if cmd == 'pushkey': args['data'] = '' data = args.pop('data', None) + size = 0 + if util.safehasattr(data, 'length'): + size = data.length + elif data is not None: + size = len(data) headers = args.pop('headers', {}) - if data and self.ui.configbool('ui', 'usehttp2', False): + if size and self.ui.configbool('ui', 'usehttp2', False): headers['Expect'] = '100-Continue' headers['X-HgHttp2'] = '1' @@ -104,9 +109,6 @@ cu = "%s%s" % (self._url, qs) req = urllib2.Request(cu, data, headers) if data is not None: - # len(data) is broken if data doesn't fit into Py_ssize_t - # add the header ourself to avoid OverflowError - size = data.__len__() self.ui.debug("sending %s bytes\n" % size) req.add_unredirected_header('Content-Length', '%d' % size) try: