mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-03 16:16:43 +00:00
LibHTTP+RequestServer: Use HTTP::HeaderMap for request headers
No longer just for response headers! The same type is obviously useful and ergonomic when making requests as well.
This commit is contained in:
parent
5ac0938859
commit
260c5c50ad
Notes:
sideshowbarker
2024-07-16 22:58:46 +09:00
Author: https://github.com/awesomekling
Commit: 260c5c50ad
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/116
20 changed files with 41 additions and 54 deletions
|
@ -12,6 +12,7 @@
|
|||
#include <AK/Optional.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibCore/Forward.h>
|
||||
#include <LibHTTP/HeaderMap.h>
|
||||
#include <LibURL/URL.h>
|
||||
|
||||
namespace HTTP {
|
||||
|
@ -55,11 +56,6 @@ public:
|
|||
PUT,
|
||||
};
|
||||
|
||||
struct Header {
|
||||
ByteString name;
|
||||
ByteString value;
|
||||
};
|
||||
|
||||
struct BasicAuthenticationCredentials {
|
||||
ByteString username;
|
||||
ByteString password;
|
||||
|
@ -69,7 +65,7 @@ public:
|
|||
~HttpRequest() = default;
|
||||
|
||||
ByteString const& resource() const { return m_resource; }
|
||||
Vector<Header> const& headers() const { return m_headers; }
|
||||
HeaderMap const& headers() const { return m_headers; }
|
||||
|
||||
URL::URL const& url() const { return m_url; }
|
||||
void set_url(URL::URL const& url) { m_url = url; }
|
||||
|
@ -83,7 +79,7 @@ public:
|
|||
StringView method_name() const;
|
||||
ErrorOr<ByteBuffer> to_raw_request() const;
|
||||
|
||||
void set_headers(HashMap<ByteString, ByteString> const&);
|
||||
void set_headers(HeaderMap);
|
||||
|
||||
static ErrorOr<HttpRequest, HttpRequest::ParseError> from_raw_request(ReadonlyBytes);
|
||||
static Optional<Header> get_http_basic_authentication_header(URL::URL const&);
|
||||
|
@ -93,7 +89,7 @@ private:
|
|||
URL::URL m_url;
|
||||
ByteString m_resource;
|
||||
Method m_method { GET };
|
||||
Vector<Header> m_headers;
|
||||
HeaderMap m_headers;
|
||||
ByteBuffer m_body;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue