mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:47:35 +00:00
WebServer: Handle incomplete HTTP requests
Mostly by copying the code in LibWeb/WebDriver/Client.cpp
This commit is contained in:
parent
ce8f1939e9
commit
cce5e3158f
2 changed files with 52 additions and 49 deletions
|
@ -24,12 +24,15 @@ public:
|
|||
private:
|
||||
Client(NonnullOwnPtr<Core::BufferedTCPSocket>, Core::Object* parent);
|
||||
|
||||
using WrappedError = Variant<AK::Error, HTTP::HttpRequest::ParseError>;
|
||||
|
||||
struct ContentInfo {
|
||||
String type;
|
||||
size_t length {};
|
||||
};
|
||||
|
||||
ErrorOr<bool> handle_request(ReadonlyBytes);
|
||||
ErrorOr<void, WrappedError> on_ready_to_read();
|
||||
ErrorOr<bool> handle_request(HTTP::HttpRequest const&);
|
||||
ErrorOr<void> send_response(Stream&, HTTP::HttpRequest const&, ContentInfo);
|
||||
ErrorOr<void> send_redirect(StringView redirect, HTTP::HttpRequest const&);
|
||||
ErrorOr<void> send_error_response(unsigned code, HTTP::HttpRequest const&, Vector<String> const& headers = {});
|
||||
|
@ -39,6 +42,7 @@ private:
|
|||
bool verify_credentials(Vector<HTTP::HttpRequest::Header> const&);
|
||||
|
||||
NonnullOwnPtr<Core::BufferedTCPSocket> m_socket;
|
||||
StringBuilder m_remaining_request;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue