From f3103cc4b6c369da96c7de487214a9e56eca755d Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Mon, 18 Nov 2024 18:32:41 +0100 Subject: Always include the path "/" in HTTP requests Following https://datatracker.ietf.org/doc/html/rfc7230#section-5.3.1, the path must not be empty, even if we have a query: > If the target URI's path component is empty, the client MUST send "/" > as the path within the origin-form of request-target. Notice URIs can have empty paths, this is a restriction of HTTP only. Fixes: https://github.com/dillo-browser/dillo/issues/302 --- src/IO/http.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/IO') diff --git a/src/IO/http.c b/src/IO/http.c index f8a1ebb2..3c178bf1 100644 --- a/src/IO/http.c +++ b/src/IO/http.c @@ -407,11 +407,10 @@ static Dstr *Http_make_query_str(DilloWeb *web, bool_t use_proxy, bool_t use_tls dStr_sprintf(proxy_auth, "Proxy-Authorization: Basic %s\r\n", HTTP_Proxy_Auth_base64); } else { - dStr_sprintfa(request_uri, "%s%s%s%s", - URL_PATH(url), + dStr_sprintfa(request_uri, "%s%s%s", + URL_PATH_(url) ? URL_PATH(url) : "/", URL_QUERY_(url) ? "?" : "", - URL_QUERY(url), - (URL_PATH_(url) || URL_QUERY_(url)) ? "" : "/"); + URL_QUERY(url)); } cookies = a_Cookies_get_query(url, web->requester); -- cgit v1.2.3