RESTinio
transfer-encoding.hpp
Go to the documentation of this file.
1/*
2 * RESTinio
3 */
4
12#pragma once
13
15
16#include <restinio/variant.hpp>
17
18#include <tuple>
19
20namespace restinio
21{
22
23namespace http_field_parsers
24{
25
26//
27// transfer_encoding_value_t
28//
49{
52 {
53 chunked,
55 deflate,
56 gzip,
57 };
58
60 static constexpr known_transfer_coding_t chunked() noexcept
62
64 static constexpr known_transfer_coding_t compress() noexcept
66
68 static constexpr known_transfer_coding_t deflate() noexcept
70
72 static constexpr known_transfer_coding_t gzip() noexcept
74
77 {
78 std::string token;
80
82 bool
83 operator==( const transfer_extension_t & o ) const noexcept
84 {
85 return std::tie(this->token, this->transfer_parameters) ==
86 std::tie(o.token, o.transfer_parameters);
87 }
88 };
89
94 >;
95
96 using value_container_t = std::vector< value_t >;
97
99
106 static auto
108 {
109 return produce< transfer_encoding_value_t >(
110 non_empty_comma_separated_list_p< value_container_t >(
111 produce< value_t >(
114 >> just_result( chunked() ),
115 expected_caseless_token_p("compress")
116 >> just_result( compress() ),
118 >> just_result( deflate() ),
120 >> just_result( gzip() ),
122 >> just_result( gzip() ),
123 produce< transfer_extension_t >(
127 ) >> as_result()
128 )
129 )
131 );
132 }
133
140 static expected_t<
144 {
146 }
147};
148
149} /* namespace http_field_parsers */
150
151} /* namespace restinio */
152
Utilities for parsing values of http-fields.
Information about parsing error.
Definition: easy_parser.hpp:93
#define RESTINIO_NODISCARD
RESTINIO_NODISCARD expected_t< typename Producer::result_type, parse_error_t > try_parse(string_view_t from, Producer producer)
Perform the parsing of the specified content by using specified value producer.
RESTINIO_NODISCARD auto just_result(T value) noexcept(noexcept(impl::just_result_consumer_t< T >{value}))
A special consumer that replaces the produced value by a value specified by a user and sets that user...
RESTINIO_NODISCARD auto as_result() noexcept
A factory function to create a as_result_consumer.
RESTINIO_NODISCARD auto to_lower() noexcept
A factory function to create a to_lower_transformer.
RESTINIO_NODISCARD auto alternatives(Clauses &&... clauses)
A factory function to create an alternatives clause.
RESTINIO_NODISCARD impl::params_with_value_producer_t params_with_value_p()
A factory of producer of parameter_with_mandatory_value_container.
Definition: basics.hpp:1685
std::vector< parameter_with_mandatory_value_t > parameter_with_mandatory_value_container_t
A type of container for parameters with mandatory values.
Definition: basics.hpp:1532
RESTINIO_NODISCARD auto token_p() noexcept
A factory function to create a token_producer.
Definition: basics.hpp:985
RESTINIO_NODISCARD auto expected_caseless_token_p(string_view_t token)
A factory function to create a producer that expect a token with specific value.
Definition: basics.hpp:1112
nonstd::string_view string_view_t
Definition: string_view.hpp:19
nonstd::expected< T, E > expected_t
Definition: expected.hpp:22
RESTINIO_NODISCARD bool operator==(const transfer_extension_t &o) const noexcept
Tools for working with the value of Transfer-Encoding HTTP-field.
static RESTINIO_NODISCARD constexpr known_transfer_coding_t compress() noexcept
static RESTINIO_NODISCARD constexpr known_transfer_coding_t gzip() noexcept
static RESTINIO_NODISCARD constexpr known_transfer_coding_t chunked() noexcept
known_transfer_coding_t
Enumeration for transfer-coding values from RFC7230.
static RESTINIO_NODISCARD constexpr known_transfer_coding_t deflate() noexcept
static RESTINIO_NODISCARD auto make_parser()
A factory function for a parser of Transfer-Encoding value.
static RESTINIO_NODISCARD expected_t< transfer_encoding_value_t, restinio::easy_parser::parse_error_t > try_parse(string_view_t what)
An attempt to parse Transfer-Encoding HTTP-field.