summaryrefslogtreecommitdiff
path: root/Userland/Services/RequestServer
diff options
context:
space:
mode:
authorArda Cinar <kuzux92@gmail.com>2023-01-13 20:01:34 +0300
committerAndreas Kling <kling@serenityos.org>2023-01-14 12:28:02 +0100
commitf883dc3eb042cf1058ca9db6f764e338b41a7b3a (patch)
tree85fc290371aa42e2098618d69ab743b93b44e756 /Userland/Services/RequestServer
parent0245a62f81f7d596838e80b3f342eae2deefcb17 (diff)
downloadserenity-f883dc3eb042cf1058ca9db6f764e338b41a7b3a.zip
RequestServer: Do not crash on Gemini responses
Starting a gemini request creates a pipe for the output stream for the response, and a Core::Stream::File object is created from that pipe. Previously, the length of the response was computed by calling output_stream.size() which used lseek on the file descriptor. Doing that returned an error from lseek. Computing the value by counting the received bytes (via Gemini::Job::response_length) avoids that crash.
Diffstat (limited to 'Userland/Services/RequestServer')
-rw-r--r--Userland/Services/RequestServer/GeminiRequest.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/Userland/Services/RequestServer/GeminiRequest.cpp b/Userland/Services/RequestServer/GeminiRequest.cpp
index 0ec84e7387..048338f30e 100644
--- a/Userland/Services/RequestServer/GeminiRequest.cpp
+++ b/Userland/Services/RequestServer/GeminiRequest.cpp
@@ -21,7 +21,7 @@ GeminiRequest::GeminiRequest(ConnectionFromClient& client, NonnullRefPtr<Gemini:
ConnectionCache::request_did_finish(url, socket);
});
if (auto* response = m_job->response()) {
- set_downloaded_size(MUST(const_cast<Core::Stream::File&>(this->output_stream()).size()));
+ set_downloaded_size(MUST(m_job->response_length()));
if (!response->meta().is_empty()) {
HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> headers;
headers.set("meta", response->meta());