LibHTTP: Don't double percent encode path in HTTPRequst::to_raw_request

This was a goof in cc55732332 which
resulted in the URL path getting double percent encoded. Since the path
already comes out percent encoded following the rules in the URL spec -
we don't need to percent encode again.

Fixes: #978
This commit is contained in:
Shannon Booth 2024-08-06 17:02:56 +12:00 committed by Tim Ledbetter
parent 8723f72f0f
commit 2995a57f63
Notes: github-actions[bot] 2024-08-06 07:19:13 +00:00

View file

@ -49,10 +49,9 @@ ErrorOr<ByteBuffer> HttpRequest::to_raw_request() const
StringBuilder builder;
TRY(builder.try_append(method_name()));
TRY(builder.try_append(' '));
// NOTE: The percent_encode is so that e.g. spaces are properly encoded.
auto path = m_url.serialize_path();
VERIFY(!path.is_empty());
TRY(builder.try_append(URL::percent_encode(path, URL::PercentEncodeSet::EncodeURI)));
TRY(builder.try_append(path));
if (m_url.query().has_value()) {
TRY(builder.try_append('?'));
TRY(builder.try_append(*m_url.query()));