~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: John Arbash Meinel
  • Date: 2006-07-06 16:29:12 UTC
  • mto: This revision was merged to the branch mainline in revision 1869.
  • Revision ID: john@arbash-meinel.com-20060706162912-1680b115cdb24071
[merge] Johan Rydberg test updates

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
        """Set the base path where files will be stored."""
52
52
        super(HttpTransport_urllib, self).__init__(base)
53
53
 
54
 
    def _get(self, relpath, ranges):
 
54
    def _get(self, relpath, ranges, tail_amount=0):
55
55
        path = relpath
56
56
        try:
57
57
            path = self._real_abspath(relpath)
58
 
            response = self._get_url_impl(path, method='GET', ranges=ranges)
 
58
            response = self._get_url_impl(path, method='GET', ranges=ranges,
 
59
                                          tail_amount=tail_amount)
59
60
            return response.code, self._handle_response(path, response)
60
61
        except urllib2.HTTPError, e:
61
62
            mutter('url error code: %s for has url: %r', e.code, path)
72
73
                             % (self.abspath(relpath), str(e)),
73
74
                             orig_error=e)
74
75
 
75
 
    def _get_url_impl(self, url, method, ranges):
 
76
    def _get_url_impl(self, url, method, ranges, tail_amount):
76
77
        """Actually pass get request into urllib
77
78
 
78
79
        :returns: urllib Response object
86
87
        request.add_header('Pragma', 'no-cache')
87
88
        request.add_header('Cache-control', 'max-age=0')
88
89
        request.add_header('User-Agent', 'bzr/%s (urllib)' % bzrlib.__version__)
89
 
        if ranges:
90
 
            request.add_header('Range', self._range_header(ranges))
 
90
        if ranges or tail_amount:
 
91
            request.add_header('Range', self._range_header(ranges, tail_amount))
91
92
        mutter("GET %s [%s]" % (url, request.get_header('Range')))
92
93
        response = opener.open(request)
93
94
        return response