对所有的已知的参数根据dubbo协议进行编码 :return:
(self)
| 128 | raise HessianTypeError('Unknown argument type: {0}'.format(_class)) |
| 129 | |
| 130 | def _encode_request_body(self): |
| 131 | """ |
| 132 | 对所有的已知的参数根据dubbo协议进行编码 |
| 133 | :return: |
| 134 | """ |
| 135 | dubbo_version = self.__body['dubbo_version'] |
| 136 | path = self.__body['path'] |
| 137 | version = self.__body['version'] |
| 138 | method = self.__body['method'] |
| 139 | arguments = self.__body['arguments'] |
| 140 | |
| 141 | body = [] |
| 142 | body.extend(self._encode_single_value(dubbo_version)) |
| 143 | body.extend(self._encode_single_value(path)) |
| 144 | body.extend(self._encode_single_value(version)) |
| 145 | body.extend(self._encode_single_value(method)) |
| 146 | body.extend(self._encode_single_value(self._get_parameter_types(arguments))) |
| 147 | for argument in arguments: |
| 148 | body.extend(self._encode_single_value(argument)) |
| 149 | |
| 150 | attachments = { |
| 151 | 'path': path, |
| 152 | 'interface': path, |
| 153 | 'version': version |
| 154 | } |
| 155 | # attachments参数以H开头,以Z结尾 |
| 156 | body.append(ord('H')) |
| 157 | for key in attachments.keys(): |
| 158 | value = attachments[key] |
| 159 | body.extend(self._encode_single_value(key)) |
| 160 | body.extend(self._encode_single_value(value)) |
| 161 | body.append(ord('Z')) |
| 162 | |
| 163 | # 因为在上面的逻辑中没有对byte大小进行检测,所以在这里进行统一的处理 |
| 164 | for i in xrange(len(body)): |
| 165 | body[i] = body[i] & 0xff |
| 166 | return body |
| 167 | |
| 168 | @staticmethod |
| 169 | def _encode_bool(value): |
no test coverage detected