##// END OF EJS Templates
httppeer: work around API differences on urllib Request objects...
Augie Fackler -
r37756:a1f78514 default
parent child Browse files
Show More
@@ -264,6 +264,14 b' def makev1commandrequest(ui, requestbuil'
264
264
265 return req, cu, qs
265 return req, cu, qs
266
266
267 def _reqdata(req):
268 """Get request data, if any. If no data, returns None."""
269 if pycompat.ispy3:
270 return req.data
271 if not req.has_data():
272 return None
273 return req.get_data()
274
267 def sendrequest(ui, opener, req):
275 def sendrequest(ui, opener, req):
268 """Send a prepared HTTP request.
276 """Send a prepared HTTP request.
269
277
@@ -290,9 +298,8 b' def sendrequest(ui, opener, req):'
290 if hgargssize is not None:
298 if hgargssize is not None:
291 dbg(line % ' %d bytes of commands arguments in headers'
299 dbg(line % ' %d bytes of commands arguments in headers'
292 % hgargssize)
300 % hgargssize)
293
301 data = _reqdata(req)
294 if req.has_data():
302 if data is not None:
295 data = req.get_data()
296 length = getattr(data, 'length', None)
303 length = getattr(data, 'length', None)
297 if length is None:
304 if length is None:
298 length = len(data)
305 length = len(data)
General Comments 0
You need to be logged in to leave comments. Login now