~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Robert Collins
  • Date: 2007-04-23 02:29:35 UTC
  • mfrom: (2441 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2442.
  • Revision ID: robertc@robertcollins.net-20070423022935-9hhongamvk6bfdso
Resolve conflicts with bzr.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