equal
deleted
inserted
replaced
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) |