mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
LibCore: Make NetworkJob::start()
take a Stream::BufferedSocketBase&
It used to take a plain `Socket` and cast it to a `BufferedSocketBase`, which can lead to unpleasant result when used with a non-buffered `Socket`.
This commit is contained in:
parent
5fc873f53b
commit
ff47223301
Notes:
sideshowbarker
2024-07-16 18:26:46 +09:00
Author: https://github.com/LucasChollet Commit: https://github.com/SerenityOS/serenity/commit/ff47223301 Pull-request: https://github.com/SerenityOS/serenity/pull/19764 Reviewed-by: https://github.com/alimpfard ✅ Reviewed-by: https://github.com/gmta ✅ Reviewed-by: https://github.com/shannonbooth
6 changed files with 8 additions and 8 deletions
|
@ -41,7 +41,7 @@ public:
|
|||
DetachFromSocket,
|
||||
CloseSocket,
|
||||
};
|
||||
virtual void start(Core::Socket&) = 0;
|
||||
virtual void start(Core::BufferedSocketBase&) = 0;
|
||||
virtual void shutdown(ShutdownMode) = 0;
|
||||
virtual void fail(Error error) { did_fail(error); }
|
||||
|
||||
|
|
|
@ -20,10 +20,10 @@ Job::Job(GeminiRequest const& request, Stream& output_stream)
|
|||
{
|
||||
}
|
||||
|
||||
void Job::start(Core::Socket& socket)
|
||||
void Job::start(Core::BufferedSocketBase& socket)
|
||||
{
|
||||
VERIFY(!m_socket);
|
||||
m_socket = verify_cast<Core::BufferedSocketBase>(&socket);
|
||||
m_socket = &socket;
|
||||
on_socket_connected();
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ public:
|
|||
explicit Job(GeminiRequest const&, Stream&);
|
||||
virtual ~Job() override = default;
|
||||
|
||||
virtual void start(Core::Socket&) override;
|
||||
virtual void start(Core::BufferedSocketBase&) override;
|
||||
virtual void shutdown(ShutdownMode) override;
|
||||
|
||||
GeminiResponse* response() { return static_cast<GeminiResponse*>(Core::NetworkJob::response()); }
|
||||
|
|
|
@ -92,10 +92,10 @@ Job::Job(HttpRequest&& request, Stream& output_stream)
|
|||
{
|
||||
}
|
||||
|
||||
void Job::start(Core::Socket& socket)
|
||||
void Job::start(Core::BufferedSocketBase& socket)
|
||||
{
|
||||
VERIFY(!m_socket);
|
||||
m_socket = static_cast<Core::BufferedSocketBase*>(&socket);
|
||||
m_socket = &socket;
|
||||
dbgln_if(HTTPJOB_DEBUG, "Reusing previous connection for {}", url());
|
||||
deferred_invoke([this] {
|
||||
dbgln_if(HTTPJOB_DEBUG, "HttpJob: on_connected callback");
|
||||
|
|
|
@ -22,7 +22,7 @@ public:
|
|||
explicit Job(HttpRequest&&, Stream&);
|
||||
virtual ~Job() override = default;
|
||||
|
||||
virtual void start(Core::Socket&) override;
|
||||
virtual void start(Core::BufferedSocketBase&) override;
|
||||
virtual void shutdown(ShutdownMode) override;
|
||||
|
||||
Core::Socket const* socket() const { return m_socket; }
|
||||
|
|
|
@ -56,7 +56,7 @@ struct Proxy {
|
|||
template<typename Socket, typename SocketStorageType = Socket>
|
||||
struct Connection {
|
||||
struct JobData {
|
||||
Function<void(Core::Socket&)> start {};
|
||||
Function<void(Core::BufferedSocketBase&)> start {};
|
||||
Function<void(Core::NetworkJob::Error)> fail {};
|
||||
Function<Vector<TLS::Certificate>()> provide_client_certificates {};
|
||||
|
||||
|
|
Loading…
Reference in a new issue