35#include <unordered_map>
37#include <seastar/core/sstring.hh>
38#include <seastar/http/mime_types.hh>
39#include <seastar/core/iostream.hh>
40#include <seastar/util/noncopyable_function.hh>
41#include <seastar/util/modules.hh>
42#include <seastar/util/string_utils.hh>
43#include <seastar/util/iostream.hh>
47SEASTAR_MODULE_EXPORT_BEGIN
67 switching_protocols = 101,
71 nonauthoritative_information = 203,
74 partial_content = 206,
75 multiple_choices = 300,
76 moved_permanently = 301,
77 moved_temporarily = 302,
81 temporary_redirect = 307,
84 payment_required = 402,
87 method_not_allowed = 405,
89 request_timeout = 408,
92 length_required = 411,
93 payload_too_large = 413,
95 unsupported_media_type = 415,
96 expectation_failed = 417,
98 unprocessable_entity = 422,
99 upgrade_required = 426,
100 too_many_requests = 429,
102 internal_server_error = 500,
103 not_implemented = 501,
105 service_unavailable = 503,
106 gateway_timeout = 504,
107 http_version_not_supported = 505,
108 insufficient_storage = 507,
109 bandwidth_limit_exceeded = 509,
110 network_read_timeout = 598,
111 network_connect_timeout = 599,
139 auto sc =
static_cast<std::underlying_type_t<status_type>
>(http_status) / 100;
140 if (sc < 1 || sc > 5) [[unlikely]] {
141 return status_class::unclassified;
149 std::unordered_map<sstring, sstring, seastar::internal::case_insensitive_hash, seastar::internal::case_insensitive_cmp>
_headers;
156 size_t content_length = 0;
158 sstring _response_line;
159 std::unordered_map<sstring, sstring> trailing_headers;
160 std::unordered_map<sstring, sstring> chunk_extensions;
166 reply& add_header(
const sstring& h,
const sstring& value) {
184 reply& set_version(
const sstring& version) {
189 reply& set_status(
status_type status, sstring content =
"") {
212 set_mime_type(http::mime_types::extension_to_type(content_type));
216 reply&
done(
const sstring& content_type) {
224 _response_line = response_line();
227 sstring response_line()
const;
253 template <
typename W>
255 void write_body(
const sstring& content_type, W&& body_writer) {
257 return util::write_to_stream_and_close(std::move(out), std::move(body_writer));
270 void write_body(
const sstring& content_type, sstring content);
286using reply [[deprecated(
"Use http::reply instead")]] =
http::reply;
289SEASTAR_MODULE_EXPORT_END
292#if FMT_VERSION >= 90000
293template <>
struct fmt::formatter<
seastar::http::reply::status_type> : fmt::ostream_formatter {};
A representation of a possibly not-yet-computed value.
Definition: future.hh:1240
Seastar API namespace.
Definition: abort_on_ebadf.hh:26
Definition: noncopyable_function.hh:37
void write_body(const sstring &content_type, noncopyable_function< future<>(output_stream< char > &&)> &&body_writer)
use an output stream to write the message body
static constexpr status_class classify_status(status_type http_status)
Definition: reply.hh:138
std::unordered_map< sstring, sstring, seastar::internal::case_insensitive_hash, seastar::internal::case_insensitive_cmp > _headers
Definition: reply.hh:149
status_class
Definition: reply.hh:124
reply & set_mime_type(const sstring &mime)
Definition: reply.hh:202
sstring get_header(const sstring &name) const
Definition: reply.hh:176
status_type
Definition: reply.hh:65
reply & done()
Definition: reply.hh:223
sstring _content
Definition: reply.hh:155
reply & set_content_type(const sstring &content_type="html")
Definition: reply.hh:211
void write_body(const sstring &content_type, W &&body_writer)
use and output stream to write the message body
Definition: reply.hh:255
void write_body(const sstring &content_type, sstring content)
Write a string as the reply.