~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/message.py

  • Committer: Matt Nordhoff
  • Date: 2009-04-04 02:50:01 UTC
  • mfrom: (4253 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4256.
  • Revision ID: mnordhoff@mattnordhoff.com-20090404025001-z1403k0tatmc8l91
Merge bzr.dev, fixing conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
import collections
18
18
from cStringIO import StringIO
36
36
 
37
37
    def headers_received(self, headers):
38
38
        """Called when message headers are received.
39
 
        
 
39
 
40
40
        This default implementation just stores them in self.headers.
41
41
        """
42
42
        self.headers = headers
67
67
 
68
68
    def protocol_error(self, exception):
69
69
        """Called when there is a protocol decoding error.
70
 
        
 
70
 
71
71
        The default implementation just re-raises the exception.
72
72
        """
73
73
        raise
74
 
    
 
74
 
75
75
    def end_received(self):
76
76
        """Called when the end of the message is received."""
77
77
        # No-op by default.
172
172
 
173
173
    def read_response_tuple(self, expect_body=False):
174
174
        """Reads and returns the response tuple for the current request.
175
 
        
 
175
 
176
176
        :keyword expect_body: a boolean indicating if a body is expected in the
177
177
            response.  Some protocol versions needs this information to know
178
178
            when a response is finished.  If False, read_body_bytes should
283
283
                    self._protocol_decoder._get_in_buffer()[:10],
284
284
                    self._protocol_decoder.state_accept.__name__)
285
285
            raise errors.ConnectionReset(
286
 
                "please check connectivity and permissions",
287
 
                "(and try -Dhpss if further diagnosis is required)")
 
286
                "please check connectivity and permissions")
288
287
        self._protocol_decoder.accept_bytes(bytes)
289
288
 
290
289
    def protocol_error(self, exception):
292
291
        self.finished_reading = True
293
292
        self._medium_request.finished_reading()
294
293
        raise
295
 
        
 
294
 
296
295
    def read_response_tuple(self, expect_body=False):
297
296
        """Read a response tuple from the wire."""
298
297
        self._wait_for_response_args()
307
306
 
308
307
    def read_body_bytes(self, count=-1):
309
308
        """Read bytes from the body, decoding into a byte stream.
310
 
        
311
 
        We read all bytes at once to ensure we've checked the trailer for 
 
309
 
 
310
        We read all bytes at once to ensure we've checked the trailer for
312
311
        errors, and then feed the buffer back as read_body_bytes is called.
313
312
 
314
313
        Like the builtin file.read in Python, a count of -1 (the default) means