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.
This commit is contained in:
Christopher Faulet 2019-05-13 15:27:23 +02:00 committed by Willy Tarreau
parent 7b7d507a5b
commit a3f1550dfa
10 changed files with 27 additions and 27 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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)

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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)
/* <blk> 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);

View File

@ -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;

View File

@ -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);