MCPcopy Create free account
hub / github.com/apache/brpc / PrintMessage

Function PrintMessage

src/brpc/policy/http_rpc_protocol.cpp:227–252  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

225}
226
227static void PrintMessage(const butil::IOBuf& inbuf,
228 bool request_or_response,
229 bool has_content) {
230 butil::IOBuf buf1 = inbuf;
231 butil::IOBuf buf2;
232 char str[48];
233 if (request_or_response) {
234 snprintf(str, sizeof(str), "[ HTTP REQUEST @%s ]", butil::my_ip_cstr());
235 } else {
236 snprintf(str, sizeof(str), "[ HTTP RESPONSE @%s ]", butil::my_ip_cstr());
237 }
238 buf2.append(str);
239 size_t last_size;
240 do {
241 buf2.append("\r\n> ");
242 last_size = buf2.size();
243 } while (buf1.cut_until(&buf2, "\r\n") == 0);
244 if (buf2.size() == last_size) {
245 buf2.pop_back(2); // remove "> "
246 }
247 if (!has_content) {
248 LOG(INFO) << '\n' << buf2 << buf1;
249 } else {
250 LOG(INFO) << '\n' << buf2 << butil::ToPrintableString(buf1, FLAGS_http_verbose_max_body_length);
251 }
252}
253
254static void AddGrpcPrefix(butil::IOBuf* body, bool compressed) {
255 char buf[5];

Callers 2

PackHttpRequestFunction · 0.85
~HttpResponseSenderMethod · 0.85

Calls 7

snprintfFunction · 0.85
my_ip_cstrFunction · 0.85
ToPrintableStringFunction · 0.85
cut_untilMethod · 0.80
appendMethod · 0.45
sizeMethod · 0.45
pop_backMethod · 0.45

Tested by

no test coverage detected