1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 06:17:35 +00:00

LibCore: Allow constructing a Core::HttpRequest from a raw HTTP request

This patch adds a very simple HTTP request parser that can be useful
for implementing say.. a web server. :^)
This commit is contained in:
Andreas Kling 2020-02-09 11:27:36 +01:00
parent a189285658
commit 3a7e49fe07
2 changed files with 119 additions and 0 deletions

View file

@ -26,6 +26,7 @@
#pragma once
#include <AK/Optional.h>
#include <AK/String.h>
#include <AK/URL.h>
@ -42,9 +43,17 @@ public:
POST
};
struct Header {
String name;
String value;
};
HttpRequest();
~HttpRequest();
const String& resource() const { return m_resource; }
const Vector<Header>& headers() const { return m_headers; }
const URL& url() const { return m_url; }
void set_url(const URL& url) { m_url = url; }
@ -56,9 +65,13 @@ public:
RefPtr<NetworkJob> schedule();
static Optional<HttpRequest> from_raw_request(const ByteBuffer&);
private:
URL m_url;
String m_resource;
Method m_method { GET };
Vector<Header> m_headers;
};
}