~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Vincent Ladeuil
  • Date: 2007-03-01 21:26:57 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-20070301212657-bclmihdfnxgfy0sw
Take Aaron's review comments into account.

* bzrlib/transport/http/_urllib2_wrappers.py:
(HTTPRedirectHandler.http_error_301): Fix bug #88780.

* bzrlib/transport/http/__init__.py:
(HttpTransportBase._get): Fix doc string.

* bzrlib/transport/__init__.py:
(do_catching_redirections): Raise TooManyRedirections instead of
requiring an exception as a parameter.

* bzrlib/tests/test_http.py:
(TestHTTPRedirections.setUp): Simplified.
(TestHTTPRedirections.test_read_redirected_bundle_from_url): New test.
(TestDoCatchRedirections): New tests.

* bzrlib/tests/HTTPTestUtil.py:
(TestCaseWithRedirectedWebserver): New class factored out from
test_http.TestHTTPRedirections.

* bzrlib/errors.py:
(TooManyRedirections): New exception.

* bzrlib/bzrdir.py:
(BzrDir.open_from_transport.redirected): Catch TooManyRedirections.

* bzrlib/bundle/__init__.py:
(read_bundle_from_url.redirected_transport): Catch TooManyRedirections.

Show diffs side-by-side

added added

removed removed

Lines of Context:
600
600
 
601
601
    def http_error_301(self, req, fp, code, msg, headers):
602
602
        response = self.http_error_30x(req, fp, code, msg, headers)
603
 
        # If one or several 301 response occur during the
 
603
        # If one or several 301 responses occur during the
604
604
        # redirection chain, we MUST update the original request
605
605
        # to indicate where the URI where finally found.
606
606
 
607
607
        original_req = req
608
608
        while original_req.parent is not None:
609
609
            original_req = original_req.parent
610
 
            if original_req.redirected_to is None:
611
 
                # Only the last occurring 301 should be taken
612
 
                # into account i.e. the first occurring here when
613
 
                # redirected_to has not yet been set.
614
 
                original_req.redirected_to = redirected_url
 
610
        if original_req.redirected_to is None:
 
611
            # Only the last occurring 301 (the deepest in the
 
612
            # recursive call chain) should be taken into
 
613
            # account i.e. the first occurring here when
 
614
            # redirected_to has not yet been set.
 
615
            original_req.redirected_to = req.redirected_to
615
616
        return response
616
617
 
617
618