~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/http/_pycurl.py

  • Committer: Vincent Ladeuil
  • Date: 2009-02-05 10:20:51 UTC
  • mfrom: (3945.1.8 pb-http)
  • mto: This revision was merged to the branch mainline in revision 3983.
  • Revision ID: v.ladeuil+lp@free.fr-20090205102051-gyivrlud1hk1c12g
Progress bar at socket level for http

Show diffs side-by-side

added added

removed removed

Lines of Context:
215
215
 
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
221
221
    # too.
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)
250
249
 
251
250
    def _parse_headers(self, status_and_headers):
252
251
        """Transform the headers provided by curl into an HTTPMessage"""
286
285
        data.seek(0)
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)
291
289
 
292
290
 
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))
309
307
 
 
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)
 
323
 
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)
316
 
 
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