| 70 | } |
| 71 | |
| 72 | void NsheadMcpackAdaptor::SerializeResponseToIOBuf( |
| 73 | const NsheadMeta&, Controller* cntl, |
| 74 | const google::protobuf::Message* pb_res, NsheadMessage* raw_res) const { |
| 75 | if (cntl->Failed()) { |
| 76 | cntl->CloseConnection("Close connection due to previous error"); |
| 77 | return; |
| 78 | } |
| 79 | CompressType type = cntl->response_compress_type(); |
| 80 | if (type != COMPRESS_TYPE_NONE) { |
| 81 | LOG(WARNING) << "nshead_mcpack protocol doesn't support compression"; |
| 82 | type = COMPRESS_TYPE_NONE; |
| 83 | } |
| 84 | |
| 85 | if (pb_res == NULL) { |
| 86 | cntl->CloseConnection("response was not created yet"); |
| 87 | return; |
| 88 | } |
| 89 | |
| 90 | const std::string msg_name = butil::EnsureString(pb_res->GetDescriptor()->full_name()); |
| 91 | mcpack2pb::MessageHandler handler = mcpack2pb::find_message_handler(msg_name); |
| 92 | if (!handler.serialize_to_iobuf(*pb_res, &raw_res->body, |
| 93 | ::mcpack2pb::FORMAT_MCPACK_V2)) { |
| 94 | cntl->CloseConnection("Fail to serialize %s", msg_name.c_str()); |
| 95 | return; |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | void ProcessNsheadMcpackResponse(InputMessageBase* msg_base) { |
| 100 | const int64_t start_parse_us = butil::cpuwide_time_us(); |
nothing calls this directly
no test coverage detected