comparison mercurial/httppeer.py @ 48887:426cf9d98a5d

httppeer: inline simplified _reqdata() The function can be reduced to an attribute lookup on Python 3. So inline it. Differential Revision: https://phab.mercurial-scm.org/D12290
author Gregory Szorc <gregory.szorc@gmail.com>
date Mon, 21 Feb 2022 10:25:53 -0700
parents 6000f5b25c9b
children 642e31cb55f0
comparison
equal deleted inserted replaced
48886:127cc4535853 48887:426cf9d98a5d
229 req.add_unredirected_header('Content-Length', '%d' % size) 229 req.add_unredirected_header('Content-Length', '%d' % size)
230 230
231 return req, cu, qs 231 return req, cu, qs
232 232
233 233
234 def _reqdata(req):
235 """Get request data, if any. If no data, returns None."""
236 if pycompat.ispy3:
237 return req.data
238 if not req.has_data():
239 return None
240 return req.get_data()
241
242
243 def sendrequest(ui, opener, req): 234 def sendrequest(ui, opener, req):
244 """Send a prepared HTTP request. 235 """Send a prepared HTTP request.
245 236
246 Returns the response object. 237 Returns the response object.
247 """ 238 """
272 dbg( 263 dbg(
273 line 264 line
274 % b' %d bytes of commands arguments in headers' 265 % b' %d bytes of commands arguments in headers'
275 % hgargssize 266 % hgargssize
276 ) 267 )
277 data = _reqdata(req) 268 data = req.data
278 if data is not None: 269 if data is not None:
279 length = getattr(data, 'length', None) 270 length = getattr(data, 'length', None)
280 if length is None: 271 if length is None:
281 length = len(data) 272 length = len(data)
282 dbg(line % b' %d bytes of data' % length) 273 dbg(line % b' %d bytes of data' % length)