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.
This commit is contained in:
Christopher Faulet 2019-10-08 15:43:39 +02:00
parent d7b7a1ce50
commit 92916d343c

View File

@ -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) 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)) if (HTX_SL_LEN(sl) + 4 > b_room(chk))
return 0; 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, HTX_SL_REQ_MPTR(sl), HTX_SL_REQ_MLEN(sl));
chunk_memcat(chk, " ", 1); 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); chunk_memcat(chk, " ", 1);
if (sl->flags & HTX_SL_F_VER_11) if (sl->flags & HTX_SL_F_VER_11)
chunk_memcat(chk, "HTTP/1.1", 8); chunk_memcat(chk, "HTTP/1.1", 8);