/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

  • Committer: Martin von Gagern
  • Date: 2010-04-20 08:47:38 UTC
  • mfrom: (5167 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5195.
  • Revision ID: martin.vgagern@gmx.net-20100420084738-ygymnqmdllzrhpfn
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
 
1
# Copyright (C) 2006-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
from cStringIO import StringIO
18
18
import urllib
43
43
 
44
44
    def __init__(self, base, _from_transport=None):
45
45
        super(HttpTransport_urllib, self).__init__(
46
 
            base, _from_transport=_from_transport)
 
46
            base, 'urllib', _from_transport=_from_transport)
47
47
        if _from_transport is not None:
48
48
            self._opener = _from_transport._opener
49
49
        else:
50
 
            self._opener = self._opener_class()
 
50
            self._opener = self._opener_class(
 
51
                report_activity=self._report_activity)
51
52
 
52
53
    def _perform(self, request):
53
54
        """Send the request to the server and handles common errors.
86
87
            self._update_credentials((request.auth, request.proxy_auth))
87
88
 
88
89
        code = response.code
89
 
        if request.follow_redirections is False \
90
 
                and code in (301, 302, 303, 307):
 
90
        if (request.follow_redirections is False
 
91
            and code in (301, 302, 303, 307)):
91
92
            raise errors.RedirectRequested(request.get_full_url(),
92
93
                                           request.redirected_to,
93
 
                                           is_permanent=(code == 301),
94
 
                                           qual_proto=self._scheme)
 
94
                                           is_permanent=(code == 301))
95
95
 
96
96
        if request.redirected_to is not None:
97
97
            trace.mutter('redirected from: %s to: %s' % (request.get_full_url(),
101
101
 
102
102
    def _get(self, relpath, offsets, tail_amount=0):
103
103
        """See HttpTransport._get"""
104
 
 
105
104
        abspath = self._remote_path(relpath)
106
105
        headers = {}
107
106
        accepted_errors = [200, 404]
166
165
 
167
166
def get_test_permutations():
168
167
    """Return the permutations to be used in testing."""
169
 
    from bzrlib.tests.http_server import HttpServer_urllib
170
 
    return [(HttpTransport_urllib, HttpServer_urllib),
171
 
            ]
 
168
    from bzrlib import tests
 
169
    from bzrlib.tests import http_server
 
170
    permutations = [(HttpTransport_urllib, http_server.HttpServer_urllib),]
 
171
    if tests.HTTPSServerFeature.available():
 
172
        from bzrlib.tests import https_server
 
173
        permutations.append((HttpTransport_urllib,
 
174
                             https_server.HTTPSServer_urllib))
 
175
    return permutations