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.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/header-value-parser.c b/header-value-parser.c
index aeab7d3..c1835a5 100644
--- a/header-value-parser.c
+++ b/header-value-parser.c
@@ -88,6 +88,30 @@ fhp_header_value_parser_done(fhp_t * const fhp) {
if ((r = fhp_te_parser_get_tes(&(fhp->parsers.te), fhp->tes, FHP_MAX_TRANSFER_ENCODINGS)) != FHP_OK)
return r;
+ // update body type
+ // FIXME: follow RFC7230 3.3.3
+ // https://tools.ietf.org/html/rfc7230#section-3.3.3
+ switch (fhp->body_type) {
+ case FHP_BODY_TYPE_NONE:
+ // set body type
+ fhp->body_type = FHP_BODY_TYPE_CONTENT_LENGTH;
+
+ break;
+ case FHP_BODY_TYPE_CONTENT_LENGTH:
+ // duplicate content-length
+ // FIXME: should print warning here
+
+ break;
+ case FHP_BODY_TYPE_TRANSFER_ENCODING:
+ // already have transfer-encoding, ignore content-length
+ // FIXME: should print warning here
+
+ break;
+ default:
+ // never reached
+ return FHP_ERR_INVALID_BODY_TYPE;
+ }
+
// notify callback
if (!fhp->cb(fhp, FHP_TOKEN_HEADER_TRANSFER_ENCODING, 0, 0))
return FHP_ERR_CB;
@@ -98,6 +122,30 @@ fhp_header_value_parser_done(fhp_t * const fhp) {
if ((r = fhp_cl_parser_done(&(fhp->parsers.cl), &(fhp->content_length))) != FHP_OK)
return r;
+ // update body type
+ // FIXME: follow RFC7230 3.3.3
+ // https://tools.ietf.org/html/rfc7230#section-3.3.3
+ switch (fhp->body_type) {
+ case FHP_BODY_TYPE_NONE:
+ // set body type
+ fhp->body_type = FHP_BODY_TYPE_TRANSFER_ENCODING;
+
+ break;
+ case FHP_BODY_TYPE_CONTENT_LENGTH:
+ // both content-type and transfer-encoding, ignore content-type
+ // FIXME: should print warning here
+
+ break;
+ case FHP_BODY_TYPE_TRANSFER_ENCODING:
+ // duplicate transfer-encoding
+ // FIXME: should print warnings
+
+ break;
+ default:
+ // never reached
+ return FHP_ERR_INVALID_BODY_TYPE;
+ }
+
// notify callback
if (!fhp->cb(fhp, FHP_TOKEN_HEADER_CONTENT_LENGTH, 0, 0))
return FHP_ERR_CB;