From 42bc7b1f471d427e871f1b71079b397a3cddf565 Mon Sep 17 00:00:00 2001 From: cpq Date: Tue, 9 Feb 2021 13:27:17 +0000 Subject: [PATCH] Add "struct mg_http_message::head" attr --- mongoose.c | 5 +++-- mongoose.h | 3 ++- src/http.c | 5 +++-- src/http.h | 3 ++- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/mongoose.c b/mongoose.c index 5efe7855..38638504 100644 --- a/mongoose.c +++ b/mongoose.c @@ -570,8 +570,9 @@ int mg_http_parse(const char *s, size_t len, struct mg_http_message *hm) { memset(hm, 0, sizeof(*hm)); if (req_len <= 0) return req_len; - hm->message.ptr = s; - hm->body.ptr = s + req_len; + hm->message.ptr = hm->head.ptr = s; + hm->body.ptr = end; + hm->head.len = req_len; hm->message.len = hm->body.len = (size_t) ~0; // Set body length to infinite // Parse request line diff --git a/mongoose.h b/mongoose.h index b62b6123..970aa56f 100644 --- a/mongoose.h +++ b/mongoose.h @@ -694,7 +694,8 @@ struct mg_http_message { struct mg_str method, uri, query, proto; // Request/response line struct mg_http_header headers[MG_MAX_HTTP_HEADERS]; // Headers struct mg_str body; // Body - struct mg_str message; // Request line + headers + body + struct mg_str head; // Request + headers + struct mg_str message; // Request + headers + body }; // Parameter for mg_http_serve_dir() diff --git a/src/http.c b/src/http.c index 0c7ea7d1..49b118ae 100644 --- a/src/http.c +++ b/src/http.c @@ -150,8 +150,9 @@ int mg_http_parse(const char *s, size_t len, struct mg_http_message *hm) { memset(hm, 0, sizeof(*hm)); if (req_len <= 0) return req_len; - hm->message.ptr = s; - hm->body.ptr = s + req_len; + hm->message.ptr = hm->head.ptr = s; + hm->body.ptr = end; + hm->head.len = req_len; hm->message.len = hm->body.len = (size_t) ~0; // Set body length to infinite // Parse request line diff --git a/src/http.h b/src/http.h index 890367e7..3079db2b 100644 --- a/src/http.h +++ b/src/http.h @@ -16,7 +16,8 @@ struct mg_http_message { struct mg_str method, uri, query, proto; // Request/response line struct mg_http_header headers[MG_MAX_HTTP_HEADERS]; // Headers struct mg_str body; // Body - struct mg_str message; // Request line + headers + body + struct mg_str head; // Request + headers + struct mg_str message; // Request + headers + body }; // Parameter for mg_http_serve_dir()