summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2016-08-27 14:46:04 -0400
committerPaul Duncan <pabs@pablotron.org>2016-08-27 14:46:04 -0400
commit998f207725e0427b6518fea5e6d64347cb14e231 (patch)
tree86d5be69a0099cbe8fc1502af3e56d049329bae8
parentbf917d7ddf539ff2eff0e3e998d9cbd979b2dea3 (diff)
downloadlibfhp-998f207725e0427b6518fea5e6d64347cb14e231.tar.bz2
libfhp-998f207725e0427b6518fea5e6d64347cb14e231.zip
hash header name
-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;
};