mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-28 15:42:30 +00:00
MINOR: mux-h1: Add h1_eval_htx_hdrs_size() to estimate size of the HTX headers
It is just a cosmetic change, to avoid code duplication.
This commit is contained in:
parent
ada34b6a86
commit
82f0160318
30
src/mux_h1.c
30
src/mux_h1.c
@ -900,21 +900,26 @@ static void h1_set_res_tunnel_mode(struct h1s *h1s)
|
||||
}
|
||||
}
|
||||
|
||||
/* Estimate the size of the HTX headers after the parsing, including the EOH. */
|
||||
static size_t h1_eval_htx_hdrs_size(struct http_hdr *hdrs)
|
||||
{
|
||||
size_t sz = 0;
|
||||
int i;
|
||||
|
||||
for (i = 0; hdrs[i].n.len; i++)
|
||||
sz += sizeof(struct htx_blk) + hdrs[i].n.len + hdrs[i].v.len;
|
||||
sz += sizeof(struct htx_blk) + 1;
|
||||
return sz;
|
||||
}
|
||||
|
||||
/* Estimate the size of the HTX request after the parsing. */
|
||||
static size_t h1_eval_htx_req_size(struct h1m *h1m, union h1_sl *h1sl, struct http_hdr *hdrs)
|
||||
{
|
||||
size_t sz;
|
||||
int i;
|
||||
|
||||
/* size of the HTX start-line */
|
||||
sz = sizeof(struct htx_sl) + h1sl->rq.m.len + h1sl->rq.u.len + h1sl->rq.v.len;
|
||||
|
||||
/* size of all HTX headers */
|
||||
for (i = 0; hdrs[i].n.len; i++)
|
||||
sz += sizeof(struct htx_blk) + hdrs[i].n.len + hdrs[i].v.len;
|
||||
|
||||
/* size of the EOH */
|
||||
sz += sizeof(struct htx_blk) + 1;
|
||||
sz += h1_eval_htx_hdrs_size(hdrs);
|
||||
|
||||
/* size of the EOM */
|
||||
if (h1m->state == H1_MSG_DONE)
|
||||
@ -927,17 +932,10 @@ static size_t h1_eval_htx_req_size(struct h1m *h1m, union h1_sl *h1sl, struct ht
|
||||
static size_t h1_eval_htx_res_size(struct h1m *h1m, union h1_sl *h1sl, struct http_hdr *hdrs)
|
||||
{
|
||||
size_t sz;
|
||||
int i;
|
||||
|
||||
/* size of the HTX start-line */
|
||||
sz = sizeof(struct htx_sl) + h1sl->st.v.len + h1sl->st.c.len + h1sl->st.r.len;
|
||||
|
||||
/* size of all HTX headers */
|
||||
for (i = 0; hdrs[i].n.len; i++)
|
||||
sz += sizeof(struct htx_blk) + hdrs[i].n.len + hdrs[i].v.len;
|
||||
|
||||
/* size of the EOH */
|
||||
sz += sizeof(struct htx_blk) + 1;
|
||||
sz += h1_eval_htx_hdrs_size(hdrs);
|
||||
|
||||
/* size of the EOM */
|
||||
if (h1m->state == H1_MSG_DONE)
|
||||
|
Loading…
Reference in New Issue
Block a user