14 #include <restinio/helpers/http_field_parsers/basics.hpp> 16 #include <restinio/helpers/http_field_parsers/details/pct_encoded_symbols.hpp> 53 ep_impl::source_t::content_consumer_t consumer{ from };
54 const auto result = hfp_impl::token_producer_t::try_parse( from );
57 if(
'*' == *(result->rbegin()) )
60 return make_unexpected( parse_error_t{
61 consumer.started_at() + result->size() - 1,
62 error_reason_t::unexpected_character
95 ep_impl::source_t::content_consumer_t consumer{ from };
96 const auto result = hfp_impl::token_producer_t::try_parse( from );
99 if(
'*' != *(result->rbegin()) )
102 return make_unexpected( parse_error_t{
103 consumer.started_at(),
104 error_reason_t::pattern_not_found
132 return hfp_impl::is_alpha(actual)
133 || hfp_impl::is_digit(actual)
165 return ep_impl::symbol_producer_template_t< mime_charsetc_predicate_t >{};
190 return hfp_impl::is_alpha(actual)
191 || hfp_impl::is_digit(actual)
209 return ep_impl::symbol_producer_template_t< language_predicate_t >{};
229 return hfp_impl::is_alpha(actual)
230 || hfp_impl::is_digit(actual)
261 return ep_impl::symbol_producer_template_t< attr_char_predicate_t >{};
301 return produce< std::string >(
302 repeat( 1, N, mime_charsetc_symbol_p() >> to_container() ),
303 symbol_p(
'\'' ) >> to_container(),
304 repeat( 0, N, language_symbol_p() >> to_container() ),
305 symbol_p(
'\'' ) >> to_container(),
308 attr_char_symbol_p() >> to_container(),
309 hfp_details::pct_encoded_symbols_p() >>
310 hfp_details::pct_encoded_symbols_consumer_t{} )
356 return produce< content_disposition_value_t >(
357 token_p() >> to_lower()
358 >> &content_disposition_value_t::value,
359 produce< parameter_container_t >(
361 produce< parameter_t >(
367 regular_token_producer_t{}
368 >> to_lower() >> ¶meter_t::first,
371 token_p() >> ¶meter_t::second,
372 quoted_string_p() >> ¶meter_t::second
376 ext_token_producer_t{}
377 >> to_lower() >> ¶meter_t::first,
379 ext_parameter_value_p() >> ¶meter_t::second
384 ) >> &content_disposition_value_t::parameters
397 return restinio::easy_parser::try_parse( what, make_parser() );
expected_t< std::optional< string_view_t >, not_found_t > find_first(const parameter_with_optional_value_container_t &where, string_view_t what)
A helper function to find the first occurence of a parameter with the specified value.
A preducate for symbol_producer_template that checks that a symbol is language symbol from RCF5646...
A preducate for symbol_producer_template that checks that a symbol is attr-char symbol from RCF5987...
bool operator()(const char actual) const noexcept
std::enable_if< std::is_same< Parameter_Container, query_string_params_t >::value||std::is_same< Parameter_Container, router::route_params_t >::value, std::optional< Value_Type > >::type opt_value(const Parameter_Container ¶ms, string_view_t key)
Gets the value of a parameter specified by key wrapped in std::optional<Value_Type> if parameter exis...
bool operator()(const char actual) const noexcept
A producer for token that is an "extended parameter name" in sense of RCF6266 and RCF5987...
auto ext_parameter_value_p()
A producer for an "extended parameter value" in sense of RCF6266 and RCF5987.
static auto make_parser()
A factory function for a parser of Content-Disposition value.
bool operator()(const char actual) const noexcept
auto attr_char_symbol_p()
A factory for producer that extracts attr-char symbols.
expected_t< result_type, parse_error_t > try_parse(ep_impl::source_t &from) const
expected_t< result_type, parse_error_t > try_parse(ep_impl::source_t &from) const
static expected_t< content_disposition_value_t, restinio::easy_parser::parse_error_t > try_parse(string_view_t what)
An attempt to parse Content-Disposition HTTP-field.
parameter_container_t parameters
A producer for token that is a "regular parameter name" in sense of RCF6266 and RCF5987.
Tools for working with the value of Content-Disposition HTTP-field.
auto mime_charsetc_symbol_p()
A factory for producer that extracts mime-charsetc symbols.
A preducate for symbol_producer_template that checks that a symbol is mime-charsetc symbol from RCF59...
auto language_symbol_p()
A factory for producer that extracts language symbols.