Commit de323bde authored by zyearn's avatar zyearn Committed by zhujiashun

* Add Trailers-Only Support in Response

* Add grpc-message
parent 4c50ffb4
......@@ -1716,8 +1716,8 @@ H2UnsentResponse::AppendAndDestroySelf(butil::IOBuf* out, Socket* socket) {
// TODO(zhujiashun): how to decide status code and status message
HPacker::Header status("grpc-status", "0");
hpacker.Encode(&trailer_appender, status, options);
//HPacker::Header message("grpc-message", "");
//hpacker.Encode(&trailer_appender, message, options);
HPacker::Header message("grpc-message", "");
hpacker.Encode(&trailer_appender, message, options);
trailer_appender.move_to(trailer_frag);
}
......
......@@ -270,13 +270,15 @@ void ProcessHttpResponse(InputMessageBase* msg) {
// TODO(zhujiashun): handle compression
char compressed_grpc = false;
if (ParseContentType(res_header->content_type()) == HTTP_CONTENT_GRPC) {
if (ParseContentType(res_header->content_type()) == HTTP_CONTENT_GRPC &&
!res_body.empty()) {
/* 4 is the size of grpc Message-Length in Length-Prefixed-Message*/
char buf[4];
res_body.cut1(&compressed_grpc);
res_body.cutn(buf, 4);
int message_length = ReadBigEndian4Bytes(buf);
CHECK(message_length == res_body.length());
CHECK(message_length == res_body.length()) << message_length
<< " vs " << res_body.length();
}
do {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment