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

Function parse_response_head

dubbo/codec/decoder.py:419–445  ·  view source on GitHub ↗

对响应头部的字节做解析 :param response_head: :return:

(response_head)

Source from the content-addressed store, hash-verified

417
418
419def parse_response_head(response_head):
420 """
421 对响应头部的字节做解析
422 :param response_head:
423 :return:
424 """
425 # Magic number
426 if not (response_head[0] == 0xda and response_head[1] == 0xbb):
427 raise DubboException('illegal response')
428
429 # 第三位为1表示这是一个心跳包
430 if response_head[2] & 0x20 == 0x20:
431 if response_head[2] & 0x80 == 0x80:
432 # 第一位为1,一个心跳请求的包
433 heartbeat = 2
434 else:
435 # 第一位为0,一个心跳响应的包
436 heartbeat = 1
437 response_status = response_head[3]
438 if response_status != 20:
439 raise DubboException(response_status_message[response_status])
440 else:
441 heartbeat = 0
442 response_status = response_head[3]
443 if response_status != 20:
444 raise DubboResponseException(response_status_message[response_status])
445 return heartbeat, unpack('!i', response_head[12:])[0]
446
447
448if __name__ == '__main__':

Callers 1

_parse_headMethod · 0.90

Calls 2

DubboExceptionClass · 0.90

Tested by

no test coverage detected