mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 23:17:46 +00:00
Userland: Convert TLS::TLSv12 to a Core::Stream::Socket
This commit converts TLS::TLSv12 to a Core::Stream object, and in the process allows TLS to now wrap other Core::Stream::Socket objects. As a large part of LibHTTP and LibGemini depend on LibTLS's interface, this also converts those to support Core::Stream, which leads to a simplification of LibHTTP (as there's no need to care about the underlying socket type anymore). Note that RequestServer now controls the TLS socket options, which is a better place anyway, as RS is the first receiver of the user-requested options (though this is currently not particularly useful).
This commit is contained in:
parent
7a95c451a3
commit
aafc451016
47 changed files with 841 additions and 1157 deletions
|
@ -17,12 +17,17 @@
|
|||
namespace HTTP {
|
||||
|
||||
class Job : public Core::NetworkJob {
|
||||
C_OBJECT(Job);
|
||||
|
||||
public:
|
||||
explicit Job(HttpRequest&&, OutputStream&);
|
||||
explicit Job(HttpRequest&&, Core::Stream::Stream&);
|
||||
virtual ~Job() override;
|
||||
|
||||
virtual void start(NonnullRefPtr<Core::Socket>) override = 0;
|
||||
virtual void shutdown(ShutdownMode) override = 0;
|
||||
virtual void start(Core::Stream::Socket&) override;
|
||||
virtual void shutdown(ShutdownMode) override;
|
||||
|
||||
Core::Stream::Socket const* socket() const { return m_socket; }
|
||||
URL url() const { return m_request.url(); }
|
||||
|
||||
HttpResponse* response() { return static_cast<HttpResponse*>(Core::NetworkJob::response()); }
|
||||
const HttpResponse* response() const { return static_cast<const HttpResponse*>(Core::NetworkJob::response()); }
|
||||
|
@ -31,18 +36,10 @@ protected:
|
|||
void finish_up();
|
||||
void on_socket_connected();
|
||||
void flush_received_buffers();
|
||||
virtual void register_on_ready_to_read(Function<void()>) = 0;
|
||||
virtual void register_on_ready_to_write(Function<void()>) = 0;
|
||||
virtual bool can_read_line() const = 0;
|
||||
virtual String read_line(size_t) = 0;
|
||||
virtual bool can_read() const = 0;
|
||||
virtual ByteBuffer receive(size_t) = 0;
|
||||
virtual bool eof() const = 0;
|
||||
virtual bool write(ReadonlyBytes) = 0;
|
||||
virtual bool is_established() const = 0;
|
||||
virtual bool should_fail_on_empty_payload() const { return true; }
|
||||
virtual void read_while_data_available(Function<IterationDecision()> read) { read(); };
|
||||
virtual void timer_event(Core::TimerEvent&) override;
|
||||
void register_on_ready_to_read(Function<void()>);
|
||||
String read_line(size_t);
|
||||
ByteBuffer receive(size_t);
|
||||
void timer_event(Core::TimerEvent&) override;
|
||||
|
||||
enum class State {
|
||||
InStatus,
|
||||
|
@ -54,13 +51,13 @@ protected:
|
|||
|
||||
HttpRequest m_request;
|
||||
State m_state { State::InStatus };
|
||||
Core::Stream::BufferedSocketBase* m_socket { nullptr };
|
||||
int m_code { -1 };
|
||||
HashMap<String, String, CaseInsensitiveStringTraits> m_headers;
|
||||
Vector<String> m_set_cookie_headers;
|
||||
Vector<ByteBuffer, 2> m_received_buffers;
|
||||
size_t m_buffered_size { 0 };
|
||||
size_t m_received_size { 0 };
|
||||
bool m_sent_data { 0 };
|
||||
Optional<u32> m_content_length;
|
||||
Optional<ssize_t> m_current_chunk_remaining_size;
|
||||
Optional<size_t> m_current_chunk_total_size;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue