2020-01-18 08:38:21 +00:00
|
|
|
/*
|
2024-10-04 11:19:50 +00:00
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <andreas@ladybird.org>
|
2022-03-03 18:35:10 +00:00
|
|
|
* Copyright (c) 2022, the SerenityOS developers.
|
2020-01-18 08:38:21 +00:00
|
|
|
*
|
2021-04-22 08:24:48 +00:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 08:38:21 +00:00
|
|
|
*/
|
|
|
|
|
2019-04-07 12:36:10 +00:00
|
|
|
#pragma once
|
|
|
|
|
2020-02-06 14:04:03 +00:00
|
|
|
#include <LibCore/NetworkResponse.h>
|
2024-06-09 09:28:37 +00:00
|
|
|
#include <LibHTTP/HeaderMap.h>
|
2019-04-07 12:36:10 +00:00
|
|
|
|
2020-04-20 21:25:25 +00:00
|
|
|
namespace HTTP {
|
2020-02-02 11:34:39 +00:00
|
|
|
|
2020-04-20 21:25:25 +00:00
|
|
|
class HttpResponse : public Core::NetworkResponse {
|
2019-04-07 12:36:10 +00:00
|
|
|
public:
|
2022-03-03 18:35:10 +00:00
|
|
|
virtual ~HttpResponse() override = default;
|
2024-06-09 09:28:37 +00:00
|
|
|
static NonnullRefPtr<HttpResponse> create(int code, HeaderMap&& headers, size_t downloaded_size)
|
2019-04-07 12:36:10 +00:00
|
|
|
{
|
2022-02-02 15:51:55 +00:00
|
|
|
return adopt_ref(*new HttpResponse(code, move(headers), downloaded_size));
|
2019-04-07 12:36:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int code() const { return m_code; }
|
2022-02-02 15:51:55 +00:00
|
|
|
size_t downloaded_size() const { return m_downloaded_size; }
|
2021-06-05 12:28:11 +00:00
|
|
|
StringView reason_phrase() const { return reason_phrase_for_code(m_code); }
|
2024-06-09 09:28:37 +00:00
|
|
|
HeaderMap const& headers() const { return m_headers; }
|
2021-06-05 12:28:11 +00:00
|
|
|
|
|
|
|
static StringView reason_phrase_for_code(int code);
|
2019-04-07 12:36:10 +00:00
|
|
|
|
|
|
|
private:
|
2024-06-09 09:28:37 +00:00
|
|
|
HttpResponse(int code, HeaderMap&&, size_t size);
|
2019-04-07 12:36:10 +00:00
|
|
|
|
|
|
|
int m_code { 0 };
|
2024-06-09 09:28:37 +00:00
|
|
|
HeaderMap m_headers;
|
2022-02-02 15:51:55 +00:00
|
|
|
size_t m_downloaded_size { 0 };
|
2019-04-07 12:36:10 +00:00
|
|
|
};
|
2020-02-02 11:34:39 +00:00
|
|
|
|
|
|
|
}
|