]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: htx: Remove support of pseudo headers because it is unused
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 24 May 2019 12:54:00 +0000 (14:54 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 28 May 2019 05:42:33 +0000 (07:42 +0200)
The code to handle pseudo headers is unused and with no real value. So remove
it.

include/common/htx.h
src/htx.c
src/mux_h1.c

index 7840af672c1809b019a1d21354cf8a0a6f010b38..a6065a6e3704fa42f7a81575375bb7fe4315a505 100644 (file)
 #define HTX_FL_UPGRADE           0x00000002
 
 
-/* Pseudo header types (max 255). */
-enum htx_phdr_type {
-       HTX_PHDR_UNKNOWN =  0,
-       HTX_PHDR_SIZE,
-};
-
 /* HTTP block's type (max 15). */
 enum htx_blk_type {
        HTX_BLK_REQ_SL =  0, /* Request start-line */
        HTX_BLK_RES_SL =  1, /* Response start-line */
        HTX_BLK_HDR    =  2, /* header name/value block */
-       HTX_BLK_PHDR   =  3, /* pseudo header block */
-       HTX_BLK_EOH    =  4, /* end-of-headers block */
-       HTX_BLK_DATA   =  5, /* data block */
-       HTX_BLK_EOD    =  6, /* end-of-data block */
-       HTX_BLK_TLR    =  7, /* trailer name/value block */
-       HTX_BLK_EOM    =  8, /* end-of-message block */
-       /* 9 .. 14 unused */
+       HTX_BLK_EOH    =  3, /* end-of-headers block */
+       HTX_BLK_DATA   =  4, /* data block */
+       HTX_BLK_EOD    =  5, /* end-of-data block */
+       HTX_BLK_TLR    =  6, /* trailer name/value block */
+       HTX_BLK_EOM    =  7, /* end-of-message block */
+       /* 8 .. 14 unused */
        HTX_BLK_UNUSED = 15, /* unused/removed block */
 };
 
@@ -191,7 +184,6 @@ struct htx_blk *htx_replace_header(struct htx *htx, struct htx_blk *blk,
 struct htx_blk *htx_add_header(struct htx *htx, const struct ist name, const struct ist value);
 struct htx_blk *htx_add_blk_type_size(struct htx *htx, enum htx_blk_type type, uint32_t blksz);
 struct htx_blk *htx_add_all_headers(struct htx *htx, const struct http_hdr *hdrs);
-struct htx_blk *htx_add_pseudo_header(struct htx *htx,  enum htx_phdr_type phdr, const struct ist value);
 struct htx_blk *htx_add_endof(struct htx *htx, enum htx_blk_type type);
 struct htx_blk *htx_add_data(struct htx *htx, const struct ist data);
 struct htx_blk *htx_add_trailer(struct htx *htx, const struct ist tlr);
@@ -299,25 +291,6 @@ static inline enum htx_blk_type htx_get_blk_type(const struct htx_blk *blk)
        return (blk->info >> 28);
 }
 
-/* Returns the pseudo-header type of the block <blk>. If it's not a
- * pseudo-header, HTX_PHDR_UNKNOWN is returned.
- */
-static inline enum htx_phdr_type htx_get_blk_phdr(const struct htx_blk *blk)
-{
-       enum htx_blk_type type = htx_get_blk_type(blk);
-       enum htx_phdr_type phdr;
-
-       switch (type) {
-               case HTX_BLK_PHDR:
-                       phdr = (blk->info & 0xff);
-                       return phdr;
-
-               default:
-                       /* Not a pseudo-header */
-                       return HTX_PHDR_UNKNOWN;
-       }
-}
-
 /* Returns the size of the block <blk>, depending of its type */
 static inline uint32_t htx_get_blksz(const struct htx_blk *blk)
 {
@@ -327,9 +300,6 @@ static inline uint32_t htx_get_blksz(const struct htx_blk *blk)
                case HTX_BLK_HDR:
                        /*       name.length       +        value.length        */
                        return ((blk->info & 0xff) + ((blk->info >> 8) & 0xfffff));
-               case HTX_BLK_PHDR:
-                       /*          value.length          */
-                       return ((blk->info >> 8) & 0xfffff);
                default:
                        /*         value.length      */
                        return (blk->info & 0xfffffff);
@@ -542,7 +512,6 @@ static inline void htx_set_blk_value_len(struct htx_blk *blk, uint32_t vlen)
 
        switch (type) {
                case HTX_BLK_HDR:
-               case HTX_BLK_PHDR:
                        blk->info = (type << 28) + (vlen << 8) + (blk->info & 0xff);
                        break;
                case HTX_BLK_REQ_SL:
@@ -598,11 +567,6 @@ static inline struct ist htx_get_blk_value(const struct htx *htx, const struct h
                        ret.len = (blk->info >> 8) & 0xfffff;
                        break;
 
-               case HTX_BLK_PHDR:
-                       ret.ptr = htx_get_blk_ptr(htx, blk);
-                       ret.len = (blk->info >> 8) & 0xfffff;
-                       break;
-
                case HTX_BLK_REQ_SL:
                case HTX_BLK_RES_SL:
                case HTX_BLK_DATA:
@@ -786,7 +750,6 @@ static inline const char *htx_blk_type_str(enum htx_blk_type type)
                case HTX_BLK_REQ_SL: return "HTX_BLK_REQ_SL";
                case HTX_BLK_RES_SL: return "HTX_BLK_RES_SL";
                case HTX_BLK_HDR:    return "HTX_BLK_HDR";
-               case HTX_BLK_PHDR:   return "HTX_BLK_PHDR";
                case HTX_BLK_EOH:    return "HTX_BLK_EOH";
                case HTX_BLK_DATA:   return "HTX_BLK_DATA";
                case HTX_BLK_EOD:    return "HTX_BLK_EOD";
@@ -797,14 +760,6 @@ static inline const char *htx_blk_type_str(enum htx_blk_type type)
        };
 }
 
-static inline const char *htx_blk_phdr_str(enum htx_phdr_type phdr)
-{
-       switch (phdr) {
-               case HTX_PHDR_UNKNOWN: return "HTX_PHDR_UNKNOWN";
-               default:               return "HTX_PHDR_???";
-       }
-}
-
 static inline void htx_dump(struct htx *htx)
 {
        int32_t pos;
@@ -819,7 +774,6 @@ static inline void htx_dump(struct htx *htx)
                struct htx_sl     *sl;
                struct htx_blk    *blk  = htx_get_blk(htx, pos);
                enum htx_blk_type  type = htx_get_blk_type(blk);
-               enum htx_phdr_type phdr = htx_get_blk_phdr(blk);
                uint32_t           sz   = htx_get_blksz(blk);
                struct ist         n, v;
 
@@ -839,11 +793,6 @@ static inline void htx_dump(struct htx *htx)
                                pos, htx_blk_type_str(type), sz, blk->addr,
                                (int)n.len, n.ptr,
                                (int)v.len, v.ptr);
-
-               else if (type == HTX_BLK_PHDR)
-                       fprintf(stderr, "\t\t[%u] type=%-17s - size=%-6u - addr=%-6u\t%.*s\n",
-                               pos, htx_blk_phdr_str(phdr), sz, blk->addr,
-                               (int)v.len, v.ptr);
                else
                        fprintf(stderr, "\t\t[%u] type=%-17s - size=%-6u - addr=%-6u%s\n",
                                pos, htx_blk_type_str(type), sz, blk->addr,
index 8ff643633618c71ccb5f041dede2190c78b98fbe..7bdeec1c37e084cdb46d5f7ba8d4c9b2ae1ee2f4 100644 (file)
--- a/src/htx.c
+++ b/src/htx.c
@@ -528,7 +528,7 @@ struct htx_ret htx_xfer_blks(struct htx *dst, struct htx *src, uint32_t count,
                if (!max)
                        break;
                if (sz > max) {
-                       /* Headers and pseudo headers must be fully copied  */
+                       /* Headers must be fully copied  */
                        if (type != HTX_BLK_DATA)
                                break;
                        sz = max;
@@ -744,23 +744,6 @@ struct htx_blk *htx_add_all_headers(struct htx *htx, const struct http_hdr *hdrs
        }
        return htx_add_endof(htx, HTX_BLK_EOH);
 }
-/* Adds an HTX block of type PHDR in <htx>. It returns the new block on
- * success. Otherwise, it returns NULL.
- */
-struct htx_blk *htx_add_pseudo_header(struct htx *htx,  enum htx_phdr_type phdr,
-                                     const struct ist value)
-{
-       struct htx_blk *blk;
-
-       /* FIXME: check value.len ( < 1MB) */
-       blk = htx_add_blk(htx, HTX_BLK_PHDR, value.len);
-       if (!blk)
-               return NULL;
-
-       blk->info += (value.len << 8) + phdr;
-       memcpy(htx_get_blk_ptr(htx, blk), value.ptr, value.len);
-       return blk;
-}
 
 /* Adds an HTX block of type EOH,EOD or EOM in <htx>. It returns the new block
  * on success. Otherwise, it returns NULL.
index 881501eb0cac330cc00c51fa8075d4727b37bd63..d1e7c1d76bf0788b24ec4418c61ce2da5942df71 100644 (file)
@@ -1574,11 +1574,6 @@ static size_t h1_process_output(struct h1c *h1c, struct buffer *buf, size_t coun
                                h1m->state = H1_MSG_HDR_L2_LWS;
                                break;
 
-                       case HTX_BLK_PHDR:
-                               /* not implemented yet */
-                               h1m->flags |= errflag;
-                               break;
-
                        case HTX_BLK_EOH:
                                if (h1m->state != H1_MSG_LAST_LF && process_conn_mode) {
                                        /* There is no "Connection:" header and