MINOR: mux-h1: Set flags about the request's scheme on the start-line

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.
This commit is contained in:
Christopher Faulet 2019-06-14 10:31:25 +02:00
parent a9a5c04c23
commit 42993a86c9

View 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) {