diff --git a/custom_parser.cpp b/custom_parser.cpp index 52959b9..ced2d3a 100644 --- a/custom_parser.cpp +++ b/custom_parser.cpp @@ -107,7 +107,7 @@ int custom_parser::on_message_complete(http_parser *parser) { if (gzip_decompress(self->response_body, new_body)) { self->response_body = new_body; } else { - std::cerr << ANSI_COLOR_RED << "uncompress error" << ANSI_COLOR_RESET << std::endl; + std::cerr << ANSI_COLOR_RED << "[decompress error]" << ANSI_COLOR_RESET << std::endl; } } return 0; @@ -153,7 +153,9 @@ std::ostream& operator<<(std::ostream& out, const custom_parser& parser) { << ANSI_COLOR_BLUE << parser.response_header << ANSI_COLOR_RESET; - if (!is_atty || is_plain_text(parser.response_body)) { + if (parser.response_body.empty()) { + out << ANSI_COLOR_RED << "[empty response body]" << ANSI_COLOR_RESET; + } else if (!is_atty || is_plain_text(parser.response_body)) { out << parser.response_body; } else { out << ANSI_COLOR_RED << "[binary response body]" << ANSI_COLOR_RESET; diff --git a/http_flow.cpp b/http_flow.cpp index 253fcea..1276b0b 100644 --- a/http_flow.cpp +++ b/http_flow.cpp @@ -76,7 +76,7 @@ static bool process_tcp(struct packet_info *packet, const u_char *content, size_ packet->src_addr.assign(buff); std::snprintf(buff, 128, "%s:%d", packet->dst_addr.c_str(), dst_port); packet->dst_addr.assign(buff); - packet->is_fin = !!(tcp_header->th_flags & TH_FIN); + packet->is_fin = !!(tcp_header->th_flags & (TH_FIN | TH_RST)); content += tcp_header_len; packet->body = std::string(reinterpret_cast(content), len - tcp_header_len); @@ -396,7 +396,7 @@ int main(int argc, char **argv) { datalink_id = pcap_datalink(handle); datalink_str = datalink2str(datalink_id); cap_conf->datalink_size = datalink2off(datalink_id); - std::cerr << "datalink: " << datalink_str << " header size: " << cap_conf->datalink_size << std::endl; + std::cerr << "datalink: " << datalink_id << "(" << datalink_str << ") header size: " << cap_conf->datalink_size << std::endl; if (-1 == pcap_loop(handle, -1, pcap_callback, reinterpret_cast(cap_conf))) { std::cerr << "pcap_loop(): " << pcap_geterr(handle) << std::endl;