AK+LibURL: Move AK::URL into a new URL library

This URL library ends up being a relatively fundamental base library of
the system, as LibCore depends on LibURL.

This change has two main benefits:
 * Moving AK back more towards being an agnostic library that can
   be used between the kernel and userspace. URL has never really fit
   that description - and is not used in the kernel.
 * URL _should_ depend on LibUnicode, as it needs punnycode support.
   However, it's not really possible to do this inside of AK as it can't
   depend on any external library. This change brings us a little closer
   to being able to do that, but unfortunately we aren't there quite
   yet, as the code generators depend on LibCore.
This commit is contained in:
Shannon Booth 2024-03-18 16:22:27 +13:00 committed by Tim Flynn
commit e800605ad3
Notes: sideshowbarker 2024-07-17 04:41:05 +09:00
403 changed files with 1336 additions and 1305 deletions

View file

@ -6,4 +6,4 @@ set(SOURCES
)
serenity_lib(LibHTTP http)
target_link_libraries(LibHTTP PRIVATE LibCompress LibCore LibTLS)
target_link_libraries(LibHTTP PRIVATE LibCompress LibCore LibTLS LibURL)

View file

@ -7,9 +7,9 @@
#include <AK/Base64.h>
#include <AK/StringBuilder.h>
#include <AK/URLParser.h>
#include <LibHTTP/HttpRequest.h>
#include <LibHTTP/Job.h>
#include <LibURL/Parser.h>
namespace HTTP {
@ -269,7 +269,7 @@ void HttpRequest::set_headers(HashMap<ByteString, ByteString> const& headers)
m_headers.append({ it.key, it.value });
}
Optional<HttpRequest::Header> HttpRequest::get_http_basic_authentication_header(URL const& url)
Optional<HttpRequest::Header> HttpRequest::get_http_basic_authentication_header(URL::URL const& url)
{
if (!url.includes_credentials())
return {};

View file

@ -10,9 +10,9 @@
#include <AK/ByteBuffer.h>
#include <AK/ByteString.h>
#include <AK/Optional.h>
#include <AK/URL.h>
#include <AK/Vector.h>
#include <LibCore/Forward.h>
#include <LibURL/URL.h>
namespace HTTP {
@ -71,8 +71,8 @@ public:
ByteString const& resource() const { return m_resource; }
Vector<Header> const& headers() const { return m_headers; }
URL const& url() const { return m_url; }
void set_url(URL const& url) { m_url = url; }
URL::URL const& url() const { return m_url; }
void set_url(URL::URL const& url) { m_url = url; }
Method method() const { return m_method; }
void set_method(Method method) { m_method = method; }
@ -86,11 +86,11 @@ public:
void set_headers(HashMap<ByteString, ByteString> const&);
static ErrorOr<HttpRequest, HttpRequest::ParseError> from_raw_request(ReadonlyBytes);
static Optional<Header> get_http_basic_authentication_header(URL const&);
static Optional<Header> get_http_basic_authentication_header(URL::URL const&);
static Optional<BasicAuthenticationCredentials> parse_http_basic_authentication_header(ByteString const&);
private:
URL m_url;
URL::URL m_url;
ByteString m_resource;
Method m_method { GET };
Vector<Header> m_headers;

View file

@ -26,7 +26,7 @@ public:
virtual void shutdown(ShutdownMode) override;
Core::Socket const* socket() const { return m_socket; }
URL url() const { return m_request.url(); }
URL::URL url() const { return m_request.url(); }
HttpResponse* response() { return static_cast<HttpResponse*>(Core::NetworkJob::response()); }
HttpResponse const* response() const { return static_cast<HttpResponse const*>(Core::NetworkJob::response()); }