mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 08:08:12 +00:00
RequestServer+LibHTTP+LibGemini: Cache connections to the same host
This makes connections (particularly TLS-based ones) do the handshaking stuff only once. Currently the cache is configured to keep at most two connections evenly balanced in queue size, and with a grace period of 10s after the last queued job has finished (after which the connection will be dropped).
This commit is contained in:
parent
c5d7eb8618
commit
65f7e45a75
22 changed files with 295 additions and 51 deletions
|
@ -4,6 +4,8 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "ConnectionCache.h"
|
||||
#include <LibCore/EventLoop.h>
|
||||
#include <LibGemini/GeminiJob.h>
|
||||
#include <LibGemini/GeminiResponse.h>
|
||||
#include <RequestServer/GeminiRequest.h>
|
||||
|
@ -15,6 +17,9 @@ GeminiRequest::GeminiRequest(ClientConnection& client, NonnullRefPtr<Gemini::Gem
|
|||
, m_job(job)
|
||||
{
|
||||
m_job->on_finish = [this](bool success) {
|
||||
Core::deferred_invoke([url = m_job->url(), socket = m_job->socket()] {
|
||||
ConnectionCache::request_did_finish(url, socket);
|
||||
});
|
||||
if (auto* response = m_job->response()) {
|
||||
set_downloaded_size(this->output_stream().size());
|
||||
if (!response->meta().is_empty()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue