~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/client.py

  • Committer: Martin Pool
  • Date: 2009-01-13 03:11:04 UTC
  • mto: This revision was merged to the branch mainline in revision 3937.
  • Revision ID: mbp@sourcefrog.net-20090113031104-03my054s02i9l2pe
Bump version to 1.12 and add news template

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
            self._headers = dict(headers)
38
38
 
39
39
    def _send_request(self, protocol_version, method, args, body=None,
40
 
                      readv_body=None, body_stream=None):
 
40
                      readv_body=None):
41
41
        encoder, response_handler = self._construct_protocol(
42
42
            protocol_version)
43
43
        encoder.set_headers(self._headers)
45
45
            if readv_body is not None:
46
46
                raise AssertionError(
47
47
                    "body and readv_body are mutually exclusive.")
48
 
            if body_stream is not None:
49
 
                raise AssertionError(
50
 
                    "body and body_stream are mutually exclusive.")
51
48
            encoder.call_with_body_bytes((method, ) + args, body)
52
49
        elif readv_body is not None:
53
 
            if body_stream is not None:
54
 
                raise AssertionError(
55
 
                    "readv_body and body_stream are mutually exclusive.")
56
 
            encoder.call_with_body_readv_array((method, ) + args, readv_body)
57
 
        elif body_stream is not None:
58
 
            encoder.call_with_body_stream((method, ) + args, body_stream)
 
50
            encoder.call_with_body_readv_array((method, ) + args,
 
51
                    readv_body)
59
52
        else:
60
53
            encoder.call(method, *args)
61
54
        return response_handler
68
61
            hook(params)
69
62
            
70
63
    def _call_and_read_response(self, method, args, body=None, readv_body=None,
71
 
            body_stream=None, expect_response_body=True):
 
64
            expect_response_body=True):
72
65
        self._run_call_hooks(method, args, body, readv_body)
73
66
        if self._medium._protocol_version is not None:
74
67
            response_handler = self._send_request(
75
68
                self._medium._protocol_version, method, args, body=body,
76
 
                readv_body=readv_body, body_stream=body_stream)
 
69
                readv_body=readv_body)
77
70
            return (response_handler.read_response_tuple(
78
71
                        expect_body=expect_response_body),
79
72
                    response_handler)
84
77
                    self._medium._remember_remote_is_before((1, 6))
85
78
                response_handler = self._send_request(
86
79
                    protocol_version, method, args, body=body,
87
 
                    readv_body=readv_body, body_stream=body_stream)
 
80
                    readv_body=readv_body)
88
81
                try:
89
82
                    response_tuple = response_handler.read_response_tuple(
90
83
                        expect_body=expect_response_body)
172
165
                args[0], args[1:], readv_body=body, expect_response_body=True)
173
166
        return (response, response_handler)
174
167
 
175
 
    def call_with_body_stream(self, args, stream):
176
 
        response, response_handler = self._call_and_read_response(
177
 
                args[0], args[1:], body_stream=stream,
178
 
                expect_response_body=False)
179
 
        return (response, response_handler)
180
 
 
181
168
    def remote_path_from_transport(self, transport):
182
169
        """Convert transport into a path suitable for using in a request.
183
170