44 content_type_field_not_found,
46 content_type_field_parse_error,
50 content_type_field_inappropriate_value,
53 illegal_boundary_value,
55 content_disposition_field_parse_error,
58 content_disposition_field_inappropriate_value,
69 terminated_by_handler,
91 dest result = dest::unexpected_error;
95 case source::content_type_field_not_found:
96 result = dest::content_type_field_not_found;
break;
98 case source::content_type_field_parse_error:
99 result = dest::content_type_field_parse_error;
break;
101 case source::content_type_field_inappropriate_value:
102 result = dest::content_type_field_inappropriate_value;
break;
104 case source::illegal_boundary_value:
105 result = dest::illegal_boundary_value;
break;
107 case source::no_parts_found:
108 result = dest::no_parts_found;
break;
110 case source::terminated_by_handler:
111 result = dest::terminated_by_handler;
break;
113 case source::unexpected_error:
227 restinio::http_field::content_disposition );
228 if( !disposition_field )
229 return make_unexpected( enumeration_error_t::no_files_found );
235 if( !parsed_disposition )
236 return make_unexpected(
237 enumeration_error_t::content_disposition_field_parse_error );
238 if(
"form-data" != parsed_disposition->value )
239 return make_unexpected( enumeration_error_t::no_files_found );
242 parsed_disposition->parameters,
"name" );
244 return make_unexpected(
245 enumeration_error_t::content_disposition_field_inappropriate_value );
246 const auto expected_to_optional = [](
auto expected ) {
256 parsed_disposition->parameters,
"filename*" ) );
258 parsed_disposition->parameters,
"filename" ) );
261 if( !filename_star && !filename )
262 return make_unexpected( enumeration_error_t::no_files_found );
267 std::string{ name->data(), name->size() },
279 template<
typename,
typename = restinio::utils::metaprogramming::
void_t<> >
282 template<
typename T >
289 decltype(std::declval<T>()(std::declval<part_description_t>()))
294 > :
public std::true_type
358 template<
typename Handler >
372 impl::valid_handler_type< std::decay_t<Handler> >::value,
373 "Handler should be callable object, "
374 "should accept part_description_t by value, const or rvalue reference, "
375 "and should return handling_result_t" );
377 std::size_t files_found{ 0u };
378 optional_t< enumeration_error_t > error;
381 [&handler, &files_found, &error]
385 if( part_description )
389 return handler(
std::move(*part_description) );
391 else if( enumeration_error_t::no_files_found ==
392 part_description.error() )
398 error = part_description.error();
399 return handling_result_t::terminate_enumeration;
403 expected_media_subtype );
406 return make_unexpected( *error );
408 return make_unexpected(