| 225 | } |
| 226 | |
| 227 | static 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 | |
| 254 | static void AddGrpcPrefix(butil::IOBuf* body, bool compressed) { |
| 255 | char buf[5]; |
no test coverage detected