143 "invalid compression level: {}, must be "
144 "an integer value in the range of -1 to 9" ),
195 "invalid window_bits: {}, must be "
196 "an integer value in the range of 8 to {} or "
197 "0 for decompress operation" ),
241 "invalid compression mem_level: {}, must be "
242 "an integer value in the range of 1 to {}" ),
284 "invalid compression strategy: {}, must be "
286 "Z_DEFAULT_STRATEGY({}), "
288 "Z_HUFFMAN_ONLY({}), "
325 throw exception_t{
"too small reserve buffer size" };
528 "Failed to initialize zlib stream: {}, {}" ),
586 "input data is too large: {} (max possible: {}), "
587 "try to break large data into pieces" ),
589 std::numeric_limits<
decltype(
m_zlib_stream.avail_in ) >::max() ) };
592 if( 0 <
input.size() )
595 reinterpret_cast< Bytef*
>(
const_cast< char*
>(
input.data() ) );
710 const char *
err_msg =
"<no zlib error description>";
722 throw exception_t{
"zlib operation is already completed" };
738 reinterpret_cast< Bytef*
>(
767 const char *
err_msg =
"<no error desc>";
774 "unexpected result of deflate() (zlib): {}, {}" ),
819 "unexpected result of inflate() (zlib): {}, {}" ),
899 return z.giveaway_output();
931template <
typename Response_Output_Strategy >
961 std::string
result{
"identity" };
965 result.assign(
"deflate" );
982template <
typename Response_Output_Strategy,
typename Descendant >
996 restinio::http_field::content_encoding,
1018template <
typename X_Controlled_Output,
typename Descendant >
1025 using base_type_t::base_type_t;
1073 restinio_controlled_output_t,
1074 body_appender_t< restinio_controlled_output_t > >
1088 return m_ztransformator->output_size();
1091 using base_type_t::base_type_t;
1120 user_controlled_output_t,
1121 body_appender_t< user_controlled_output_t > >
1135 m_ztransformator->flush();
1137 .append_body( m_ztransformator->giveaway_output() )
1181 body_appender_t< chunked_output_t > >
1189 using base_type_t::base_type_t;
1201 m_ztransformator->write(
input );
1217 m_ztransformator->flush();
1220 m_resp.append_chunk( m_ztransformator->giveaway_output() );
1232 if( !m_ztransformator->is_completed() )
1234 m_ztransformator->flush();
1235 m_resp.append_chunk( m_ztransformator->giveaway_output() );
1246 m_ztransformator->complete();
1247 m_resp.append_chunk( m_ztransformator->giveaway_output() );
1253template <
typename Response_Output_Strategy >
1264template <
typename Response_Output_Strategy >
1275template <
typename Response_Output_Strategy >
1286template <
typename Response_Output_Strategy >
1330template <
typename Extra_Data,
typename Handler >
1339 req.header().get_field_or( restinio::http_field::content_encoding,
"identity" );
Exception class for all exceptions thrown by RESTinio.
Forbid arbitrary response_builder_t instantiations.
Base class for body appenders.
std::unique_ptr< zlib_t > m_ztransformator
body_appender_base_t(body_appender_base_t &&ba) noexcept
body_appender_base_t(const body_appender_base_t &)=delete
body_appender_base_t(const params_t ¶ms, resp_t &resp)
body_appender_base_t & operator=(const body_appender_base_t &)=delete
virtual ~body_appender_base_t()
void flush()
Flushes currently available compressed data with possibly creating new chunk and then flushes target ...
auto & append(string_view_t input)
Append data to be compressed.
auto & make_chunk(string_view_t input=string_view_t{})
Append data to be compressed and adds current zlib transformator output as a new chunk.
void complete()
Complete zlib transformation operation.
auto size() const
Get the size of transformed body.
Base class for body appenders with restinio or user controlled output.
Descendant & append(string_view_t input)
Append a piece of data to response.
void complete()
Complete zlib transformation operation.
A special wrapper around fmtlib include files.
#define RESTINIO_FMT_FORMAT_STRING(s)
bool is_equal_caseless(const char *a, const char *b, std::size_t size) noexcept
Comparator for fields names.
run_on_this_thread_settings_t< Traits > on_this_thread()
A special marker for the case when http_server must be run on the context of the current thread.
std::string_view string_view_t
Helpers for caseless comparison of strings.
Tag type for chunked output response builder.
Tag type for RESTinio controlled output response builder.
Tag type for user controlled output response builder.