From: Christopher Faulet Date: Mon, 13 May 2019 13:27:23 +0000 (+0200) Subject: MEDIUM: http/htx: Perform analysis relatively to the first block X-Git-Tag: v2.0-dev5~49 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a3f1550dfa62f67dae41d2a258e46dba37163336;p=thirdparty%2Fhaproxy.git MEDIUM: http/htx: Perform analysis relatively to the first block The first block is the start-line, if defined. Otherwise it the head of the HTX message. So now, during HTTP analysis, lookup are all done using the first block instead of the head. Concretely, for now, it is the same because only one HTTP message is stored at a time in an HTX message. 1xx informational messages are handled separatly from the final reponse and from each other. But it will make sense when the 1xx informational messages and the associated final reponse will be stored in the same HTX message. --- diff --git a/src/backend.c b/src/backend.c index fc00666658..88991a8281 100644 --- a/src/backend.c +++ b/src/backend.c @@ -347,7 +347,7 @@ static struct server *get_server_ph_post(struct stream *s, const struct server * p = params = NULL; len = 0; - for (blk = htx_get_head_blk(htx); blk; blk = htx_get_next_blk(htx, blk)) { + for (blk = htx_get_first_blk(htx); blk; blk = htx_get_next_blk(htx, blk)) { enum htx_blk_type type = htx_get_blk_type(blk); struct ist v; diff --git a/src/cache.c b/src/cache.c index 188efea177..1fec57e240 100644 --- a/src/cache.c +++ b/src/cache.c @@ -715,7 +715,7 @@ enum act_return http_action_store_cache(struct act_rule *rule, struct proxy *px, } chunk_reset(&trash); - for (pos = htx_get_head(htx); pos != -1; pos = htx_get_next(htx, pos)) { + for (pos = htx_get_first(htx); pos != -1; pos = htx_get_next(htx, pos)) { struct htx_blk *blk = htx_get_blk(htx, pos); enum htx_blk_type type = htx_get_blk_type(blk); uint32_t sz = htx_get_blksz(blk); diff --git a/src/da.c b/src/da.c index 6c7ce814e0..f5e0135285 100644 --- a/src/da.c +++ b/src/da.c @@ -307,7 +307,7 @@ static int da_haproxy_fetch(const struct arg *args, struct sample *smp, const ch } i = 0; - for (blk = htx_get_head_blk(htx); nbh < DA_MAX_HEADERS && blk; blk = htx_get_next_blk(htx, blk)) { + for (blk = htx_get_first_blk(htx); nbh < DA_MAX_HEADERS && blk; blk = htx_get_next_blk(htx, blk)) { size_t vlen; char *pval; da_evidence_id_t evid; diff --git a/src/filters.c b/src/filters.c index 95ba7728bd..62e256ee96 100644 --- a/src/filters.c +++ b/src/filters.c @@ -933,7 +933,7 @@ flt_analyze_http_headers(struct stream *s, struct channel *chn, unsigned int an_ struct htx *htx = htxbuf(&chn->buf); int32_t pos; - for (pos = htx_get_head(htx); pos != -1; pos = htx_get_next(htx, pos)) { + for (pos = htx_get_first(htx); pos != -1; pos = htx_get_next(htx, pos)) { struct htx_blk *blk = htx_get_blk(htx, pos); c_adv(chn, htx_get_blksz(blk)); if (htx_get_blk_type(blk) == HTX_BLK_EOH) diff --git a/src/flt_trace.c b/src/flt_trace.c index ed159e8a7c..3a14244892 100644 --- a/src/flt_trace.c +++ b/src/flt_trace.c @@ -422,7 +422,7 @@ trace_http_headers(struct stream *s, struct filter *filter, HTX_SL_P2_LEN(sl), HTX_SL_P2_PTR(sl), HTX_SL_P3_LEN(sl), HTX_SL_P3_PTR(sl)); - for (pos = htx_get_head(htx); pos != -1; pos = htx_get_next(htx, pos)) { + for (pos = htx_get_first(htx); pos != -1; pos = htx_get_next(htx, pos)) { struct htx_blk *blk = htx_get_blk(htx, pos); enum htx_blk_type type = htx_get_blk_type(blk); struct ist n, v; diff --git a/src/hlua.c b/src/hlua.c index 72ce6bab60..bb8c93da6b 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -3993,7 +3993,7 @@ static int hlua_applet_http_new(lua_State *L, struct appctx *ctx) lua_settable(L, -3); } - for (pos = htx_get_head(htx); pos != -1; pos = htx_get_next(htx, pos)) { + for (pos = htx_get_first(htx); pos != -1; pos = htx_get_next(htx, pos)) { struct htx_blk *blk = htx_get_blk(htx, pos); enum htx_blk_type type = htx_get_blk_type(blk); @@ -4210,7 +4210,7 @@ __LJMP static int hlua_applet_htx_getline_yield(lua_State *L, int status, lua_KC htx = htx_from_buf(&req->buf); count = co_data(req); - blk = htx_get_head_blk(htx); + blk = htx_get_first_blk(htx); while (count && !stop && blk) { enum htx_blk_type type = htx_get_blk_type(blk); @@ -4366,7 +4366,7 @@ __LJMP static int hlua_applet_htx_recv_yield(lua_State *L, int status, lua_KCont htx = htx_from_buf(&req->buf); len = MAY_LJMP(luaL_checkinteger(L, 2)); count = co_data(req); - blk = htx_get_head_blk(htx); + blk = htx_get_first_blk(htx); while (count && len && blk) { enum htx_blk_type type = htx_get_blk_type(blk); uint32_t sz = htx_get_blksz(blk); @@ -5197,7 +5197,7 @@ __LJMP static int hlua_http_get_headers(lua_State *L, struct hlua_txn *htxn, str struct htx *htx = htxbuf(&msg->chn->buf); int32_t pos; - for (pos = htx_get_head(htx); pos != -1; pos = htx_get_next(htx, pos)) { + for (pos = htx_get_first(htx); pos != -1; pos = htx_get_next(htx, pos)) { struct htx_blk *blk = htx_get_blk(htx, pos); enum htx_blk_type type = htx_get_blk_type(blk); struct ist n, v; @@ -7213,7 +7213,7 @@ static void hlua_applet_htx_fct(struct appctx *ctx) * the Lua. */ req_htx = htx_from_buf(&req->buf); - blk = htx_get_head_blk(req_htx); + blk = htx_get_first_blk(req_htx); while (count && blk) { enum htx_blk_type type = htx_get_blk_type(blk); uint32_t sz = htx_get_blksz(blk); diff --git a/src/http_fetch.c b/src/http_fetch.c index 0a5a2f91f7..395e665e9d 100644 --- a/src/http_fetch.c +++ b/src/http_fetch.c @@ -615,7 +615,7 @@ static int smp_fetch_hdrs(const struct arg *args, struct sample *smp, const char if (!htx) return 0; temp = get_trash_chunk(); - for (pos = htx_get_head(htx); pos != -1; pos = htx_get_next(htx, pos)) { + for (pos = htx_get_first(htx); pos != -1; pos = htx_get_next(htx, pos)) { struct htx_blk *blk = htx_get_blk(htx, pos); enum htx_blk_type type = htx_get_blk_type(blk); @@ -687,7 +687,7 @@ static int smp_fetch_hdrs_bin(const struct arg *args, struct sample *smp, const temp = get_trash_chunk(); p = temp->area; end = temp->area + temp->size; - for (pos = htx_get_head(htx); pos != -1; pos = htx_get_next(htx, pos)) { + for (pos = htx_get_first(htx); pos != -1; pos = htx_get_next(htx, pos)) { struct htx_blk *blk = htx_get_blk(htx, pos); enum htx_blk_type type = htx_get_blk_type(blk); struct ist n, v; @@ -844,7 +844,7 @@ static int smp_fetch_body(const struct arg *args, struct sample *smp, const char return 0; temp = get_trash_chunk(); - for (pos = htx_get_head(htx); pos != -1; pos = htx_get_next(htx, pos)) { + for (pos = htx_get_first(htx); pos != -1; pos = htx_get_next(htx, pos)) { struct htx_blk *blk = htx_get_blk(htx, pos); enum htx_blk_type type = htx_get_blk_type(blk); @@ -915,7 +915,7 @@ static int smp_fetch_body_len(const struct arg *args, struct sample *smp, const if (!htx) return 0; - for (pos = htx_get_head(htx); pos != -1; pos = htx_get_next(htx, pos)) { + for (pos = htx_get_first(htx); pos != -1; pos = htx_get_next(htx, pos)) { struct htx_blk *blk = htx_get_blk(htx, pos); enum htx_blk_type type = htx_get_blk_type(blk); @@ -963,7 +963,7 @@ static int smp_fetch_body_size(const struct arg *args, struct sample *smp, const if (!htx) return 0; - for (pos = htx_get_head(htx); pos != -1; pos = htx_get_next(htx, pos)) { + for (pos = htx_get_first(htx); pos != -1; pos = htx_get_next(htx, pos)) { struct htx_blk *blk = htx_get_blk(htx, pos); enum htx_blk_type type = htx_get_blk_type(blk); @@ -1281,7 +1281,7 @@ static int smp_fetch_hdr_names(const struct arg *args, struct sample *smp, const del = *args[0].data.str.area; temp = get_trash_chunk(); - for (pos = htx_get_head(htx); pos != -1; pos = htx_get_next(htx, pos)) { + for (pos = htx_get_first(htx); pos != -1; pos = htx_get_next(htx, pos)) { struct htx_blk *blk = htx_get_blk(htx, pos); enum htx_blk_type type = htx_get_blk_type(blk); struct ist n; @@ -2590,7 +2590,7 @@ static int smp_fetch_body_param(const struct arg *args, struct sample *smp, cons return 0; temp = get_trash_chunk(); - for (pos = htx_get_head(htx); pos != -1; pos = htx_get_next(htx, pos)) { + for (pos = htx_get_first(htx); pos != -1; pos = htx_get_next(htx, pos)) { struct htx_blk *blk = htx_get_blk(htx, pos); enum htx_blk_type type = htx_get_blk_type(blk); diff --git a/src/http_htx.c b/src/http_htx.c index 8099071d4f..15865d5022 100644 --- a/src/http_htx.c +++ b/src/http_htx.c @@ -80,7 +80,7 @@ int http_find_header(const struct htx *htx, const struct ist name, if (!htx->used) return 0; - for (blk = htx_get_head_blk(htx); blk; blk = htx_get_next_blk(htx, blk)) { + for (blk = htx_get_first_blk(htx); blk; blk = htx_get_next_blk(htx, blk)) { rescan_hdr: type = htx_get_blk_type(blk); if (type == HTX_BLK_EOH || type == HTX_BLK_EOM) @@ -143,7 +143,7 @@ int http_add_header(struct htx *htx, const struct ist n, const struct ist v) /* is the head, swap it iteratively with its predecessor to place * it just before the end-of-header block. So blocks remains ordered. */ - for (prev = htx_get_prev(htx, htx->tail); prev != -1; prev = htx_get_prev(htx, prev)) { + for (prev = htx_get_prev(htx, htx->tail); prev != htx->sl_pos; prev = htx_get_prev(htx, prev)) { struct htx_blk *pblk = htx_get_blk(htx, prev); enum htx_blk_type type = htx_get_blk_type(pblk); diff --git a/src/proto_htx.c b/src/proto_htx.c index 35039fc535..dbbd937bdf 100644 --- a/src/proto_htx.c +++ b/src/proto_htx.c @@ -300,7 +300,7 @@ int htx_wait_for_request(struct stream *s, struct channel *req, int an_bit) htx_debug_stline("clireq", s, sl); - for (pos = htx_get_head(htx); pos != -1; pos = htx_get_next(htx, pos)) { + for (pos = htx_get_first(htx); pos != -1; pos = htx_get_next(htx, pos)) { struct htx_blk *blk = htx_get_blk(htx, pos); enum htx_blk_type type = htx_get_blk_type(blk); @@ -1655,7 +1655,7 @@ int htx_wait_for_response(struct stream *s, struct channel *rep, int an_bit) htx_debug_stline("srvrep", s, sl); - for (pos = htx_get_head(htx); pos != -1; pos = htx_get_next(htx, pos)) { + for (pos = htx_get_first(htx); pos != -1; pos = htx_get_next(htx, pos)) { struct htx_blk *blk = htx_get_blk(htx, pos); enum htx_blk_type type = htx_get_blk_type(blk); @@ -3531,7 +3531,7 @@ static int htx_apply_filter_to_req_headers(struct stream *s, struct channel *req htx = htxbuf(&req->buf); - for (pos = htx_get_head(htx); pos != -1; pos = htx_get_next(htx, pos)) { + for (pos = htx_get_first(htx); pos != -1; pos = htx_get_next(htx, pos)) { struct htx_blk *blk = htx_get_blk(htx, pos); enum htx_blk_type type; struct ist n, v; @@ -3749,7 +3749,7 @@ static int htx_apply_filter_to_resp_headers(struct stream *s, struct channel *re htx = htxbuf(&res->buf); - for (pos = htx_get_head(htx); pos != -1; pos = htx_get_next(htx, pos)) { + for (pos = htx_get_first(htx); pos != -1; pos = htx_get_next(htx, pos)) { struct htx_blk *blk = htx_get_blk(htx, pos); enum htx_blk_type type; struct ist n, v; @@ -4643,7 +4643,7 @@ void htx_check_request_for_cacheability(struct stream *s, struct channel *req) htx = htxbuf(&req->buf); pragma_found = cc_found = 0; - for (pos = htx_get_head(htx); pos != -1; pos = htx_get_next(htx, pos)) { + for (pos = htx_get_first(htx); pos != -1; pos = htx_get_next(htx, pos)) { struct htx_blk *blk = htx_get_blk(htx, pos); enum htx_blk_type type = htx_get_blk_type(blk); struct ist n, v; @@ -4731,7 +4731,7 @@ void htx_check_response_for_cacheability(struct stream *s, struct channel *res) } htx = htxbuf(&res->buf); - for (pos = htx_get_head(htx); pos != -1; pos = htx_get_next(htx, pos)) { + for (pos = htx_get_first(htx); pos != -1; pos = htx_get_next(htx, pos)) { struct htx_blk *blk = htx_get_blk(htx, pos); enum htx_blk_type type = htx_get_blk_type(blk); struct ist n, v; @@ -5564,7 +5564,7 @@ static void htx_capture_headers(struct htx *htx, char **cap, struct cap_hdr *cap struct cap_hdr *h; int32_t pos; - for (pos = htx_get_head(htx); pos != -1; pos = htx_get_next(htx, pos)) { + for (pos = htx_get_first(htx); pos != -1; pos = htx_get_next(htx, pos)) { struct htx_blk *blk = htx_get_blk(htx, pos); enum htx_blk_type type = htx_get_blk_type(blk); struct ist n, v; diff --git a/src/stats.c b/src/stats.c index 7d9a8a3a77..a8f9795c90 100644 --- a/src/stats.c +++ b/src/stats.c @@ -2788,7 +2788,7 @@ static int stats_process_http_post(struct stream_interface *si) } /* The request was fully received. Copy data */ - blk = htx_get_head_blk(htx); + blk = htx_get_first_blk(htx); while (blk) { enum htx_blk_type type = htx_get_blk_type(blk);