]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: http/htx: Perform analysis relatively to the first block
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 13 May 2019 13:27:23 +0000 (15:27 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 28 May 2019 05:42:12 +0000 (07:42 +0200)
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.

src/backend.c
src/cache.c
src/da.c
src/filters.c
src/flt_trace.c
src/hlua.c
src/http_fetch.c
src/http_htx.c
src/proto_htx.c
src/stats.c

index fc006666580011d0746964fbce964b1762ef6b4b..88991a8281d5653f3a08b9511a687867258ef6cb 100644 (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;
 
index 188efea177b1bfb161b98a94e64bde7b3afe657a..1fec57e240df5bc36f1a8e51731b6d1ee8fed9d8 100644 (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);
index 6c7ce814e0c8e706ca416dcbf008e3b673cf556f..f5e01352853956caaf90c78c144e009674ec1d73 100644 (file)
--- 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;
index 95ba7728bd09cd2e90b974de2ae0136d76b9f57e..62e256ee96f1cad560e27ecfce9ad9d67fbd7097 100644 (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)
index ed159e8a7c10156251e29de752ccaf385398cce6..3a142448920a181608cb2848ddc9aea905e443c4 100644 (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;
index 72ce6bab60059c1ba1aa3d1f82903cbaf4ae4e25..bb8c93da6b7f7bc69aac08463ffe7a64be191679 100644 (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);
index 0a5a2f91f79abe0cb7d8081e123f52a622cbefb2..395e665e9df607ce7785781adb757e64aac85291 100644 (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);
 
index 8099071d4ff4940fc868c847da390db1ee4168bb..15865d5022a1803e6f8b13fc38f3472f58fa35f1 100644 (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);
 
index 35039fc5355f6bc1790240fca5b75d864e2cca37..dbbd937bdf14bafea0270cfa2b7034d3552e9e06 100644 (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;
index 7d9a8a3a7757be17d95912f81bacf3fd209eb604..a8f9795c905d20b8a27dd7c356d288d9e6594f23 100644 (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);