]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mux-h1: Set flags about the request's scheme on the start-line
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 14 Jun 2019 08:31:25 +0000 (10:31 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 14 Jun 2019 09:13:32 +0000 (11:13 +0200)
We first try to figure out if the URI of the start-line is absolute or not. So,
if it does not start by a slash ("/"), it means the URI is an absolute one and
the flag HTX_SL_F_HAS_SCHM is set. Then checks are performed to know if the
scheme is "http" or "https" and the corresponding flag is set,
HTX_SL_F_SCHM_HTTP or HTX_SL_F_SCHM_HTTPS. Other schemes, for instance ftp, are
ignored.

src/mux_h1.c

index 2a6e401599dd034f772ebe6527f5fb46515ebed2..638d2036740f8ecb6a3d99a612bd5bc078333cc8 100644 (file)
@@ -1078,6 +1078,14 @@ static size_t h1_process_headers(struct h1s *h1s, struct h1m *h1m, struct htx *h
                if (!sl || !htx_add_all_headers(htx, hdrs))
                        goto error;
                sl->info.req.meth = h1s->meth;
+
+               /* Check if the uri contains an explicit scheme and if it is
+                * "http" or "https". */
+               if (h1sl.rq.u.len && h1sl.rq.u.ptr[0] != '/') {
+                       sl->flags |= HTX_SL_F_HAS_SCHM;
+                       if (h1sl.rq.u.len > 4 && (h1sl.rq.u.ptr[0] | 0x20) == 'h')
+                               sl->flags |= ((h1sl.rq.u.ptr[4] == ':') ? HTX_SL_F_SCHM_HTTP : HTX_SL_F_SCHM_HTTPS);
+               }
        }
        else {
                if (h1_eval_htx_res_size(h1m, &h1sl, hdrs) > max) {