From f1dc8e12d2fa53e82951977429f358405108ed91 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Mon, 17 May 2021 20:43:33 +0200 Subject: [PATCH] LibHTTP: Make sure we're not sending an empty path in requests When the path component of the request URL was empty we'd end up sending requests like "GET HTTP/1.1" (note the missing /). This ensures that we always send a path. --- Userland/Libraries/LibHTTP/HttpRequest.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibHTTP/HttpRequest.cpp b/Userland/Libraries/LibHTTP/HttpRequest.cpp index 0351cb97bb..b642a17930 100644 --- a/Userland/Libraries/LibHTTP/HttpRequest.cpp +++ b/Userland/Libraries/LibHTTP/HttpRequest.cpp @@ -37,7 +37,10 @@ ByteBuffer HttpRequest::to_raw_request() const StringBuilder builder; builder.append(method_name()); builder.append(' '); - builder.append(m_url.path()); + if (!m_url.path().is_empty()) + builder.append(m_url.path()); + else + builder.append('/'); if (!m_url.query().is_empty()) { builder.append('?'); builder.append(m_url.query());