From 998f207725e0427b6518fea5e6d64347cb14e231 Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Sat, 27 Aug 2016 14:46:04 -0400 Subject: hash header name --- fhp.c | 9 +++++++++ include/fhp/fhp.h | 3 +++ 2 files changed, 12 insertions(+) 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; }; -- cgit v1.2.3