mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-08 04:15:23 +03:00
6e19ab2bbc
We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
40 lines
1.3 KiB
C++
40 lines
1.3 KiB
C++
/*
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
* Copyright (c) 2022, the SerenityOS developers.
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/DeprecatedString.h>
|
|
#include <AK/HashMap.h>
|
|
#include <LibCore/NetworkResponse.h>
|
|
|
|
namespace HTTP {
|
|
|
|
class HttpResponse : public Core::NetworkResponse {
|
|
public:
|
|
virtual ~HttpResponse() override = default;
|
|
static NonnullRefPtr<HttpResponse> create(int code, HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits>&& headers, size_t downloaded_size)
|
|
{
|
|
return adopt_ref(*new HttpResponse(code, move(headers), downloaded_size));
|
|
}
|
|
|
|
int code() const { return m_code; }
|
|
size_t downloaded_size() const { return m_downloaded_size; }
|
|
StringView reason_phrase() const { return reason_phrase_for_code(m_code); }
|
|
HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> const& headers() const { return m_headers; }
|
|
|
|
static StringView reason_phrase_for_code(int code);
|
|
|
|
private:
|
|
HttpResponse(int code, HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits>&&, size_t size);
|
|
|
|
int m_code { 0 };
|
|
HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> m_headers;
|
|
size_t m_downloaded_size { 0 };
|
|
};
|
|
|
|
}
|