MINOR: hlua/h1: Use http_parse_cont_len_header() to parse content-length value
Till now, h1_parse_cont_len_header() was used during the H1 message parsing and by the lua HTTP applets to parse the content-length header value. But a more generic function was added some years ago doing exactly the same operations. So let's use it instead.
This commit is contained in:
parent
a6b32922fc
commit
9e05c14a41
5
src/h1.c
5
src/h1.c
@ -1054,8 +1054,9 @@ int h1_headers_to_hdr_list(char *start, const char *stop,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (isteqi(n, ist("content-length"))) {
|
else if (isteqi(n, ist("content-length"))) {
|
||||||
ret = h1_parse_cont_len_header(h1m, &v);
|
unsigned long long body_len = h1m->body_len;
|
||||||
|
|
||||||
|
ret = http_parse_cont_len_header(&v, &body_len, (h1m->flags & H1_MF_CLEN));
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
state = H1_MSG_HDR_L2_LWS;
|
state = H1_MSG_HDR_L2_LWS;
|
||||||
ptr = v.ptr; /* Set ptr on the error */
|
ptr = v.ptr; /* Set ptr on the error */
|
||||||
@ -1065,6 +1066,8 @@ int h1_headers_to_hdr_list(char *start, const char *stop,
|
|||||||
/* skip it */
|
/* skip it */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
h1m->flags |= H1_MF_CLEN;
|
||||||
|
h1m->curr_len = h1m->body_len = body_len;
|
||||||
}
|
}
|
||||||
else if (isteqi(n, ist("connection"))) {
|
else if (isteqi(n, ist("connection"))) {
|
||||||
h1_parse_connection_header(h1m, &v);
|
h1_parse_connection_header(h1m, &v);
|
||||||
|
@ -6282,18 +6282,21 @@ __LJMP static int hlua_applet_http_send_response(lua_State *L)
|
|||||||
goto next; /* Skip it */
|
goto next; /* Skip it */
|
||||||
}
|
}
|
||||||
else if (isteqi(ist2(name, nlen), ist("content-length"))) {
|
else if (isteqi(ist2(name, nlen), ist("content-length"))) {
|
||||||
|
unsigned long long body_len = h1m.body_len;
|
||||||
struct ist v = ist2(value, vlen);
|
struct ist v = ist2(value, vlen);
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = h1_parse_cont_len_header(&h1m, &v);
|
ret = http_parse_cont_len_header(&v, &body_len, (h1m.flags & H1_MF_CLEN));
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
hlua_pusherror(L, "Lua applet http '%s': Invalid '%s' header.\n",
|
hlua_pusherror(L, "Lua applet http '%s': Invalid '%s' header.\n",
|
||||||
luactx->appctx->rule->arg.hlua_rule->fcn->name,
|
luactx->appctx->rule->arg.hlua_rule->fcn->name,
|
||||||
name);
|
name);
|
||||||
WILL_LJMP(lua_error(L));
|
WILL_LJMP(lua_error(L));
|
||||||
}
|
}
|
||||||
else if (ret == 0)
|
else if(ret == 0)
|
||||||
goto next; /* Skip it */
|
goto next; /* Skip it */
|
||||||
|
h1m.flags |= H1_MF_CLEN;
|
||||||
|
h1m.curr_len = h1m.body_len = body_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add a new header */
|
/* Add a new header */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user