~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/protocol.py

  • Committer: Andrew Bennetts
  • Date: 2008-07-28 06:53:44 UTC
  • mfrom: (3581 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3583.
  • Revision ID: andrew.bennetts@canonical.com-20080728065344-ocndjoycs903q6fz
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
698
698
            return self._body_buffer.read(count)
699
699
        _body_decoder = LengthPrefixedBodyDecoder()
700
700
 
701
 
        # Read no more than 64k at a time so that we don't risk error 10055 (no
702
 
        # buffer space available) on Windows.
703
 
        max_read = 64 * 1024
704
701
        while not _body_decoder.finished_reading:
705
 
            bytes_wanted = min(_body_decoder.next_read_size(), max_read)
706
 
            bytes = self._request.read_bytes(bytes_wanted)
 
702
            bytes = self._request.read_bytes(_body_decoder.next_read_size())
707
703
            if bytes == '':
708
704
                # end of file encountered reading from server
709
705
                raise errors.ConnectionReset(
719
715
 
720
716
    def _recv_tuple(self):
721
717
        """Receive a tuple from the medium request."""
722
 
        return _decode_tuple(self._recv_line())
723
 
 
724
 
    def _recv_line(self):
725
 
        """Read an entire line from the medium request."""
726
 
        line = ''
727
 
        while not line or line[-1] != '\n':
728
 
            # TODO: this is inefficient - but tuples are short.
729
 
            new_char = self._request.read_bytes(1)
730
 
            if new_char == '':
731
 
                # end of file encountered reading from server
732
 
                raise errors.ConnectionReset(
733
 
                    "please check connectivity and permissions",
734
 
                    "(and try -Dhpss if further diagnosis is required)")
735
 
            line += new_char
736
 
        return line
 
718
        return _decode_tuple(self._request.read_line())
737
719
 
738
720
    def query_version(self):
739
721
        """Return protocol version number of the server."""
776
758
        if version != self.response_marker:
777
759
            self._request.finished_reading()
778
760
            raise errors.UnexpectedProtocolVersionMarker(version)
779
 
        response_status = self._recv_line()
 
761
        response_status = self._request.read_line()
780
762
        result = SmartClientRequestProtocolOne._read_response_tuple(self)
781
763
        self._response_is_unknown_method(result)
782
764
        if response_status == 'success\n':
804
786
        """
805
787
        # Read no more than 64k at a time so that we don't risk error 10055 (no
806
788
        # buffer space available) on Windows.
807
 
        max_read = 64 * 1024
808
789
        _body_decoder = ChunkedBodyDecoder()
809
790
        while not _body_decoder.finished_reading:
810
 
            bytes_wanted = min(_body_decoder.next_read_size(), max_read)
811
 
            bytes = self._request.read_bytes(bytes_wanted)
 
791
            bytes = self._request.read_bytes(_body_decoder.next_read_size())
812
792
            if bytes == '':
813
793
                # end of file encountered reading from server
814
794
                raise errors.ConnectionReset(