~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Vincent Ladeuil
  • Date: 2009-01-29 14:27:28 UTC
  • mto: (3982.1.1 bzr.integration)
  • mto: This revision was merged to the branch mainline in revision 3983.
  • Revision ID: v.ladeuil+lp@free.fr-20090129142728-1iu8017zgso23w0i
Start implementing http activity reporting at socket level.

* bzrlib/transport/http/_urllib2_wrappers.py:
(_ReportingFileSocket, _ReportingSocket): Wrappers for
socket._socket and socket_filesocket objects providing activity
reporting.
(Response.__init__): Deleted. Wrapping the file socket object is
now done handled at connection time.
(AbstractHTTPConnection._wrap_socket_for_reporting): Wrap the
underlying socket into a reporting one.
(HTTPConnection.__init__, HTTPSConnection.__init__): Accept a
report_activity parameter.
(HTTPSConnection.connect): Wrap the newly created socket.
(HTTPSConnection.connect_to_origin): Wrap the newly created *or*
connected ssl socket.
(ConnectionHandler.__init__): Accept a report_activity parameter.
(ConnectionHandler.create_connection): Pass the report_activity
parameter to all created connections.
(Opener.__init__): Accept a report_activity parameter.

* bzrlib/transport/http/_urllib.py:
(HttpTransport_urllib.__init__): Provide the report activity
function to the opener.
(HttpTransport_urllib._get, HttpTransport_urllib._post): Don't use
the RangeFile report activity facility anymore.

* bzrlib/transport/http/__init__.py:
(HttpTransportBase.get_bytes): Deleted, this gratuitously add a
useless level of buffering.

* bzrlib/tests/test_http.py:
(ActivityHttpServer, PreRecoredRequestHandler, TestActivity): Test
activity reporting by http clients.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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.
100
101
 
101
102
    def _get(self, relpath, offsets, tail_amount=0):
102
103
        """See HttpTransport._get"""
103
 
 
104
104
        abspath = self._remote_path(relpath)
105
105
        headers = {}
106
106
        accepted_errors = [200, 404]
126
126
            raise errors.InvalidHttpRange(abspath, range_header,
127
127
                                          'Server return code %d' % code)
128
128
 
129
 
        data = handle_response(abspath, code, response.info(), response,
130
 
            report_activity=self._report_activity)
 
129
        data = handle_response(abspath, code, response.info(), response)
131
130
        return code, data
132
131
 
133
132
    def _post(self, body_bytes):
137
136
        response = self._perform(Request('POST', abspath, body_bytes,
138
137
                                         accepted_errors=[200, 403]))
139
138
        code = response.code
140
 
        data = handle_response(abspath, code, response.info(), response,
141
 
            report_activity=self._report_activity)
 
139
        data = handle_response(abspath, code, response.info(), response)
142
140
        return code, data
143
141
 
144
142
    def _head(self, relpath):