func()

in proxy/protocol/dubbo/dubbo/codec.go [364:395]


func (p *DubboCodec) DecodeDubboReqHead(req *Request, header []byte, bodyLen *int) int {
	if len(header) < HeaderLength {
		return NeedMore
	}
	//读取Magic
	if header[0] != MagicHigh || header[1] != MagicLow {
		return InvalidFragement
	}
	//读取请求ID
	var id = util.Bytes2long(header, 4)

	var flag = header[2]
	proto := byte(flag & SerializationMask)

	if proto != Hessian2 { //当前只支持hessian2编码
		return InvalidSerialization
	}

	if (flag & FlagRequest) == 0 {
		return InvalidFragement
	}
	req.SetMsgID(id)
	req.SetVersion(DubboVersion)
	req.SetTwoWay((flag & FlagTwoWay) != 0)
	if (flag & FlagEvent) != 0 {
		req.SetEvent(HeartBeatEvent)
	}
	//读取长度
	*bodyLen = int(util.Bytes2int(header, 12))

	return Success
}