/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/__init__.py

Make HttpTransportBase.get_smart_client return self again.

Move HTTP smart client code into http.py from smart.py.

Show diffs side-by-side

added added

removed removed

Lines of Context:
245
245
        raise NotImplementedError(self._get)
246
246
 
247
247
    def get_request(self):
248
 
        return smart.SmartClientMediumRequest(self)
 
248
        return SmartClientHTTPMediumRequest(self)
249
249
 
250
250
    def get_smart_medium(self):
251
251
        """See Transport.get_smart_medium.
253
253
        HttpTransportBase directly implements the minimal interface of
254
254
        SmartMediumClient, so this returns self.
255
255
        """
256
 
        return smart.SmartClientHTTPMedium(self)
 
256
        return self
257
257
 
258
258
    def readv(self, relpath, offsets):
259
259
        """Get parts of the file at the given relative path.
414
414
 
415
415
        return ','.join(strings)
416
416
 
 
417
    def send_http_smart_request(self, bytes):
 
418
        code, body_filelike = self._post(bytes)
 
419
        assert code == 200, 'unexpected HTTP response code %r' % (code,)
 
420
        return body_filelike
 
421
 
 
422
 
 
423
class SmartClientHTTPMediumRequest(smart.SmartClientMediumRequest):
 
424
    """A SmartClientMediumRequest that works with an HTTP medium."""
 
425
 
 
426
    def __init__(self, medium):
 
427
        smart.SmartClientMediumRequest.__init__(self, medium)
 
428
        self._buffer = ''
 
429
 
 
430
    def _accept_bytes(self, bytes):
 
431
        self._buffer += bytes
 
432
 
 
433
    def _finished_writing(self):
 
434
        data = self._medium.send_http_smart_request(self._buffer)
 
435
        self._response_body = data
 
436
 
 
437
    def _read_bytes(self, count):
 
438
        return self._response_body.read(count)
 
439
        
 
440
    def _finished_reading(self):
 
441
        """See SmartClientMediumRequest._finished_reading."""
 
442
        pass
 
443
        
417
444
 
418
445
#---------------- test server facilities ----------------
419
446
# TODO: load these only when running tests