summaryrefslogtreecommitdiff
path: root/header-value-parser.c
diff options
context:
space:
mode:
Diffstat (limited to 'header-value-parser.c')
-rw-r--r--header-value-parser.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/header-value-parser.c b/header-value-parser.c
index d31deca..aeab7d3 100644
--- a/header-value-parser.c
+++ b/header-value-parser.c
@@ -29,6 +29,10 @@ fhp_header_value_parser_init(fhp_t * const fhp) {
} else if (hash == fhp->env->hashes[FHP_STR_CONTENT_LENGTH]) {
// set parser type
parser = FHP_HEADER_VALUE_PARSER_CONTENT_LENGTH;
+
+ // init parser
+ if ((err = fhp_cl_parser_init(&(fhp->parsers.cl))) != FHP_OK)
+ return err;
} else {
// set default parser type
parser = FHP_HEADER_VALUE_PARSER_NONE;
@@ -54,8 +58,7 @@ fhp_header_value_parser_push(
r = fhp_te_parser_push(&(fhp->parsers.te), buf, len);
break;
case FHP_HEADER_VALUE_PARSER_CONTENT_LENGTH:
- // TODO
- r = FHP_OK;
+ r = fhp_cl_parser_push(&(fhp->parsers.cl), buf, len);
break;
default:
// do nothing
@@ -91,8 +94,13 @@ fhp_header_value_parser_done(fhp_t * const fhp) {
break;
case FHP_HEADER_VALUE_PARSER_CONTENT_LENGTH:
- // TODO
- r = FHP_OK;
+ // finish parsing content-length and copy to context
+ if ((r = fhp_cl_parser_done(&(fhp->parsers.cl), &(fhp->content_length))) != FHP_OK)
+ return r;
+
+ // notify callback
+ if (!fhp->cb(fhp, FHP_TOKEN_HEADER_CONTENT_LENGTH, 0, 0))
+ return FHP_ERR_CB;
break;
default:
@@ -108,4 +116,3 @@ fhp_header_value_parser_done(fhp_t * const fhp) {
// return result
return r;
}
-