summaryrefslogtreecommitdiff
path: root/test/http_decoder_perf_plug.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/http_decoder_perf_plug.cpp')
-rw-r--r--test/http_decoder_perf_plug.cpp41
1 files changed, 23 insertions, 18 deletions
diff --git a/test/http_decoder_perf_plug.cpp b/test/http_decoder_perf_plug.cpp
index c8c8771..3a3d14a 100644
--- a/test/http_decoder_perf_plug.cpp
+++ b/test/http_decoder_perf_plug.cpp
@@ -1,3 +1,4 @@
+#include "http_decoder.h"
#include <stdio.h>
#include <time.h>
#include <unistd.h>
@@ -20,16 +21,15 @@ static int g_exdata_idx = -1;
static int g_topic_id = -1;
static int g_plugin_id = -1;
-#define DEBUG_PRINT(fmt, ...) ///printf(fmt, ##__VA_ARGS__)
+#define DEBUG_PRINT(fmt, ...) //printf(fmt, ##__VA_ARGS__)
extern "C" void http_decoder_perf_entry(struct session *sess, int topic_id, const void *raw_msg, void *per_session_ctx, void *plugin_env)
-// extern "C" int http_decoder_perf_entry(struct session *sess, int topic_id, const void *data, void *cb_arg)
{
struct http_request_line req_line = {0};
struct http_response_line res_line = {0};
struct http_header header = {0};
- hstring url = {0};
- hstring body = {0};
+ hstring url = {};
+ hstring body = {};
struct http_message *msg = (struct http_message *)raw_msg;
enum http_message_type msg_type = http_message_type_get(msg);
void *ret1, *ret2;
@@ -38,7 +38,7 @@ extern "C" void http_decoder_perf_entry(struct session *sess, int topic_id, cons
{
case HTTP_MESSAGE_REQ_LINE:
DEBUG_PRINT("---------------------------------------------------------------\n");
- http_message_get_request_line(msg, &req_line);
+ http_message_request_line_get0(msg, &req_line);
if (req_line.uri.iov_base)
{
DEBUG_PRINT("req_line.method.iov_base: %.*s\n", req_line.method.iov_len, req_line.method.iov_base);
@@ -53,7 +53,7 @@ extern "C" void http_decoder_perf_entry(struct session *sess, int topic_id, cons
ret2 = memmem(header.val.iov_base, header.val.iov_len, "val", 3);
DEBUG_PRINT("REQ header: %.*s : %.*s\n", (int)header.key.iov_len, header.key.iov_base, (int)header.val.iov_len, header.val.iov_base);
}
- http_message_get_url(msg, &url);
+ http_message_raw_url_get0(msg, &url);
if(url.iov_base && url.iov_len){
DEBUG_PRINT("URL: %.*s\n", url.iov_len, url.iov_base);
}
@@ -61,12 +61,12 @@ extern "C" void http_decoder_perf_entry(struct session *sess, int topic_id, cons
case HTTP_MESSAGE_REQ_BODY:
// http_message_get_request_raw_body(msg, &body);
// output_http_body(&body, 0);
- http_message_get_decompress_body(msg, &body);
+ http_message_decompress_body_get0(msg, &body);
// output_http_body(&body, 1);
ret1 = memmem(body.iov_base, body.iov_len, "</html>", 7);
break;
case HTTP_MESSAGE_RES_LINE:
- http_message_get_response_line(msg, &res_line);
+ http_message_response_line_get0(msg, &res_line);
ret1 = memmem(res_line.status.iov_base, res_line.status.iov_len, "OK", 2);
DEBUG_PRINT("res_line.status.iov_base: %.*s\n", (int)res_line.status.iov_len, res_line.status.iov_base);
break;
@@ -78,17 +78,22 @@ extern "C" void http_decoder_perf_entry(struct session *sess, int topic_id, cons
DEBUG_PRINT("RES header: %.*s : %.*s\n", (int)header.key.iov_len, header.key.iov_base, (int)header.val.iov_len, header.val.iov_base);
}
break;
+ case HTTP_MESSAGE_RES_BODY_START:
case HTTP_MESSAGE_RES_BODY:
- http_message_get_raw_body(msg, &body);
- DEBUG_PRINT("res raw body: %.*s\n", body.iov_len, body.iov_base);
+ case HTTP_MESSAGE_RES_BODY_END:
+ http_message_raw_body_get0(msg, &body);
+ if(body.iov_base!=NULL && body.iov_len > 0){
+ DEBUG_PRINT("res raw body: %.*s\n", body.iov_len, body.iov_base);
+ }
// output_http_body(&body, 0);
- http_message_get_decompress_body(msg, &body);
- // output_http_body(&body, 1);
- ret1 = memmem(body.iov_base, body.iov_len, "</html>", 7);
- DEBUG_PRINT("res unzip body: %.*s\n", body.iov_len, body.iov_base);
- DEBUG_PRINT("---------------------------------------------------------------\n");
+ http_message_decompress_body_get0(msg, &body);
+ if(body.iov_base!=NULL && body.iov_len > 0){
+ // output_http_body(&body, 1);
+ ret1 = memmem(body.iov_base, body.iov_len, "</html>", 7);
+ DEBUG_PRINT("res unzip body: %.*s\n", body.iov_len, body.iov_base);
+ DEBUG_PRINT("---------------------------------------------------------------\n");
+ }
break;
-
// to do: check payload
default:
break;
@@ -103,7 +108,7 @@ static void http_decoder_test_exdata_free(struct session *sess, int idx, void *e
return;
}
-extern "C" void *http_decoder_perf_init(struct stellar *st)
+extern "C" void *http_decoder_perf_plug_init(struct stellar *st)
{
g_plugin_id = stellar_session_plugin_register(st, NULL, NULL, NULL);
g_exdata_idx = stellar_session_exdata_new_index(st, "HTTP_DECODER_REQ_TEST",
@@ -128,7 +133,7 @@ extern "C" void *http_decoder_perf_init(struct stellar *st)
return NULL;
}
-extern "C" void http_decoder_perf_exit(void *test_ctx)
+extern "C" void http_decoder_perf_plug_exit(void *test_ctx)
{
if (test_ctx != NULL)
{