Skip to content

Commit 949053c

Browse files
awesomeklingtrflynn89
authored andcommitted
LibHTTP: Remove unused HttpRequest functions re: basic auth
1 parent 8a197b7 commit 949053c

File tree

2 files changed

+0
-44
lines changed

2 files changed

+0
-44
lines changed

Libraries/LibHTTP/HttpRequest.cpp

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -262,40 +262,4 @@ ErrorOr<HttpRequest, HttpRequest::ParseError> HttpRequest::from_raw_request(Read
262262
return request;
263263
}
264264

265-
Optional<Header> HttpRequest::get_http_basic_authentication_header(URL::URL const& url)
266-
{
267-
if (!url.includes_credentials())
268-
return {};
269-
StringBuilder builder;
270-
builder.append(URL::percent_decode(url.username()));
271-
builder.append(':');
272-
builder.append(URL::percent_decode(url.password()));
273-
274-
// FIXME: change to TRY() and make method fallible
275-
auto token = MUST(encode_base64(builder.string_view().bytes()));
276-
builder.clear();
277-
builder.append("Basic "sv);
278-
builder.append(token);
279-
return Header { "Authorization", builder.to_byte_string() };
280-
}
281-
282-
Optional<HttpRequest::BasicAuthenticationCredentials> HttpRequest::parse_http_basic_authentication_header(ByteString const& value)
283-
{
284-
if (!value.starts_with("Basic "sv, AK::CaseSensitivity::CaseInsensitive))
285-
return {};
286-
auto token = value.substring_view(6);
287-
if (token.is_empty())
288-
return {};
289-
auto decoded_token_bb = decode_base64(token);
290-
if (decoded_token_bb.is_error())
291-
return {};
292-
auto decoded_token = ByteString::copy(decoded_token_bb.value());
293-
auto colon_index = decoded_token.find(':');
294-
if (!colon_index.has_value())
295-
return {};
296-
auto username = decoded_token.substring_view(0, colon_index.value());
297-
auto password = decoded_token.substring_view(colon_index.value() + 1);
298-
return BasicAuthenticationCredentials { username, password };
299-
}
300-
301265
}

Libraries/LibHTTP/HttpRequest.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include <AK/ByteBuffer.h>
1111
#include <AK/ByteString.h>
1212
#include <AK/Noncopyable.h>
13-
#include <AK/Optional.h>
1413
#include <LibCore/Forward.h>
1514
#include <LibHTTP/HeaderList.h>
1615
#include <LibURL/URL.h>
@@ -56,11 +55,6 @@ class HttpRequest {
5655
PUT,
5756
};
5857

59-
struct BasicAuthenticationCredentials {
60-
ByteString username;
61-
ByteString password;
62-
};
63-
6458
explicit HttpRequest(NonnullRefPtr<HeaderList>);
6559
~HttpRequest() = default;
6660

@@ -82,8 +76,6 @@ class HttpRequest {
8276
ErrorOr<ByteBuffer> to_raw_request() const;
8377

8478
static ErrorOr<HttpRequest, HttpRequest::ParseError> from_raw_request(ReadonlyBytes);
85-
static Optional<Header> get_http_basic_authentication_header(URL::URL const&);
86-
static Optional<BasicAuthenticationCredentials> parse_http_basic_authentication_header(ByteString const&);
8779

8880
private:
8981
URL::URL m_url;

0 commit comments

Comments
 (0)