~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Aaron Bentley
  • Date: 2006-10-15 16:22:42 UTC
  • mfrom: (2077 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2078.
  • Revision ID: aaron.bentley@utoronto.ca-20061015162242-2de5677dd0495500
Merge from bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
        # so nothing to do with from_transport
55
55
 
56
56
    def _get(self, relpath, ranges, tail_amount=0):
 
57
        return self._request(relpath, 'GET', ranges, tail_amount=tail_amount)
 
58
 
 
59
    def _request(self, relpath, method, ranges, tail_amount=0, body=None):
57
60
        path = relpath
58
61
        try:
59
62
            path = self._real_abspath(relpath)
60
 
            resp = self._get_url_impl(path, method='GET', ranges=ranges,
61
 
                                      tail_amount=tail_amount)
 
63
            resp = self._get_url_impl(path, method=method, ranges=ranges,
 
64
                                      tail_amount=tail_amount, body=body)
62
65
            return resp.code, response.handle_response(path,
63
66
                                resp.code, resp.headers, resp)
64
67
        except urllib2.HTTPError, e:
76
79
                                  % (self.abspath(relpath), str(e)),
77
80
                                  orig_error=e)
78
81
 
79
 
    def _get_url_impl(self, url, method, ranges, tail_amount=0):
 
82
    def _get_url_impl(self, url, method, ranges, tail_amount=0, body=None):
80
83
        """Actually pass get request into urllib
81
84
 
82
85
        :returns: urllib Response object
87
90
        opener = urllib2.build_opener(auth_handler)
88
91
        request = Request(url)
89
92
        request.method = method
 
93
        if body is not None:
 
94
            request.add_data(body)
90
95
        request.add_header('Pragma', 'no-cache')
91
96
        request.add_header('Cache-control', 'max-age=0')
92
97
        request.add_header('User-Agent',
97
102
        response = opener.open(request)
98
103
        return response
99
104
 
 
105
    def _post(self, body_bytes):
 
106
        return self._request('.bzr/smart', 'POST', [], body=body_bytes)
 
107
 
100
108
    def should_cache(self):
101
109
        """Return True if the data pulled across should be cached locally.
102
110
        """