mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 00:50:22 +00:00
LibHTTP: Make HTTPRequest::from_raw_request() take a ReadonlyBytes
This allows us to get rid of some ByteBuffer::wrap() usage.
This commit is contained in:
parent
e517505e35
commit
48d74c5356
Notes:
sideshowbarker
2024-07-19 00:44:29 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/48d74c53565
5 changed files with 6 additions and 6 deletions
|
@ -79,7 +79,7 @@ ByteBuffer HttpRequest::to_raw_request() const
|
|||
return builder.to_byte_buffer();
|
||||
}
|
||||
|
||||
Optional<HttpRequest> HttpRequest::from_raw_request(const ByteBuffer& raw_request)
|
||||
Optional<HttpRequest> HttpRequest::from_raw_request(ReadonlyBytes raw_request)
|
||||
{
|
||||
enum class State {
|
||||
InMethod,
|
||||
|
|
|
@ -69,7 +69,7 @@ public:
|
|||
|
||||
void set_headers(const HashMap<String, String>&);
|
||||
|
||||
static Optional<HttpRequest> from_raw_request(const ByteBuffer&);
|
||||
static Optional<HttpRequest> from_raw_request(ReadonlyBytes);
|
||||
|
||||
private:
|
||||
URL m_url;
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
auto request_wrapper = HTTP::HttpRequest::from_raw_request(ByteBuffer::wrap(const_cast<u8*>(data), size));
|
||||
auto request_wrapper = HTTP::HttpRequest::from_raw_request(ReadonlyBytes { data, size });
|
||||
if (!request_wrapper.has_value())
|
||||
return 1;
|
||||
|
||||
|
|
|
@ -65,12 +65,12 @@ void Client::start()
|
|||
|
||||
dbg() << "Got raw request: '" << String::copy(raw_request) << "'";
|
||||
|
||||
handle_request(move(raw_request));
|
||||
handle_request(raw_request.bytes());
|
||||
die();
|
||||
};
|
||||
}
|
||||
|
||||
void Client::handle_request(ByteBuffer raw_request)
|
||||
void Client::handle_request(ReadonlyBytes raw_request)
|
||||
{
|
||||
auto request_or_error = HTTP::HttpRequest::from_raw_request(raw_request);
|
||||
if (!request_or_error.has_value())
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
private:
|
||||
Client(NonnullRefPtr<Core::TCPSocket>, const String&, Core::Object* parent);
|
||||
|
||||
void handle_request(ByteBuffer);
|
||||
void handle_request(ReadonlyBytes);
|
||||
void send_response(StringView, const HTTP::HttpRequest&, const String& content_type);
|
||||
void send_redirect(StringView redirect, const HTTP::HttpRequest& request);
|
||||
void send_error_response(unsigned code, const StringView& message, const HTTP::HttpRequest&);
|
||||
|
|
Loading…
Reference in a new issue