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.
This commit is contained in:
Arda Cinar 2023-01-13 20:01:34 +03:00 committed by Andreas Kling
parent 0245a62f81
commit f883dc3eb0
Notes: sideshowbarker 2024-07-17 01:44:01 +09:00

View file

@ -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());