D3347: httppeer: work around API differences on urllib Request objects
This revision was automatically updated to reflect the committed changes. Closed by commit rHGa1f785148097: httppeer: work around API differences on urllib Request objects (authored by durin42, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3347?vs=8224=8341 REVISION DETAIL https://phab.mercurial-scm.org/D3347 AFFECTED FILES mercurial/httppeer.py CHANGE DETAILS diff --git a/mercurial/httppeer.py b/mercurial/httppeer.py --- a/mercurial/httppeer.py +++ b/mercurial/httppeer.py @@ -264,6 +264,14 @@ return req, cu, qs +def _reqdata(req): +"""Get request data, if any. If no data, returns None.""" +if pycompat.ispy3: +return req.data +if not req.has_data(): +return None +return req.get_data() + def sendrequest(ui, opener, req): """Send a prepared HTTP request. @@ -290,9 +298,8 @@ if hgargssize is not None: dbg(line % ' %d bytes of commands arguments in headers' % hgargssize) - -if req.has_data(): -data = req.get_data() +data = _reqdata(req) +if data is not None: length = getattr(data, 'length', None) if length is None: length = len(data) To: durin42, #hg-reviewers, indygreg Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3347: httppeer: work around API differences on urllib Request objects
durin42 created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY Since this is only a problem in httppeer, I'd rather keep this a local-to-the-module kludge rather than pile more on pycompat. We'll still find it easily to clean up later because it checks pycompat.ispy3. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3347 AFFECTED FILES mercurial/httppeer.py CHANGE DETAILS diff --git a/mercurial/httppeer.py b/mercurial/httppeer.py --- a/mercurial/httppeer.py +++ b/mercurial/httppeer.py @@ -264,6 +264,14 @@ return req, cu, qs +def _reqdata(req): +"""Get request data, if any. If no data, returns None.""" +if pycompat.ispy3: +return req.data +if not req.has_data(): +return None +return req.get_data() + def sendrequest(ui, opener, req): """Send a prepared HTTP request. @@ -290,9 +298,8 @@ if hgargssize is not None: dbg(line % ' %d bytes of commands arguments in headers' % hgargssize) - -if req.has_data(): -data = req.get_data() +data = _reqdata(req) +if data is not None: length = getattr(data, 'length', None) if length is None: length = len(data) To: durin42, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel