~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: v.ladeuil+lp at free
  • Date: 2006-10-13 08:53:34 UTC
  • mto: (2145.1.1 keepalive)
  • mto: This revision was merged to the branch mainline in revision 2146.
  • Revision ID: v.ladeuil+lp@free.fr-20061013085334-e216654a3e842ff9
Fix bug #57644 by issuing an explicit error message.

* bzrlib/tests/test_http.py:
Fix some doc strings.
(TestForbiddenServer, TestForbiddenServer_urllib,
TestForbiddenServer_pycurl): Tests for correct handling of 403
error code.

* bzrlib/transport/http/_urllib2_wrappers.py:
Cleanup errors import and uses.
(HTTPDefaultErrorHandler.http_error_default): Handles 403 error code.

* bzrlib/transport/http/_pycurl.py:
(PyCurlTransport._raise_curl_http_error): Handles 403 error code.

* bzrlib/tests/HTTPTestUtil.py:
(ForbiddenRequestHandler): New class. An http server where
everything is forbidden.

Show diffs side-by-side

added added

removed removed

Lines of Context:
194
194
    def _raise_curl_http_error(self, curl, info=None):
195
195
        code = curl.getinfo(pycurl.HTTP_CODE)
196
196
        url = curl.getinfo(pycurl.EFFECTIVE_URL)
197
 
        if info is None:
198
 
            msg = ''
 
197
        # Some error codes can be handled the same way for all
 
198
        # requests
 
199
        if code == 403:
 
200
            raise errors.TransportError('Server refuses to fullfil the request')
199
201
        else:
200
 
            msg = ': ' + info
201
 
        raise errors.InvalidHttpResponse(url, 'Unable to handle http code %d%s'
202
 
                                              % (code,msg))
 
202
            if info is None:
 
203
                msg = ''
 
204
            else:
 
205
                msg = ': ' + info
 
206
            raise errors.InvalidHttpResponse(
 
207
                url, 'Unable to handle http code %d%s' % (code,msg))
203
208
 
204
209
    def _set_curl_options(self, curl):
205
210
        """Set options for all requests"""