MCPcopy Index your code
hub / github.com/apache/dubbo-python2 / Response

Class Response

dubbo/codec/decoder.py:40–416  ·  view source on GitHub ↗

A class for parsing dubbo response body. All types can be parsed: * byte * boolean * int * long * double * string * object * class * generic type * list * map * date * null

Source from the content-addressed store, hash-verified

38
39
40class Response(object):
41 """
42 A class for parsing dubbo response body.
43 All types can be parsed:
44 * byte
45 * boolean
46 * int
47 * long
48 * double
49 * string
50 * object
51 * class
52 * generic type
53 * list
54 * map
55 * date
56 * null
57 """
58
59 def __init__(self, data):
60 self.__data = data # data是字节数组
61 self.__index = 0
62 self.types = []
63 self.objects = []
64 # 对于一个类来说,有path的地方就应该有field_name
65 self.paths = []
66 self.field_names = []
67
68 def get_byte(self):
69 """
70 获取到头部的字节数据,只是获取并不移动指针
71 :return:
72 """
73 return self.__data[self.__index]
74
75 def length(self):
76 """
77 当前的字节长度
78 :return:
79 """
80 return len(self.__data) - self.__index
81
82 def read_byte(self):
83 """
84 读取一个字节并向后移动一位指针
85 :return:
86 """
87 if self.__index >= len(self.__data):
88 raise ValueError('Index {} bigger than data length {}'.format(self.__index, len(self.__data)))
89 value = self.__data[self.__index]
90 self.__index += 1
91 return value
92
93 def read_bytes(self, num):
94 """
95 读取n个字节并向后移动n位指针
96 :param num:
97 :return:

Callers 2

_callbackMethod · 0.90
_parse_responseMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected