summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fhp.c9
-rw-r--r--include/fhp/fhp.h3
2 files changed, 12 insertions, 0 deletions
diff --git a/fhp.c b/fhp.c
index be4b7f3..fdf344b 100644
--- a/fhp.c
+++ b/fhp.c
@@ -398,6 +398,7 @@ static const fhp_t DEFAULT_CONTEXT = {
.ofs = 0,
.buf_len = 0,
.is_hashing = false,
+ .header_name_hash = 0,
};
fhp_err_t
@@ -721,6 +722,10 @@ retry:
if (!fhp->cb(fhp, FHP_TOKEN_HEADER_NAME_START, 0, 0))
return FHP_ERR_CB;
+ // enable buffer hashing
+ fhp->is_hashing = true;
+ fhp->buf_hash = fhp_hash_init();
+
// set state
fhp->state = FHP_STATE_HEADER_NAME;
goto retry;
@@ -768,6 +773,10 @@ retry:
if (!fhp->cb(fhp, FHP_TOKEN_HEADER_NAME_END, 0, 0))
return FHP_ERR_CB;
+ // disable buffer hashing
+ fhp->is_hashing = false;
+ fhp->header_name_hash = fhp->buf_hash;
+
// set state
fhp->state = FHP_STATE_HEADER_NAME_END;
diff --git a/include/fhp/fhp.h b/include/fhp/fhp.h
index 2e1dc95..3337cbe 100644
--- a/include/fhp/fhp.h
+++ b/include/fhp/fhp.h
@@ -165,6 +165,9 @@ struct fhp_t_ {
// cached http method and version
fhp_token_t http_method, http_version;
+ // hash of last header name
+ uint32_t header_name_hash;
+
// state for url hex decoder
uint32_t hex;
};