/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

  • Committer: Vincent Ladeuil
  • Date: 2011-06-27 15:42:09 UTC
  • mfrom: (5993 +trunk)
  • mto: (5993.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 5994.
  • Revision ID: v.ladeuil+lp@free.fr-20110627154209-azubuhbuxsz109hq
Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
from bzrlib import (
38
38
    debug,
39
39
    errors,
 
40
    trace,
40
41
    )
41
42
import bzrlib
42
 
from bzrlib.trace import mutter
43
43
from bzrlib.transport.http import (
44
44
    ca_bundle,
45
45
    HttpTransportBase,
50
50
try:
51
51
    import pycurl
52
52
except ImportError, e:
53
 
    mutter("failed to import pycurl: %s", e)
 
53
    trace.mutter("failed to import pycurl: %s", e)
54
54
    raise errors.DependencyNotPresent('pycurl', e)
55
55
 
56
56
try:
65
65
    # reported by Alexander Belchenko, 2006-04-26
66
66
    pycurl.Curl()
67
67
except pycurl.error, e:
68
 
    mutter("failed to initialize pycurl: %s", e)
 
68
    trace.mutter("failed to initialize pycurl: %s", e)
69
69
    raise errors.DependencyNotPresent('pycurl', e)
70
70
 
71
71
 
282
282
                # error code and the headers are known to be available, we just
283
283
                # swallow the exception, leaving the upper levels handle the
284
284
                # 400+ error.
285
 
                mutter('got pycurl error in POST: %s, %s, %s, url: %s ',
286
 
                       e[0], e[1], e, abspath)
 
285
                trace.mutter('got pycurl error in POST: %s, %s, %s, url: %s ',
 
286
                             e[0], e[1], e, abspath)
287
287
            else:
288
288
                # Re-raise otherwise
289
289
                raise
332
332
            self._report_activity(len(text), 'read')
333
333
            if (kind == pycurl.INFOTYPE_HEADER_IN
334
334
                and 'http' in debug.debug_flags):
335
 
                mutter('< %s' % text)
 
335
                trace.mutter('< %s' % (text.rstrip(),))
336
336
        elif kind in (pycurl.INFOTYPE_HEADER_OUT, pycurl.INFOTYPE_DATA_OUT,
337
337
                      pycurl.INFOTYPE_SSL_DATA_OUT):
338
338
            self._report_activity(len(text), 'write')
339
339
            if (kind == pycurl.INFOTYPE_HEADER_OUT
340
340
                and 'http' in debug.debug_flags):
341
 
                mutter('> %s' % text)
 
341
                lines = []
 
342
                for line in text.rstrip().splitlines():
 
343
                    # People are often told to paste -Dhttp output to help
 
344
                    # debug. Don't compromise credentials.
 
345
                    try:
 
346
                        header, details = line.split(':', 1)
 
347
                    except ValueError:
 
348
                        header = None
 
349
                    if header in ('Authorization', 'Proxy-Authorization'):
 
350
                        line = '%s: <masked>' % (header,)
 
351
                    lines.append(line)
 
352
                trace.mutter('> ' + '\n> '.join(lines))
342
353
        elif kind == pycurl.INFOTYPE_TEXT and 'http' in debug.debug_flags:
343
 
            mutter('* %s' % text)
 
354
            trace.mutter('* %s' % text.rstrip())
344
355
 
345
356
    def _set_curl_options(self, curl):
346
357
        """Set options for all requests"""
377
388
            curl.perform()
378
389
        except pycurl.error, e:
379
390
            url = curl.getinfo(pycurl.EFFECTIVE_URL)
380
 
            mutter('got pycurl error: %s, %s, %s, url: %s ',
381
 
                    e[0], e[1], e, url)
 
391
            trace.mutter('got pycurl error: %s, %s, %s, url: %s ',
 
392
                         e[0], e[1], e, url)
382
393
            if e[0] in (CURLE_COULDNT_RESOLVE_HOST,
383
394
                        CURLE_COULDNT_RESOLVE_PROXY,
384
395
                        CURLE_COULDNT_CONNECT,