Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,11 @@ bool DubboProtocolImpl::encode(Buffer::Instance& buffer, const MessageMetadata&
buffer.writeByte(flag);
buffer.writeByte(static_cast<uint8_t>(metadata.responseStatus()));
buffer.writeBEInt<uint64_t>(metadata.requestId());
buffer.writeBEInt<uint32_t>(0);
// Body of heart beat response is null.
// TODO(wbpcode): Currently we only support the Hessian2 serialization scheme, so here we
// directly use the 'N' for null object in Hessian2. This coupling should be unnecessary.
buffer.writeBEInt<uint32_t>(1u);
buffer.writeByte('N');
return true;
}
case MessageType::Response: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,21 @@ TEST(DubboProtocolImplTest, encode) {
EXPECT_TRUE(dubbo_protocol.decodeData(buffer, context, output_metadata));
}

TEST(DubboProtocolImplTest, HeartBeatResponseTest) {
MessageMetadata metadata;
metadata.setMessageType(MessageType::HeartbeatResponse);
metadata.setResponseStatus(ResponseStatus::Ok);
metadata.setSerializationType(SerializationType::Hessian2);
metadata.setRequestId(100);

Buffer::OwnedImpl buffer;
DubboProtocolImpl dubbo_protocol;
dubbo_protocol.initSerializer(SerializationType::Hessian2);
EXPECT_TRUE(dubbo_protocol.encode(buffer, metadata, "", RpcResponseType::ResponseWithValue));
// 16 bytes header and one byte null object body.
EXPECT_EQ(17, buffer.length());
}

TEST(DubboProtocolImplTest, decode) {
Buffer::OwnedImpl buffer;
MessageMetadataSharedPtr metadata;
Expand Down