From f43d6a95cd8b2ad37edf3c956ae299a9045702b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Fri, 28 Jun 2024 11:18:38 +0200 Subject: [PATCH] Fix handling of the request URI for HTTP/2. --- source/vibe/http/internal/http2/exchange.d | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/source/vibe/http/internal/http2/exchange.d b/source/vibe/http/internal/http2/exchange.d index 9d8cf18..3d8351f 100644 --- a/source/vibe/http/internal/http2/exchange.d +++ b/source/vibe/http/internal/http2/exchange.d @@ -216,9 +216,6 @@ bool handleHTTP2Request(UStream)(ref HTTP2ConnectionStream!UStream stream, req.host = tcp_connection.localAddress.toString; } - if(req.tls) req.requestURI = "https://" ~ req.host ~ req.path; - else req.requestURI = "http://" ~ req.host ~ req.path; - string reqhost; ushort reqport = 0; { @@ -689,15 +686,19 @@ void parseHTTP2RequestHeader(R)(ref R headers, HTTPServerRequest req) @safe if(!host.empty) req.host = cast(string)host[0].value; //Path - req.requestPath = InetPath(cast(string)headers.find!((h,m) => h.name == m)(":path")[0].value); + auto pathstr = cast(string)headers.find!((h,m) => h.name == m)(":path")[0].value; + if(req.tls) req.requestURI = "https://" ~ req.host ~ pathstr; + else req.requestURI = "http://" ~ req.host ~ pathstr; - //URI - req.requestURI = req.host; + auto url = URL.parse(req.requestURI); + req.queryString = url.queryString; + req.username = url.username; + req.password = url.password; + req.requestPath = url.path; //HTTP version req.httpVersion = HTTPVersion.HTTP_2; - //headers foreach(h; headers.filter!(f => !f.name.startsWith(":"))) { req.headers[h.name] = cast(string)h.value;