~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: v.ladeuil+lp at free
  • Date: 2006-12-13 17:37:07 UTC
  • mto: (2323.7.1 redirection)
  • mto: This revision was merged to the branch mainline in revision 2390.
  • Revision ID: v.ladeuil+lp@free.fr-20061213173707-a1gflgoke6b3eboc
First rough http branch redirection implementation.

* bzrlib/transport/http/_urllib2_wrappers.py:
(Request.__init__): Unless told otherwise, redirections are
followed silently.
(HTTPRedirectHandler.http_error_30x): Follow redirection or return
a 30x error.

* bzrlib/transport/http/_urllib.py:
(HttpTransport_urllib._perform): Raises RedirectRequested if the
request requires it.
(HttpTransport_urllib._get): Update the request from the hints
parameter if needed.

* bzrlib/errors.py:
 (RedirectRequested): New TransportError.

* bzrlib/bzrdir.py:
(BzrDir.open_from_transport): Catch RedirectRequested and retry
with the redirected url until we get to the final destination.
(BzrDirFormat.probe_transport): Hints get to not follow the
redirections but instead tell us where this branch is redirected.

* bzrlib/transport/smart.py:
(SmartTransport.get): Add a 'hint' parameter.

* bzrlib/transport/sftp.py:
(SFTPTransport.get): Add a 'hint' parameter.

* bzrlib/transport/memory.py:
(MemoryTransport.get): Add a 'hint' parameter.

* bzrlib/transport/local.py:
(LocalTransport.get): Add a 'hint' parameter.

* bzrlib/transport/http/_pycurl.py:
(PyCurlTransport._get): Add a 'hint' parameter and pass it to
_get_full.

* bzrlib/transport/http/__init__.py:
(HttpTransportBase.get): Add a 'hint' parameter and pass
it to _get.

* bzrlib/transport/ftp.py:
(FtpTransport.get): Add a 'hint' parameter.

* bzrlib/transport/fakevfat.py:
(FakeVFATTransportDecorator.get): Add a 'hint' parameter and pass
it to the decorated transport.

* bzrlib/transport/decorator.py:
(TransportDecorator.get): Add a 'hint' parameter and pass it to the
decorated transport.

* bzrlib/transport/chroot.py:
(ChrootTransportDecorator.get): Add a 'hint' parameter. Delete a
duplicated definition of the method.

* bzrlib/transport/__init__.py:
(Transport.get): Add a 'hint' parameter.
(TransportLogger.get): Add a 'hint' parameter and pass it to the
        

Show diffs side-by-side

added added

removed removed

Lines of Context:
217
217
    def has(self, relpath):
218
218
        raise NotImplementedError("has() is abstract on %r" % self)
219
219
 
220
 
    def get(self, relpath):
 
220
    def get(self, relpath, hints={}):
221
221
        """Get the file at the given relative path.
222
222
 
223
223
        :param relpath: The relative path to the file
 
224
        :param hints: A dict of hints applicable to the get.
 
225
            follow_redirections: False
 
226
                will raise RedirectRequested instead of silently
 
227
                following the redirections.
224
228
        """
225
 
        code, response_file = self._get(relpath, None)
 
229
        code, response_file = self._get(relpath, None, hints=hints)
226
230
        return response_file
227
231
 
228
 
    def _get(self, relpath, ranges):
 
232
    def _get(self, relpath, ranges, tail_amount=0, hints={}):
229
233
        """Get a file, or part of a file.
230
234
 
231
235
        :param relpath: Path relative to transport base URL
232
 
        :param byte_range: None to get the whole file;
 
236
        :param ranges: None to get the whole file;
233
237
            or [(start,end)] to fetch parts of a file.
 
238
        :param tail_amount: to fetch that amount from file tail.
 
239
        :param hints: A dict of hints (see get).
234
240
 
235
241
        :returns: (http_code, result_file)
236
242