~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-04-01 06:48:38 UTC
  • mfrom: (2389.1.1 0.15-to-trunk)
  • Revision ID: pqm@pqm.ubuntu.com-20070401064838-34903c7b0d0c8007
merge 0.15 back to dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
from cStringIO import StringIO
18
18
 
19
 
from bzrlib import ui
20
 
from bzrlib.errors import NoSuchFile
 
19
from bzrlib import (
 
20
    ui,
 
21
    errors,
 
22
    )
21
23
from bzrlib.trace import mutter
22
24
from bzrlib.transport import register_urlparse_netloc_protocol
23
25
from bzrlib.transport.http import HttpTransportBase
107
109
            self._user = request.user
108
110
            self._password = request.password
109
111
 
 
112
        code = response.code
 
113
        if request.follow_redirections is False \
 
114
                and code in (301, 302, 303, 307):
 
115
            raise errors.RedirectRequested(request.get_full_url(),
 
116
                                           request.redirected_to,
 
117
                                           is_permament=(code == 301),
 
118
                                           qual_proto=self._qualified_proto)
 
119
 
110
120
        if request.redirected_to is not None:
111
 
            # TODO: Update the transport so that subsequent
112
 
            # requests goes directly to the right host
113
121
            mutter('redirected from: %s to: %s' % (request.get_full_url(),
114
122
                                                   request.redirected_to))
115
123
 
132
140
        code = response.code
133
141
        if code == 404: # not found
134
142
            self._connection.fake_close()
135
 
            raise NoSuchFile(abspath)
 
143
            raise errors.NoSuchFile(abspath)
136
144
 
137
145
        data = handle_response(abspath, code, response.headers, response)
138
146
        # Close response to free the httplib.HTTPConnection pipeline
171
179
        response = self._head(relpath)
172
180
 
173
181
        code = response.code
174
 
        # FIXME: 302 MAY have been already processed by the
175
 
        # redirection handler
176
 
        if code in (200, 302): # "ok", "found"
 
182
        if code == 200: # "ok",
177
183
            return True
178
184
        else:
179
 
            assert(code == 404, 'Only 200, 404 or may be 302 are correct')
 
185
            assert(code == 404, 'Only 200 or 404 are correct')
180
186
            return False
181
187
 
182
188