/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: John Arbash Meinel
  • Date: 2010-11-05 20:54:32 UTC
  • mfrom: (5526 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5527.
  • Revision ID: john@arbash-meinel.com-20101105205432-rmyozu8sthyhmri8
Merge bzr.dev to resolve bzr-2.3.txt (aka NEWS)

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:
267
268
        # We override the Expect: header so that pycurl will send the POST
268
269
        # body immediately.
269
270
        try:
270
 
            self._curl_perform(curl, header, ['Expect: '])
 
271
            self._curl_perform(curl, header,
 
272
                               ['Expect: ',
 
273
                                'Content-Type: application/octet-stream'])
271
274
        except pycurl.error, e:
272
275
            if e[0] == CURLE_SEND_ERROR:
273
276
                # When talking to an HTTP/1.0 server, getting a 400+ error code
290
293
        return code, response.handle_response(abspath, code, msg, data)
291
294
 
292
295
 
293
 
    def _raise_curl_http_error(self, curl, info=None):
 
296
    def _raise_curl_http_error(self, curl, info=None, body=None):
 
297
        """Common curl->bzrlib error translation.
 
298
 
 
299
        Some methods may choose to override this for particular cases.
 
300
 
 
301
        The URL and code are automatically included as appropriate.
 
302
 
 
303
        :param info: Extra information to include in the message.
 
304
        :param body: File-like object from which the body of the page can be read.
 
305
        """
294
306
        code = curl.getinfo(pycurl.HTTP_CODE)
295
307
        url = curl.getinfo(pycurl.EFFECTIVE_URL)
296
 
        # Some error codes can be handled the same way for all
297
 
        # requests
 
308
        if body is not None:
 
309
            response_body = body.read()
 
310
            plaintext_body = unhtml_roughly(response_body)
 
311
        else:
 
312
            response_body = None
 
313
            plaintext_body = ''
298
314
        if code == 403:
299
315
            raise errors.TransportError(
300
316
                'Server refuses to fulfill the request (403 Forbidden)'
301
 
                ' for %s' % url)
 
317
                ' for %s: %s' % (url, plaintext_body))
302
318
        else:
303
319
            if info is None:
304
320
                msg = ''
305
321
            else:
306
322
                msg = ': ' + info
307
323
            raise errors.InvalidHttpResponse(
308
 
                url, 'Unable to handle http code %d%s' % (code,msg))
 
324
                url, 'Unable to handle http code %d%s: %s' 
 
325
                % (code, msg, plaintext_body))
309
326
 
310
327
    def _debug_cb(self, kind, text):
311
328
        if kind in (pycurl.INFOTYPE_HEADER_IN, pycurl.INFOTYPE_DATA_IN,