216
216
# The parent class use 0 to minimize the requests, but since we can't
217
217
# exploit the results as soon as they are received (pycurl limitation) we'd
218
# better issue more requests and provide a more responsive UI do the cost
219
# of more latency costs.
218
# better issue more requests and provide a more responsive UI incurring
219
# more latency costs.
220
220
# If you modify this, think about modifying the comment in http/__init__.py
222
222
_get_max_size = 4 * 1024 * 1024
245
245
'Server return code %d'
246
246
% curl.getinfo(pycurl.HTTP_CODE))
247
247
msg = self._parse_headers(header)
248
return code, response.handle_response(abspath, code, msg, data,
249
report_activity=self._report_activity)
248
return code, response.handle_response(abspath, code, msg, data)
251
250
def _parse_headers(self, status_and_headers):
252
251
"""Transform the headers provided by curl into an HTTPMessage"""
287
286
code = curl.getinfo(pycurl.HTTP_CODE)
288
287
msg = self._parse_headers(header)
289
return code, response.handle_response(abspath, code, msg, data,
290
report_activity=self._report_activity)
288
return code, response.handle_response(abspath, code, msg, data)
293
291
def _raise_curl_http_error(self, curl, info=None):
307
305
raise errors.InvalidHttpResponse(
308
306
url, 'Unable to handle http code %d%s' % (code,msg))
308
def _debug_cb(self, kind, text):
309
if kind in (pycurl.INFOTYPE_HEADER_IN, pycurl.INFOTYPE_DATA_IN,
310
pycurl.INFOTYPE_SSL_DATA_IN):
311
self._report_activity(len(text), 'read')
312
if (kind == pycurl.INFOTYPE_HEADER_IN
313
and 'http' in debug.debug_flags):
314
mutter('< %s' % text)
315
elif kind in (pycurl.INFOTYPE_HEADER_OUT, pycurl.INFOTYPE_DATA_OUT,
316
pycurl.INFOTYPE_SSL_DATA_OUT):
317
self._report_activity(len(text), 'write')
318
if (kind == pycurl.INFOTYPE_HEADER_OUT
319
and 'http' in debug.debug_flags):
320
mutter('> %s' % text)
321
elif kind == pycurl.INFOTYPE_TEXT and 'http' in debug.debug_flags:
322
mutter('* %s' % text)
310
324
def _set_curl_options(self, curl):
311
325
"""Set options for all requests"""
312
if 'http' in debug.debug_flags:
313
curl.setopt(pycurl.VERBOSE, 1)
314
# pycurl doesn't implement the CURLOPT_STDERR option, so we can't
315
# do : curl.setopt(pycurl.STDERR, trace._trace_file)
317
326
ua_str = 'bzr/%s (pycurl: %s)' % (bzrlib.__version__, pycurl.version)
318
327
curl.setopt(pycurl.USERAGENT, ua_str)
328
curl.setopt(pycurl.VERBOSE, 1)
329
curl.setopt(pycurl.DEBUGFUNCTION, self._debug_cb)
319
330
if self.cabundle:
320
331
curl.setopt(pycurl.CAINFO, self.cabundle)
321
332
# Set accepted auth methods