mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-08 06:09:58 +00:00
LibHTTP: Remove unused HttpRequest functions re: basic auth
This commit is contained in:
parent
8a197b7ee5
commit
949053cee7
Notes:
github-actions[bot]
2025-11-28 13:49:36 +00:00
Author: https://github.com/awesomekling
Commit: 949053cee7
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6965
2 changed files with 0 additions and 44 deletions
|
|
@ -262,40 +262,4 @@ ErrorOr<HttpRequest, HttpRequest::ParseError> HttpRequest::from_raw_request(Read
|
|||
return request;
|
||||
}
|
||||
|
||||
Optional<Header> HttpRequest::get_http_basic_authentication_header(URL::URL const& url)
|
||||
{
|
||||
if (!url.includes_credentials())
|
||||
return {};
|
||||
StringBuilder builder;
|
||||
builder.append(URL::percent_decode(url.username()));
|
||||
builder.append(':');
|
||||
builder.append(URL::percent_decode(url.password()));
|
||||
|
||||
// FIXME: change to TRY() and make method fallible
|
||||
auto token = MUST(encode_base64(builder.string_view().bytes()));
|
||||
builder.clear();
|
||||
builder.append("Basic "sv);
|
||||
builder.append(token);
|
||||
return Header { "Authorization", builder.to_byte_string() };
|
||||
}
|
||||
|
||||
Optional<HttpRequest::BasicAuthenticationCredentials> HttpRequest::parse_http_basic_authentication_header(ByteString const& value)
|
||||
{
|
||||
if (!value.starts_with("Basic "sv, AK::CaseSensitivity::CaseInsensitive))
|
||||
return {};
|
||||
auto token = value.substring_view(6);
|
||||
if (token.is_empty())
|
||||
return {};
|
||||
auto decoded_token_bb = decode_base64(token);
|
||||
if (decoded_token_bb.is_error())
|
||||
return {};
|
||||
auto decoded_token = ByteString::copy(decoded_token_bb.value());
|
||||
auto colon_index = decoded_token.find(':');
|
||||
if (!colon_index.has_value())
|
||||
return {};
|
||||
auto username = decoded_token.substring_view(0, colon_index.value());
|
||||
auto password = decoded_token.substring_view(colon_index.value() + 1);
|
||||
return BasicAuthenticationCredentials { username, password };
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@
|
|||
#include <AK/ByteBuffer.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Noncopyable.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <LibCore/Forward.h>
|
||||
#include <LibHTTP/HeaderList.h>
|
||||
#include <LibURL/URL.h>
|
||||
|
|
@ -56,11 +55,6 @@ public:
|
|||
PUT,
|
||||
};
|
||||
|
||||
struct BasicAuthenticationCredentials {
|
||||
ByteString username;
|
||||
ByteString password;
|
||||
};
|
||||
|
||||
explicit HttpRequest(NonnullRefPtr<HeaderList>);
|
||||
~HttpRequest() = default;
|
||||
|
||||
|
|
@ -82,8 +76,6 @@ public:
|
|||
ErrorOr<ByteBuffer> to_raw_request() const;
|
||||
|
||||
static ErrorOr<HttpRequest, HttpRequest::ParseError> from_raw_request(ReadonlyBytes);
|
||||
static Optional<Header> get_http_basic_authentication_header(URL::URL const&);
|
||||
static Optional<BasicAuthenticationCredentials> parse_http_basic_authentication_header(ByteString const&);
|
||||
|
||||
private:
|
||||
URL::URL m_url;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue