From: Christopher Faulet Date: Tue, 8 Oct 2019 13:43:39 +0000 (+0200) Subject: MINOR: h1-htx: Only use the path of a normalized URI to format a request line X-Git-Tag: v2.1-dev3~128 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=92916d343cc2c12d59db8a2a7b04ccb721fb2809;p=thirdparty%2Fhaproxy.git MINOR: h1-htx: Only use the path of a normalized URI to format a request line When a request start-line is converted to its raw representation, if its URI is normalized, only the path part is used. Most of H2 clients send requests using the absolute form (:scheme + :authority + :path), regardless the request is sent to a proxy or not. But, when the request is relayed to an H1 origin server, it is unusual to send it using the absolute form. And, even if the servers must support this form, some old servers may reject it. So, for such requests, we only get the path of the absolute URI. Most of time, it will be the right choice. However, an option will probably by added to customize this behavior. --- diff --git a/src/htx.c b/src/htx.c index d8f435d447..c9671c12fc 100644 --- a/src/htx.c +++ b/src/htx.c @@ -1046,12 +1046,25 @@ void htx_move_blk_before(struct htx *htx, struct htx_blk **blk, struct htx_blk * */ int htx_reqline_to_h1(const struct htx_sl *sl, struct buffer *chk) { + struct ist uri; + if (HTX_SL_LEN(sl) + 4 > b_room(chk)) return 0; + uri = htx_sl_req_uri(sl); + if (sl->flags & HTX_SL_F_NORMALIZED_URI) { + uri = http_get_path(uri); + if (unlikely(!uri.len)) { + if (sl->info.req.meth == HTTP_METH_OPTIONS) + uri = ist("*"); + else + uri = ist("/"); + } + } + chunk_memcat(chk, HTX_SL_REQ_MPTR(sl), HTX_SL_REQ_MLEN(sl)); chunk_memcat(chk, " ", 1); - chunk_memcat(chk, HTX_SL_REQ_UPTR(sl), HTX_SL_REQ_ULEN(sl)); + chunk_memcat(chk, uri.ptr, uri.len); chunk_memcat(chk, " ", 1); if (sl->flags & HTX_SL_F_VER_11) chunk_memcat(chk, "HTTP/1.1", 8);