/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: 2010-10-13 08:01:36 UTC
  • mfrom: (5447.5.1 config-read)
  • mto: This revision was merged to the branch mainline in revision 5499.
  • Revision ID: v.ladeuil+lp@free.fr-20101013080136-7o5qbbwgxhgncsj8
Merge config-read into config-modify

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
    ca_bundle,
45
45
    HttpTransportBase,
46
46
    response,
 
47
    unhtml_roughly,
47
48
    )
48
49
 
49
50
try:
290
291
        return code, response.handle_response(abspath, code, msg, data)
291
292
 
292
293
 
293
 
    def _raise_curl_http_error(self, curl, info=None):
 
294
    def _raise_curl_http_error(self, curl, info=None, body=None):
 
295
        """Common curl->bzrlib error translation.
 
296
 
 
297
        Some methods may choose to override this for particular cases.
 
298
 
 
299
        The URL and code are automatically included as appropriate.
 
300
 
 
301
        :param info: Extra information to include in the message.
 
302
        :param body: File-like object from which the body of the page can be read.
 
303
        """
294
304
        code = curl.getinfo(pycurl.HTTP_CODE)
295
305
        url = curl.getinfo(pycurl.EFFECTIVE_URL)
296
 
        # Some error codes can be handled the same way for all
297
 
        # requests
 
306
        if body is not None:
 
307
            response_body = body.read()
 
308
            plaintext_body = unhtml_roughly(response_body)
 
309
        else:
 
310
            response_body = None
 
311
            plaintext_body = ''
298
312
        if code == 403:
299
313
            raise errors.TransportError(
300
314
                'Server refuses to fulfill the request (403 Forbidden)'
301
 
                ' for %s' % url)
 
315
                ' for %s: %s' % (url, plaintext_body))
302
316
        else:
303
317
            if info is None:
304
318
                msg = ''
305
319
            else:
306
320
                msg = ': ' + info
307
321
            raise errors.InvalidHttpResponse(
308
 
                url, 'Unable to handle http code %d%s' % (code,msg))
 
322
                url, 'Unable to handle http code %d%s: %s' 
 
323
                % (code, msg, plaintext_body))
309
324
 
310
325
    def _debug_cb(self, kind, text):
311
326
        if kind in (pycurl.INFOTYPE_HEADER_IN, pycurl.INFOTYPE_DATA_IN,