summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibHTTP/HttpRequest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Libraries/LibHTTP/HttpRequest.cpp')
-rw-r--r--Userland/Libraries/LibHTTP/HttpRequest.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/Userland/Libraries/LibHTTP/HttpRequest.cpp b/Userland/Libraries/LibHTTP/HttpRequest.cpp
index b642a17930..32e1c3fbc9 100644
--- a/Userland/Libraries/LibHTTP/HttpRequest.cpp
+++ b/Userland/Libraries/LibHTTP/HttpRequest.cpp
@@ -37,13 +37,13 @@ ByteBuffer HttpRequest::to_raw_request() const
StringBuilder builder;
builder.append(method_name());
builder.append(' ');
- if (!m_url.path().is_empty())
- builder.append(m_url.path());
- else
- builder.append('/');
+ // NOTE: The percent_encode is so that e.g. spaces are properly encoded.
+ auto path = m_url.path();
+ VERIFY(!path.is_empty());
+ builder.append(URL::percent_encode(m_url.path(), URL::PercentEncodeSet::EncodeURI));
if (!m_url.query().is_empty()) {
builder.append('?');
- builder.append(m_url.query());
+ builder.append(URL::percent_encode(m_url.query(), URL::PercentEncodeSet::EncodeURI));
}
builder.append(" HTTP/1.1\r\nHost: ");
builder.append(m_url.host());
@@ -163,7 +163,7 @@ Optional<HttpRequest> HttpRequest::from_raw_request(ReadonlyBytes raw_request)
else
return {};
- request.m_resource = resource;
+ request.m_resource = URL::percent_decode(resource);
request.m_headers = move(headers);
return request;