kaycxx-http
HTTP client library
Loading...
Searching...
No Matches
response_base.hpp
1// SPDX-FileCopyrightText: 2026 Klaus Reimer <k@ailis.de>
2// SPDX-License-Identifier: MIT
3
4#pragma once
5
6#include <kaycxx/http/header.hpp>
7
8#include <optional>
9#include <string>
10#include <string_view>
11#include <vector>
12
13namespace kaycxx::http {
14
17public:
23 [[nodiscard]] int status_code() const noexcept;
24
32 [[nodiscard]] const std::vector<kaycxx::http::header>& headers() const & noexcept;
33
39 [[nodiscard]] std::vector<kaycxx::http::header> headers() && noexcept;
40
49 [[nodiscard]] std::optional<std::string_view> header(std::string_view name) const & noexcept;
50
57 [[nodiscard]] std::optional<std::string> header(std::string_view name) && noexcept;
58
65 [[nodiscard]] std::vector<std::string> headers(std::string_view name) const;
66
67protected:
74 response_base(int status_code, std::vector<kaycxx::http::header> headers);
75
77 response_base(const response_base&) = default;
78
80 response_base(response_base&&) noexcept = default;
81
83 response_base& operator=(const response_base&) = default;
84
86 response_base& operator=(response_base&&) noexcept = default;
87
89 ~response_base() = default;
90
91private:
93 int status_code_;
94
96 std::vector<kaycxx::http::header> headers_;
97};
98
99} // namespace kaycxx::http
int status_code() const noexcept
Returns the HTTP status code.
response_base(int status_code, std::vector< kaycxx::http::header > headers)
Creates common HTTP response data.
std::optional< std::string_view > header(std::string_view name) const &noexcept
Returns the first value of a response header using an ASCII case-insensitive name comparison.
const std::vector< kaycxx::http::header > & headers() const &noexcept
Returns all response headers in their received order.