diff options
| author | liuwentan <[email protected]> | 2024-01-10 11:43:15 +0800 |
|---|---|---|
| committer | liuwentan <[email protected]> | 2024-01-16 15:19:01 +0800 |
| commit | dceaf90cec5f1691d8d5e83fa219a31f42c2faa0 (patch) | |
| tree | 051edf2e9beb47270fff11653b12aa046ffabf06 | |
| parent | 3761b190f045f9005e78c5166b1e7b8d47bc51a0 (diff) | |
[HTTP_DECODER]bugfix for http transaction pipeline
| -rw-r--r-- | src/http_decoder/http_decoder.c | 109 | ||||
| -rw-r--r-- | src/http_decoder/http_decoder_half.c | 198 | ||||
| -rw-r--r-- | src/http_decoder/http_decoder_half.h | 4 | ||||
| -rw-r--r-- | src/http_decoder/http_decoder_table.c | 26 | ||||
| -rw-r--r-- | test/http_decoder/CMakeLists.txt | 12 | ||||
| -rw-r--r-- | test/http_decoder/http_pcap/http_trans_pipeline.pcap | bin | 0 -> 6832 bytes | |||
| -rw-r--r-- | test/http_decoder/test_result_json/http_trans_pipeline.json | 348 |
7 files changed, 488 insertions, 209 deletions
diff --git a/src/http_decoder/http_decoder.c b/src/http_decoder/http_decoder.c index 1aab5ce..e2c2d2f 100644 --- a/src/http_decoder/http_decoder.c +++ b/src/http_decoder/http_decoder.c @@ -132,8 +132,15 @@ http_decoder_result_queue_pop(struct http_decoder_result_queue *queue, assert(index < queue->queue_size); if (queue->array[index] != NULL) { - http_decoder_result_free(queue->array[index]); - queue->array[index] = NULL; + if (queue->array[index]->req_data != NULL) { + http_decoder_half_data_free(queue->array[index]->req_data); + queue->array[index]->req_data = NULL; + } + + if (queue->array[index]->res_data != NULL) { + http_decoder_half_data_free(queue->array[index]->res_data); + queue->array[index]->res_data = NULL; + } } } @@ -198,8 +205,6 @@ http_event_handler(enum http_event event, struct http_decoder_half_data **data, msg->data = *data; session_mq_publish_message(ctx->ref_session, ctx->topic_id, msg); break; - case HTTP_EVENT_REQ_HDR: - break; case HTTP_EVENT_REQ_HDR_END: msg = CALLOC(struct http_message, 1); msg->type = HTTP_MESSAGE_REQ_HEADER; @@ -264,8 +269,8 @@ http_decoder_new(http_event_cb *ev_cb, int is_cache_body) struct http_decoder *decoder = CALLOC(struct http_decoder, 1); assert(decoder); - decoder->c2s_half = http_decoder_half_new(ev_cb, is_cache_body); - decoder->s2c_half = http_decoder_half_new(ev_cb, is_cache_body); + decoder->c2s_half = http_decoder_half_new(ev_cb, is_cache_body, HTTP_REQUEST); + decoder->s2c_half = http_decoder_half_new(ev_cb, is_cache_body, HTTP_RESPONSE); return decoder; } @@ -377,7 +382,7 @@ int http_decoder_entry(struct session *sess, int events, const char *payload = session_get0_current_payload(sess, &payload_len); // printf("session:%s\n", session_get0_readable_addr(sess)); - + //printf("%s\n", payload); if (events & SESS_EV_OPENING) { if (queue != NULL) { fprintf(stderr, @@ -410,8 +415,6 @@ int http_decoder_entry(struct session *sess, int events, return 0; } - - int dir = packet_get_direction(pkt); if (dir < 0) { return -1; @@ -434,14 +437,14 @@ int http_decoder_entry(struct session *sess, int events, http_decoder_half_parse(cur_half, ctx->http_ev_ctx, payload, payload_len); - long long trans_cnt = http_decoder_half_trans_count(cur_half); + // long long trans_cnt = http_decoder_half_trans_count(cur_half); - fieldstat_easy_counter_incrby(ctx->fse, 0, ctx->fs_incoming_bytes_id, - NULL, 0, payload_len); - fieldstat_easy_counter_incrby(ctx->fse, 0, ctx->fs_incoming_pkts_id, - NULL, 0, 1); - fieldstat_easy_counter_incrby(ctx->fse, 0, ctx->fs_incoming_trans_id, - NULL, 0, trans_cnt); + // fieldstat_easy_counter_incrby(ctx->fse, 0, ctx->fs_incoming_bytes_id, + // NULL, 0, payload_len); + // fieldstat_easy_counter_incrby(ctx->fse, 0, ctx->fs_incoming_pkts_id, + // NULL, 0, 1); + // fieldstat_easy_counter_incrby(ctx->fse, 0, ctx->fs_incoming_trans_id, + // NULL, 0, trans_cnt); return 0; } @@ -520,49 +523,49 @@ void *http_decoder_init(struct stellar *st) } ctx->topic_id = topic_id; - ctx->fse = fieldstat_easy_new(1, "http_decoder_statistics", NULL, 0); - if (NULL == ctx->fse) { - fprintf(stderr, "fieldstat_easy_new failed."); - goto failed; - } - - ctx->fs_incoming_bytes_id = - fieldstat_easy_register_counter(ctx->fse, "incoming_bytes"); - if (ctx->fs_incoming_bytes_id < 0) { - fprintf(stderr, "fieldstat_easy_register_counter incoming_bytes failed."); - goto failed; - } - - ctx->fs_incoming_trans_id = - fieldstat_easy_register_counter(ctx->fse, "incoming_trans"); - if (ctx->fs_incoming_trans_id < 0) { - fprintf(stderr, "fieldstat_easy_register_counter incoming_trans failed."); - goto failed; - } - - ctx->fs_incoming_pkts_id = - fieldstat_easy_register_counter(ctx->fse, "incoming_pkts"); - if (ctx->fs_incoming_pkts_id < 0) { - fprintf(stderr, "fieldstat_easy_register_counter incoming_pkts failed."); - goto failed; - } - - int ret = fieldstat_easy_enable_auto_output(ctx->fse, fs_file_name, - FS_OUTPUT_INTERVAL_S); - if (ret < 0) { - fprintf(stderr, "fieldstat_easy_enable_auto_output failed."); - goto failed; - } - sleep(3); + // ctx->fse = fieldstat_easy_new(1, "http_decoder_statistics", NULL, 0); + // if (NULL == ctx->fse) { + // fprintf(stderr, "fieldstat_easy_new failed."); + // goto failed; + // } + + // ctx->fs_incoming_bytes_id = + // fieldstat_easy_register_counter(ctx->fse, "incoming_bytes"); + // if (ctx->fs_incoming_bytes_id < 0) { + // fprintf(stderr, "fieldstat_easy_register_counter incoming_bytes failed."); + // goto failed; + // } + + // ctx->fs_incoming_trans_id = + // fieldstat_easy_register_counter(ctx->fse, "incoming_trans"); + // if (ctx->fs_incoming_trans_id < 0) { + // fprintf(stderr, "fieldstat_easy_register_counter incoming_trans failed."); + // goto failed; + // } + + // ctx->fs_incoming_pkts_id = + // fieldstat_easy_register_counter(ctx->fse, "incoming_pkts"); + // if (ctx->fs_incoming_pkts_id < 0) { + // fprintf(stderr, "fieldstat_easy_register_counter incoming_pkts failed."); + // goto failed; + // } + + // int ret = fieldstat_easy_enable_auto_output(ctx->fse, fs_file_name, + // FS_OUTPUT_INTERVAL_S); + // if (ret < 0) { + // fprintf(stderr, "fieldstat_easy_enable_auto_output failed."); + // goto failed; + // } + // sleep(3); printf("http_decoder_init: ex_data_idx:%d, plugin_id:%d, topic_id:%d\n", ctx->ex_data_idx, ctx->plugin_id, ctx->topic_id); return ctx; -failed: - _http_decoder_context_free(ctx); - return NULL; +// failed: +// _http_decoder_context_free(ctx); +// return NULL; } void http_decoder_exit(void *decoder_ctx) diff --git a/src/http_decoder/http_decoder_half.c b/src/http_decoder/http_decoder_half.c index a122cf4..af77f0a 100644 --- a/src/http_decoder/http_decoder_half.c +++ b/src/http_decoder/http_decoder_half.c @@ -46,7 +46,7 @@ struct http_decoder_half { long long trans_counter; }; -// #define HTTP_DECODER_DEBUG +//#define HTTP_DECODER_DEBUG #ifdef HTTP_DECODER_DEBUG static void printf_debug_info(const char *desc, const char *at, size_t length) { @@ -104,8 +104,17 @@ on_message_begin(llhttp_t *http) container_of(http, struct http_decoder_half, parser); assert(half); - half->event = HTTP_EVENT_INIT; + if (half->parser.type == HTTP_REQUEST) { + half->event = HTTP_EVENT_REQ_INIT; + } else { + half->event = HTTP_EVENT_RES_INIT; + } + half->ref_data = NULL; + + assert(half->http_ev_cb != NULL); + half->http_ev_cb(half->event, &half->ref_data, half->http_ev_ctx); + half->trans_counter++; return 0; @@ -209,26 +218,12 @@ on_method(llhttp_t *http, const char *at, size_t length) { printf_debug_info("on_method", at, length); - if (0 == length) { - return 0; - } - struct http_decoder_half *half = container_of(http, struct http_decoder_half, parser); assert(half); - if (half->parser.type == HTTP_REQUEST) { - if (half->event == HTTP_EVENT_INIT) { - half->event = HTTP_EVENT_REQ_INIT; - half->http_ev_cb(half->event, &half->ref_data, half->http_ev_ctx); - } - } - - if (half->ref_data != NULL) { - http_decoder_table_refer(half->ref_data->table, HTTP_ITEM_METHOD, - at, length); - } - + http_decoder_table_refer(half->ref_data->table, HTTP_ITEM_METHOD, + at, length); return 0; } @@ -242,13 +237,7 @@ on_method_complete(llhttp_t *http) container_of(http, struct http_decoder_half, parser); assert(half); - if (half->ref_data != NULL) { - if (http_decoder_table_state(half->ref_data->table, HTTP_ITEM_METHOD) - == STRING_STATE_REFER) { - http_decoder_table_cache(half->ref_data->table, HTTP_ITEM_METHOD); - } - http_decoder_table_commit(half->ref_data->table, HTTP_ITEM_METHOD); - } + http_decoder_table_commit(half->ref_data->table, HTTP_ITEM_METHOD); return 0; } @@ -259,19 +248,12 @@ on_uri(llhttp_t *http, const char *at, size_t length) { printf_debug_info("on_uri", at, length); - if (0 == length) { - return 0; - } - struct http_decoder_half *half = container_of(http, struct http_decoder_half, parser); assert(half); - if (half->ref_data != NULL) { - http_decoder_table_refer(half->ref_data->table, HTTP_ITEM_URI, - at, length); - } - + http_decoder_table_refer(half->ref_data->table, HTTP_ITEM_URI, + at, length); return 0; } @@ -285,14 +267,7 @@ on_uri_complete(llhttp_t *http) container_of(http, struct http_decoder_half, parser); assert(half); - if (half->ref_data != NULL) { - if (http_decoder_table_state(half->ref_data->table, HTTP_ITEM_URI) - == STRING_STATE_REFER) { - http_decoder_table_cache(half->ref_data->table, HTTP_ITEM_URI); - } - - http_decoder_table_commit(half->ref_data->table, HTTP_ITEM_URI); - } + http_decoder_table_commit(half->ref_data->table, HTTP_ITEM_URI); return 0; } @@ -303,26 +278,12 @@ on_version(llhttp_t *http, const char *at, size_t length) { printf_debug_info("on_version", at, length); - if (0 == length) { - return 0; - } - struct http_decoder_half *half = container_of(http, struct http_decoder_half, parser); assert(half); - if (half->parser.type == HTTP_RESPONSE) { - if (half->event == HTTP_EVENT_INIT) { - half->event = HTTP_EVENT_RES_INIT; - half->http_ev_cb(half->event, &half->ref_data, half->http_ev_ctx); - } - } - - if (half->ref_data != NULL) { - http_decoder_table_refer(half->ref_data->table, HTTP_ITEM_VERSION, - at, length); - } - + http_decoder_table_refer(half->ref_data->table, HTTP_ITEM_VERSION, + at, length); return 0; } @@ -336,16 +297,10 @@ on_version_complete(llhttp_t *http) container_of(http, struct http_decoder_half, parser); assert(half); - if (half->ref_data) { - if (http_decoder_table_state(half->ref_data->table, HTTP_ITEM_VERSION) - == STRING_STATE_REFER) { - http_decoder_table_cache(half->ref_data->table, HTTP_ITEM_VERSION); - } - http_decoder_table_commit(half->ref_data->table, HTTP_ITEM_VERSION); + http_decoder_table_commit(half->ref_data->table, HTTP_ITEM_VERSION); - half->ref_data->major_version = llhttp_get_http_major(&half->parser); - half->ref_data->minor_version = llhttp_get_http_minor(&half->parser); - } + half->ref_data->major_version = llhttp_get_http_major(&half->parser); + half->ref_data->minor_version = llhttp_get_http_minor(&half->parser); if (half->parser.type == HTTP_REQUEST) { half->event = HTTP_EVENT_REQ_LINE; @@ -363,19 +318,12 @@ on_status(llhttp_t *http, const char *at, size_t length) { printf_debug_info("on_status", at, length); - if (0 == length) { - return 0; - } - struct http_decoder_half *half = container_of(http, struct http_decoder_half, parser); assert(half); - if (half->ref_data != NULL) { - http_decoder_table_refer(half->ref_data->table, HTTP_ITEM_STATUS, - at, length); - } - + http_decoder_table_refer(half->ref_data->table, HTTP_ITEM_STATUS, + at, length); return 0; } @@ -389,15 +337,8 @@ on_status_complete(llhttp_t *http) container_of(http, struct http_decoder_half, parser); assert(half); - if (half->ref_data != NULL) { - if (http_decoder_table_state(half->ref_data->table, HTTP_ITEM_STATUS) - == STRING_STATE_REFER) { - http_decoder_table_cache(half->ref_data->table, HTTP_ITEM_STATUS); - } - - http_decoder_table_commit(half->ref_data->table, HTTP_ITEM_STATUS); - half->ref_data->status_code = llhttp_get_status_code(&half->parser); - } + http_decoder_table_commit(half->ref_data->table, HTTP_ITEM_STATUS); + half->ref_data->status_code = llhttp_get_status_code(&half->parser); half->event = HTTP_EVENT_RES_LINE; if (half->http_ev_cb != NULL) { @@ -411,21 +352,14 @@ on_status_complete(llhttp_t *http) static int on_header_field(llhttp_t *http, const char *at, size_t length) { - if (0 == length) { - return 0; - } - printf_debug_info("on_header_field", at, length); struct http_decoder_half *half = container_of(http, struct http_decoder_half, parser); assert(half); - if (half->ref_data != NULL) { - http_decoder_table_refer(half->ref_data->table, HTTP_ITEM_HDRKEY, - at, length); - } - + http_decoder_table_refer(half->ref_data->table, HTTP_ITEM_HDRKEY, + at, length); return 0; } @@ -439,15 +373,13 @@ on_header_field_complete(llhttp_t *http) container_of(http, struct http_decoder_half, parser); assert(half); - if (half->ref_data != NULL) { - if (http_decoder_table_state(half->ref_data->table, HTTP_ITEM_HDRKEY) - == STRING_STATE_REFER) { - http_decoder_table_cache(half->ref_data->table, HTTP_ITEM_HDRKEY); - } - - http_decoder_table_commit(half->ref_data->table, HTTP_ITEM_HDRKEY); + if (http_decoder_table_state(half->ref_data->table, HTTP_ITEM_HDRKEY) == + STRING_STATE_REFER) { + http_decoder_table_cache(half->ref_data->table, HTTP_ITEM_HDRKEY); } + http_decoder_table_commit(half->ref_data->table, HTTP_ITEM_HDRKEY); + return 0; } @@ -455,21 +387,14 @@ on_header_field_complete(llhttp_t *http) static int on_header_value(llhttp_t *http, const char *at, size_t length) { - if (0 == length) { - return 0; - } - printf_debug_info("on_header_value", at, length); struct http_decoder_half *half = container_of(http, struct http_decoder_half, parser); assert(half); - if (half->ref_data != NULL) { - http_decoder_table_refer(half->ref_data->table, HTTP_ITEM_HDRVAL, - at, length); - } - + http_decoder_table_refer(half->ref_data->table, HTTP_ITEM_HDRVAL, + at, length); return 0; } @@ -483,29 +408,22 @@ on_header_value_complete(llhttp_t *http) container_of(http, struct http_decoder_half, parser); assert(half); - if (half->ref_data != NULL) { - if (http_decoder_table_state(half->ref_data->table, HTTP_ITEM_HDRVAL) - == STRING_STATE_REFER) { - http_decoder_table_cache(half->ref_data->table, HTTP_ITEM_HDRVAL); - } - http_decoder_table_commit(half->ref_data->table, HTTP_ITEM_HDRVAL); + if (http_decoder_table_state(half->ref_data->table, HTTP_ITEM_HDRVAL) == + STRING_STATE_REFER) { + http_decoder_table_cache(half->ref_data->table, HTTP_ITEM_HDRVAL); } + http_decoder_table_commit(half->ref_data->table, HTTP_ITEM_HDRVAL); - if (half->ref_data != NULL) { - if (half->ref_data->content_encoding == HTTP_CONTENT_ENCODING_NONE) { - struct http_header http_hdr = {0}; - struct hstring key = { - .str = (char *)"Content-Encoding", - .str_len = 16 - }; - - if (http_decoder_table_get_header(half->ref_data->table, &key, - &http_hdr, 1) == 1) { - char *str = safe_dup(http_hdr.val.str, http_hdr.val.str_len); - half->ref_data->content_encoding = - http_content_encoding_str2int(str); - FREE(str); - } + if (half->ref_data->content_encoding == HTTP_CONTENT_ENCODING_NONE) { + struct http_header http_hdr = {0}; + struct hstring key = {.str = (char *)"Content-Encoding", .str_len = 16}; + + if (http_decoder_table_get_header(half->ref_data->table, &key, + &http_hdr, 1) == 1) { + char *str = safe_dup(http_hdr.val.str, http_hdr.val.str_len); + half->ref_data->content_encoding = + http_content_encoding_str2int(str); + FREE(str); } } @@ -572,10 +490,6 @@ on_headers_complete(llhttp_t *http) static int on_body(llhttp_t *http, const char *at, size_t length) { - if (0 == length) { - return 0; - } - printf_debug_info("on_body", at, length); struct http_decoder_half *half = @@ -638,16 +552,16 @@ on_body(llhttp_t *http, const char *at, size_t length) return 0; } -void +static void http_decoder_half_init(struct http_decoder_half *half, - http_event_cb *http_ev_cb, int is_cache_body) + http_event_cb *http_ev_cb, int is_cache_body, int type) { if (NULL == half) { return; } llhttp_settings_init(&half->settings); - llhttp_init(&half->parser, HTTP_BOTH, &half->settings); + llhttp_init(&half->parser, type, &half->settings); half->settings.on_message_begin = on_message_begin; half->settings.on_message_complete = on_message_complete; @@ -686,12 +600,12 @@ http_decoder_half_init(struct http_decoder_half *half, } struct http_decoder_half * -http_decoder_half_new(http_event_cb *ev_cb, int is_cache_body) +http_decoder_half_new(http_event_cb *ev_cb, int is_cache_body, int type) { struct http_decoder_half *half = CALLOC(struct http_decoder_half, 1); assert(half); - http_decoder_half_init(half, ev_cb, is_cache_body); + http_decoder_half_init(half, ev_cb, is_cache_body, type); return half; } @@ -717,6 +631,7 @@ http_decoder_half_parse(struct http_decoder_half *half, void *http_ev_ctx, half->error = llhttp_execute(&half->parser, data, data_len); int ret = 0; + uint8_t type = 0; switch (half->error) { case HPE_OK: @@ -729,7 +644,8 @@ http_decoder_half_parse(struct http_decoder_half *half, void *http_ev_ctx, ret = 0; break; default: - llhttp_init(&half->parser, HTTP_BOTH, &half->settings); + type = half->parser.type; + llhttp_init(&half->parser, type, &half->settings); ret = -1; break; } diff --git a/src/http_decoder/http_decoder_half.h b/src/http_decoder/http_decoder_half.h index 327a3fa..222d040 100644 --- a/src/http_decoder/http_decoder_half.h +++ b/src/http_decoder/http_decoder_half.h @@ -25,8 +25,6 @@ extern "C" // only one http event is fired at a time enum http_event { - HTTP_EVENT_INIT = 0, - HTTP_EVENT_REQ_INIT = 1 << 1, HTTP_EVENT_REQ_LINE = 1 << 2, HTTP_EVENT_REQ_HDR = 1 << 3, @@ -53,7 +51,7 @@ typedef void http_event_cb(enum http_event event, struct http_decoder_half_data **data, void *cb_args); struct http_decoder_half * -http_decoder_half_new(http_event_cb *event_cb, int is_cache_body); +http_decoder_half_new(http_event_cb *event_cb, int is_cache_body, int type); void http_decoder_half_free(struct http_decoder_half *half); diff --git a/src/http_decoder/http_decoder_table.c b/src/http_decoder/http_decoder_table.c index 4867125..8151e5c 100644 --- a/src/http_decoder/http_decoder_table.c +++ b/src/http_decoder/http_decoder_table.c @@ -324,8 +324,12 @@ http_decoder_table_dump(struct http_decoder_table *table) http_decoder_string_dump(&table->version, "version"); http_decoder_string_dump(&table->body, "body"); - for (size_t i = 0; i < table->header_index; i++) { + for (size_t i = 0; i < table->header_size; i++) { struct http_decoder_header *header = &table->headers[i]; + if (NULL == header) { + continue; + } + http_decoder_string_dump(&header->key, "key"); http_decoder_string_dump(&header->val, "val"); } @@ -396,8 +400,12 @@ http_decoder_table_get_header(struct http_decoder_table *table, } int header_cnt = 0; - for (int i = 0; i < table->header_index && header_cnt < array_size; i++) { + for (int i = 0; i < table->header_size && header_cnt < array_size; i++) { struct http_decoder_header *tmp_header = &table->headers[i]; + if (NULL == tmp_header) { + continue; + } + if (http_decoder_string_state(&tmp_header->key) == STRING_STATE_COMMIT && http_decoder_string_state(&tmp_header->val) == STRING_STATE_COMMIT) { struct hstring tmp_key; @@ -422,17 +430,19 @@ http_decoder_table_iter_header(struct http_decoder_table *table, return -1; } - if (table->header_iter >= table->header_index) { + if (table->header_iter >= table->header_size) { return 0; } struct http_decoder_header *tmp_header = &table->headers[table->header_iter++]; - if (http_decoder_string_state(&tmp_header->key) == STRING_STATE_COMMIT - && http_decoder_string_state(&tmp_header->val) == STRING_STATE_COMMIT) { - http_decoder_string_get(&tmp_header->key, &header->key); - http_decoder_string_get(&tmp_header->val, &header->val); - return 1; + if (tmp_header != NULL) { + if (http_decoder_string_state(&tmp_header->key) == STRING_STATE_COMMIT + && http_decoder_string_state(&tmp_header->val) == STRING_STATE_COMMIT) { + http_decoder_string_get(&tmp_header->key, &header->key); + http_decoder_string_get(&tmp_header->val, &header->val); + return 1; + } } header->key.str = NULL; diff --git a/test/http_decoder/CMakeLists.txt b/test/http_decoder/CMakeLists.txt index ad4d966..75209b1 100644 --- a/test/http_decoder/CMakeLists.txt +++ b/test/http_decoder/CMakeLists.txt @@ -40,9 +40,6 @@ add_test(NAME HTTP_GET_SINGLE_TRANS_TEST COMMAND ${TEST_MAIN} ${CMAKE_CURRENT_SO add_test(NAME HTTP_GET_MULTI_TRANS_TEST COMMAND ${TEST_MAIN} ${CMAKE_CURRENT_SOURCE_DIR}/test_result_json/http_get_multi_trans.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/http_pcap/ -name http_get_multi_trans.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR}) -add_test(NAME HTTP_GET_REQ_PIPELINE_TEST COMMAND ${TEST_MAIN} ${CMAKE_CURRENT_SOURCE_DIR}/test_result_json/http_get_req_pipeline.json - -f "find ${CMAKE_CURRENT_SOURCE_DIR}/http_pcap/ -name http_get_req_pipeline.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR}) - add_test(NAME HTTP_GET_LONG_COOKIE_TEST COMMAND ${TEST_MAIN} ${CMAKE_CURRENT_SOURCE_DIR}/test_result_json/http_get_long_cookie.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/http_pcap/ -name http_get_long_cookie.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR}) @@ -103,9 +100,14 @@ add_test(NAME HTTP_UPGRADE_HTTP2_TEST COMMAND ${TEST_MAIN} ${CMAKE_CURRENT_SOURC add_test(NAME HTTP_MULTI_PARSE_ERROR_TEST COMMAND ${TEST_MAIN} ${CMAKE_CURRENT_SOURCE_DIR}/test_result_json/http_multi_parse_error.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/http_pcap/ -name http_multi_parse_error.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR}) +add_test(NAME HTTP_GET_REQ_PIPELINE_TEST COMMAND ${TEST_MAIN} ${CMAKE_CURRENT_SOURCE_DIR}/test_result_json/http_get_req_pipeline.json + -f "find ${CMAKE_CURRENT_SOURCE_DIR}/http_pcap/ -name http_get_req_pipeline.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR}) + +add_test(NAME HTTP_TRANS_PIPELINE_TEST COMMAND ${TEST_MAIN} ${CMAKE_CURRENT_SOURCE_DIR}/test_result_json/http_trans_pipeline.json + -f "find ${CMAKE_CURRENT_SOURCE_DIR}/http_pcap/ -name http_trans_pipeline.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR}) + set_tests_properties(HTTP_GET_SINGLE_TRANS_TEST HTTP_GET_MULTI_TRANS_TEST - HTTP_GET_REQ_PIPELINE_TEST HTTP_GET_LONG_COOKIE_TEST HTTP_GET_ENCODED_URI_TEST HTTP_RES_GZIP_TEST @@ -126,4 +128,6 @@ set_tests_properties(HTTP_GET_SINGLE_TRANS_TEST HTTP_MULTI_PARSE_ERROR_TEST HTTP_UPGRADE_WEBSOCKET_TEST HTTP_UPGRADE_HTTP2_TEST + HTTP_GET_REQ_PIPELINE_TEST + HTTP_TRANS_PIPELINE_TEST PROPERTIES FIXTURES_REQUIRED TestFixture)
\ No newline at end of file diff --git a/test/http_decoder/http_pcap/http_trans_pipeline.pcap b/test/http_decoder/http_pcap/http_trans_pipeline.pcap Binary files differnew file mode 100644 index 0000000..9d4aa1a --- /dev/null +++ b/test/http_decoder/http_pcap/http_trans_pipeline.pcap diff --git a/test/http_decoder/test_result_json/http_trans_pipeline.json b/test/http_decoder/test_result_json/http_trans_pipeline.json new file mode 100644 index 0000000..e2d18c7 --- /dev/null +++ b/test/http_decoder/test_result_json/http_trans_pipeline.json @@ -0,0 +1,348 @@ +[ + { + "Tuple4": "223.72.39.14.2545>192.168.182.147.80", + "method": "GET", + "uri": "/postinfo.html", + "req_version": "1.1", + "major_version": 1, + "minor_version": 1, + "Host": "116.181.2.152", + "User-Agent": "Mozilla/5.0 (compatible; Nmap Scripting Engine; https://nmap.org/book/nse.html)", + "Connection": "keep-alive", + "name": "HTTP_DECODER_RESULT_1" + }, + { + "Tuple4": "223.72.39.14.2545>192.168.182.147.80", + "method": "GET", + "uri": "/_vti_bin/_vti_aut/author.dll", + "req_version": "1.1", + "major_version": 1, + "minor_version": 1, + "Host": "116.181.2.152", + "User-Agent": "Mozilla/5.0 (compatible; Nmap Scripting Engine; https://nmap.org/book/nse.html)", + "Connection": "keep-alive", + "name": "HTTP_DECODER_RESULT_2" + }, + { + "Tuple4": "223.72.39.14.2545>192.168.182.147.80", + "method": "GET", + "uri": "/_vti_bin/_vti_aut/author.exe", + "req_version": "1.1", + "major_version": 1, + "minor_version": 1, + "Host": "116.181.2.152", + "User-Agent": "Mozilla/5.0 (compatible; Nmap Scripting Engine; https://nmap.org/book/nse.html)", + "Connection": "keep-alive", + "name": "HTTP_DECODER_RESULT_3" + }, + { + "Tuple4": "223.72.39.14.2545>192.168.182.147.80", + "method": "GET", + "uri": "/_vti_bin/_vti_aut/dvwssr.dll", + "req_version": "1.1", + "major_version": 1, + "minor_version": 1, + "Host": "116.181.2.152", + "User-Agent": "Mozilla/5.0 (compatible; Nmap Scripting Engine; https://nmap.org/book/nse.html)", + "Connection": "keep-alive", + "name": "HTTP_DECODER_RESULT_4" + }, + { + "Tuple4": "223.72.39.14.2545>192.168.182.147.80", + "method": "GET", + "uri": "/_vti_bin/_vti_adm/admin.dll", + "req_version": "1.1", + "major_version": 1, + "minor_version": 1, + "Host": "116.181.2.152", + "User-Agent": "Mozilla/5.0 (compatible; Nmap Scripting Engine; https://nmap.org/book/nse.html)", + "Connection": "keep-alive", + "name": "HTTP_DECODER_RESULT_5" + }, + { + "Tuple4": "223.72.39.14.2545>192.168.182.147.80", + "method": "GET", + "uri": "/_vti_bin/_vti_adm/admin.exe", + "req_version": "1.1", + "major_version": 1, + "minor_version": 1, + "Host": "116.181.2.152", + "User-Agent": "Mozilla/5.0 (compatible; Nmap Scripting Engine; https://nmap.org/book/nse.html)", + "Connection": "keep-alive", + "name": "HTTP_DECODER_RESULT_6" + }, + { + "Tuple4": "223.72.39.14.2545>192.168.182.147.80", + "method": "GET", + "uri": "/_vti_bin/fpcount.exe?Page=default.asp|Image=3", + "req_version": "1.1", + "major_version": 1, + "minor_version": 1, + "Host": "116.181.2.152", + "User-Agent": "Mozilla/5.0 (compatible; Nmap Scripting Engine; https://nmap.org/book/nse.html)", + "Connection": "keep-alive", + "name": "HTTP_DECODER_RESULT_7" + }, + { + "Tuple4": "223.72.39.14.2545>192.168.182.147.80", + "res_version": "1.1", + "res_status": "Not Found", + "major_version": 1, + "minor_version": 1, + "status_code": 404, + "Server": "nginx", + "Date": "Thu, 29 Oct 2020 09:59:02 GMT", + "Content-Type": "text/html", + "Content-Length": "146", + "Connection": "keep-alive", + "name": "HTTP_DECODER_RESULT_8" + }, + { + "Tuple4": "223.72.39.14.2545>192.168.182.147.80", + "res_version": "1.1", + "res_status": "Not Found", + "major_version": 1, + "minor_version": 1, + "status_code": 404, + "Server": "nginx", + "Date": "Thu, 29 Oct 2020 09:59:02 GMT", + "Content-Type": "text/html", + "Content-Length": "146", + "Connection": "keep-alive", + "name": "HTTP_DECODER_RESULT_9" + }, + { + "Tuple4": "223.72.39.14.2545>192.168.182.147.80", + "res_version": "1.1", + "res_status": "Not Found", + "major_version": 1, + "minor_version": 1, + "status_code": 404, + "Server": "nginx", + "Date": "Thu, 29 Oct 2020 09:59:02 GMT", + "Content-Type": "text/html", + "Content-Length": "146", + "Connection": "keep-alive", + "name": "HTTP_DECODER_RESULT_10" + }, + { + "Tuple4": "223.72.39.14.2545>192.168.182.147.80", + "res_version": "1.1", + "res_status": "Not Found", + "major_version": 1, + "minor_version": 1, + "status_code": 404, + "Server": "nginx", + "Date": "Thu, 29 Oct 2020 09:59:02 GMT", + "Content-Type": "text/html", + "Content-Length": "146", + "Connection": "keep-alive", + "name": "HTTP_DECODER_RESULT_11" + }, + { + "Tuple4": "223.72.39.14.2545>192.168.182.147.80", + "res_version": "1.1", + "res_status": "Not Found", + "major_version": 1, + "minor_version": 1, + "status_code": 404, + "Server": "nginx", + "Date": "Thu, 29 Oct 2020 09:59:02 GMT", + "Content-Type": "text/html", + "Content-Length": "146", + "Connection": "keep-alive", + "name": "HTTP_DECODER_RESULT_12" + }, + { + "Tuple4": "223.72.39.14.2545>192.168.182.147.80", + "res_version": "1.1", + "res_status": "Not Found", + "major_version": 1, + "minor_version": 1, + "status_code": 404, + "Server": "nginx", + "Date": "Thu, 29 Oct 2020 09:59:02 GMT", + "Content-Type": "text/html", + "Content-Length": "146", + "Connection": "keep-alive", + "name": "HTTP_DECODER_RESULT_13" + }, + { + "Tuple4": "223.72.39.14.2545>192.168.182.147.80", + "method": "GET", + "uri": "/_vti_bin/shtml.dll", + "req_version": "1.1", + "major_version": 1, + "minor_version": 1, + "Host": "116.181.2.152", + "User-Agent": "Mozilla/5.0 (compatible; Nmap Scripting Engine; https://nmap.org/book/nse.html)", + "Connection": "keep-alive", + "name": "HTTP_DECODER_RESULT_14" + }, + { + "Tuple4": "223.72.39.14.2545>192.168.182.147.80", + "method": "GET", + "uri": "/_vti_bin/shtml.exe", + "req_version": "1.1", + "major_version": 1, + "minor_version": 1, + "Host": "116.181.2.152", + "User-Agent": "Mozilla/5.0 (compatible; Nmap Scripting Engine; https://nmap.org/book/nse.html)", + "Connection": "keep-alive", + "name": "HTTP_DECODER_RESULT_15" + }, + { + "Tuple4": "223.72.39.14.2545>192.168.182.147.80", + "method": "GET", + "uri": "/_vti_pvt/_x_todo.htm", + "req_version": "1.1", + "major_version": 1, + "minor_version": 1, + "Host": "116.181.2.152", + "User-Agent": "Mozilla/5.0 (compatible; Nmap Scripting Engine; https://nmap.org/book/nse.html)", + "Connection": "keep-alive", + "name": "HTTP_DECODER_RESULT_16" + }, + { + "Tuple4": "223.72.39.14.2545>192.168.182.147.80", + "method": "GET", + "uri": "/_vti_pvt/_x_todoh.htm", + "req_version": "1.1", + "major_version": 1, + "minor_version": 1, + "Host": "116.181.2.152", + "User-Agent": "Mozilla/5.0 (compatible; Nmap Scripting Engine; https://nmap.org/book/nse.html)", + "Connection": "keep-alive", + "name": "HTTP_DECODER_RESULT_17" + }, + { + "Tuple4": "223.72.39.14.2545>192.168.182.147.80", + "method": "GET", + "uri": "/_vti_pvt/access.cnf", + "req_version": "1.1", + "major_version": 1, + "minor_version": 1, + "Host": "116.181.2.152", + "User-Agent": "Mozilla/5.0 (compatible; Nmap Scripting Engine; https://nmap.org/book/nse.html)", + "Connection": "keep-alive", + "name": "HTTP_DECODER_RESULT_18" + }, + { + "Tuple4": "223.72.39.14.2545>192.168.182.147.80", + "method": "GET", + "uri": "/_vti_pvt/administrator.pwd", + "req_version": "1.1", + "major_version": 1, + "minor_version": 1, + "Host": "116.181.2.152", + "User-Agent": "Mozilla/5.0 (compatible; Nmap Scripting Engine; https://nmap.org/book/nse.html)", + "Connection": "keep-alive", + "name": "HTTP_DECODER_RESULT_19" + }, + { + "Tuple4": "223.72.39.14.2545>192.168.182.147.80", + "method": "GET", + "uri": "/_vti_pvt/administrators.pwd", + "req_version": "1.1", + "major_version": 1, + "minor_version": 1, + "Host": "116.181.2.152", + "User-Agent": "Mozilla/5.0 (compatible; Nmap Scripting Engine; https://nmap.org/book/nse.html)", + "Connection": "keep-alive", + "name": "HTTP_DECODER_RESULT_20" + }, + { + "Tuple4": "223.72.39.14.2545>192.168.182.147.80", + "method": "GET", + "uri": "/_vti_pvt/authors.pwd", + "req_version": "1.1", + "major_version": 1, + "minor_version": 1, + "Host": "116.181.2.152", + "User-Agent": "Mozilla/5.0 (compatible; Nmap Scripting Engine; https://nmap.org/book/nse.html)", + "Connection": "keep-alive", + "name": "HTTP_DECODER_RESULT_21" + }, + { + "Tuple4": "223.72.39.14.2545>192.168.182.147.80", + "method": "GET", + "uri": "/_vti_pvt/bots.cnf", + "req_version": "1.1", + "major_version": 1, + "minor_version": 1, + "Host": "116.181.2.152", + "User-Agent": "Mozilla/5.0 (compatible; Nmap Scripting Engine; https://nmap.org/book/nse.html)", + "Connection": "keep-alive", + "name": "HTTP_DECODER_RESULT_22" + }, + { + "Tuple4": "223.72.39.14.2545>192.168.182.147.80", + "res_version": "1.1", + "res_status": "Not Found", + "major_version": 1, + "minor_version": 1, + "status_code": 404, + "Server": "nginx", + "Date": "Thu, 29 Oct 2020 09:59:02 GMT", + "Content-Type": "text/html", + "Content-Length": "146", + "Connection": "keep-alive", + "name": "HTTP_DECODER_RESULT_23" + }, + { + "Tuple4": "223.72.39.14.2545>192.168.182.147.80", + "res_version": "1.1", + "res_status": "Not Found", + "major_version": 1, + "minor_version": 1, + "status_code": 404, + "Server": "nginx", + "Date": "Thu, 29 Oct 2020 09:59:02 GMT", + "Content-Type": "text/html", + "Content-Length": "146", + "Connection": "keep-alive", + "name": "HTTP_DECODER_RESULT_24" + }, + { + "Tuple4": "223.72.39.14.2545>192.168.182.147.80", + "res_version": "1.1", + "res_status": "Not Found", + "major_version": 1, + "minor_version": 1, + "status_code": 404, + "Server": "nginx", + "Date": "Thu, 29 Oct 2020 09:59:02 GMT", + "Content-Type": "text/html", + "Content-Length": "146", + "Connection": "keep-alive", + "name": "HTTP_DECODER_RESULT_25" + }, + { + "Tuple4": "223.72.39.14.2545>192.168.182.147.80", + "res_version": "1.1", + "res_status": "Not Found", + "major_version": 1, + "minor_version": 1, + "status_code": 404, + "Server": "nginx", + "Date": "Thu, 29 Oct 2020 09:59:02 GMT", + "Content-Type": "text/html", + "Content-Length": "146", + "Connection": "keep-alive", + "name": "HTTP_DECODER_RESULT_26" + }, + { + "Tuple4": "223.72.39.14.2545>192.168.182.147.80", + "res_version": "1.1", + "res_status": "Not Found", + "major_version": 1, + "minor_version": 1, + "status_code": 404, + "Server": "nginx", + "Date": "Thu, 29 Oct 2020 09:59:02 GMT", + "Content-Type": "text/html", + "Content-Length": "146", + "Connection": "keep-alive", + "name": "HTTP_DECODER_RESULT_27" + } +]
\ No newline at end of file |
