http_headers.hpp
Go to the documentation of this file.
/*
restinio
*/
#pragma once
#include <restinio/impl/include_fmtlib.hpp>
#include <restinio/impl/string_caseless_compare.hpp>
#include <restinio/exception.hpp>
#include <restinio/string_view.hpp>
#include <restinio/optional.hpp>
#include <restinio/common_types.hpp>
#include <http_parser.h>
#include <iosfwd>
#include <string>
#include <vector>
#include <algorithm>
namespace restinio
{
// Adopted header fields
// (https://www.iana.org/assignments/message-headers/message-headers.xml#perm-headers).
// Fields `Connection` and `Content-Length` are specieal cases, thus they are excluded from the list.
#define RESTINIO_HTTP_FIELDS_MAP( RESTINIO_GEN ) \
RESTINIO_GEN( a_im, A-IM ) \
RESTINIO_GEN( accept, Accept ) \
RESTINIO_GEN( accept_additions, Accept-Additions ) \
RESTINIO_GEN( accept_charset, Accept-Charset ) \
RESTINIO_GEN( accept_datetime, Accept-Datetime ) \
RESTINIO_GEN( accept_encoding, Accept-Encoding ) \
RESTINIO_GEN( accept_features, Accept-Features ) \
RESTINIO_GEN( accept_language, Accept-Language ) \
RESTINIO_GEN( accept_patch, Accept-Patch ) \
RESTINIO_GEN( accept_post, Accept-Post ) \
RESTINIO_GEN( accept_ranges, Accept-Ranges ) \
RESTINIO_GEN( age, Age ) \
RESTINIO_GEN( allow, Allow ) \
RESTINIO_GEN( alpn, ALPN ) \
RESTINIO_GEN( alt_svc, Alt-Svc ) \
RESTINIO_GEN( alt_used, Alt-Used ) \
RESTINIO_GEN( alternates, Alternates ) \
RESTINIO_GEN( apply_to_redirect_ref, Apply-To-Redirect-Ref ) \
RESTINIO_GEN( authentication_control, Authentication-Control ) \
RESTINIO_GEN( authentication_info, Authentication-Info ) \
RESTINIO_GEN( authorization, Authorization ) \
RESTINIO_GEN( c_ext, C-Ext ) \
RESTINIO_GEN( c_man, C-Man ) \
RESTINIO_GEN( c_opt, C-Opt ) \
RESTINIO_GEN( c_pep, C-PEP ) \
RESTINIO_GEN( c_pep_info, C-PEP-Info ) \
RESTINIO_GEN( cache_control, Cache-Control ) \
RESTINIO_GEN( caldav_timezones, CalDAV-Timezones ) \
RESTINIO_GEN( close, Close ) \
RESTINIO_GEN( content_base, Content-Base ) \
RESTINIO_GEN( content_disposition, Content-Disposition ) \
RESTINIO_GEN( content_encoding, Content-Encoding ) \
RESTINIO_GEN( content_id, Content-ID ) \
RESTINIO_GEN( content_language, Content-Language ) \
RESTINIO_GEN( content_location, Content-Location ) \
RESTINIO_GEN( content_md5, Content-MD5 ) \
RESTINIO_GEN( content_range, Content-Range ) \
RESTINIO_GEN( content_script_type, Content-Script-Type ) \
RESTINIO_GEN( content_style_type, Content-Style-Type ) \
RESTINIO_GEN( content_type, Content-Type ) \
RESTINIO_GEN( content_version, Content-Version ) \
RESTINIO_GEN( cookie, Cookie ) \
RESTINIO_GEN( cookie2, Cookie2 ) \
RESTINIO_GEN( dasl, DASL ) \
RESTINIO_GEN( dav, DAV ) \
RESTINIO_GEN( date, Date ) \
RESTINIO_GEN( default_style, Default-Style ) \
RESTINIO_GEN( delta_base, Delta-Base ) \
RESTINIO_GEN( depth, Depth ) \
RESTINIO_GEN( derived_from, Derived-From ) \
RESTINIO_GEN( destination, Destination ) \
RESTINIO_GEN( differential_id, Differential-ID ) \
RESTINIO_GEN( digest, Digest ) \
RESTINIO_GEN( etag, ETag ) \
RESTINIO_GEN( expect, Expect ) \
RESTINIO_GEN( expires, Expires ) \
RESTINIO_GEN( ext, Ext ) \
RESTINIO_GEN( forwarded, Forwarded ) \
RESTINIO_GEN( from, From ) \
RESTINIO_GEN( getprofile, GetProfile ) \
RESTINIO_GEN( hobareg, Hobareg ) \
RESTINIO_GEN( host, Host ) \
RESTINIO_GEN( http2_settings, HTTP2-Settings ) \
RESTINIO_GEN( im, IM ) \
RESTINIO_GEN( if_, If ) \
RESTINIO_GEN( if_match, If-Match ) \
RESTINIO_GEN( if_modified_since, If-Modified-Since ) \
RESTINIO_GEN( if_none_match, If-None-Match ) \
RESTINIO_GEN( if_range, If-Range ) \
RESTINIO_GEN( if_schedule_tag_match, If-Schedule-Tag-Match ) \
RESTINIO_GEN( if_unmodified_since, If-Unmodified-Since ) \
RESTINIO_GEN( keep_alive, Keep-Alive ) \
RESTINIO_GEN( label, Label ) \
RESTINIO_GEN( last_modified, Last-Modified ) \
RESTINIO_GEN( link, Link ) \
RESTINIO_GEN( location, Location ) \
RESTINIO_GEN( lock_token, Lock-Token ) \
RESTINIO_GEN( man, Man ) \
RESTINIO_GEN( max_forwards, Max-Forwards ) \
RESTINIO_GEN( memento_datetime, Memento-Datetime ) \
RESTINIO_GEN( meter, Meter ) \
RESTINIO_GEN( mime_version, MIME-Version ) \
RESTINIO_GEN( negotiate, Negotiate ) \
RESTINIO_GEN( opt, Opt ) \
RESTINIO_GEN( optional_www_authenticate, Optional-WWW-Authenticate ) \
RESTINIO_GEN( ordering_type, Ordering-Type ) \
RESTINIO_GEN( origin, Origin ) \
RESTINIO_GEN( overwrite, Overwrite ) \
RESTINIO_GEN( p3p, P3P ) \
RESTINIO_GEN( pep, PEP ) \
RESTINIO_GEN( pics_label, PICS-Label ) \
RESTINIO_GEN( pep_info, Pep-Info ) \
RESTINIO_GEN( position, Position ) \
RESTINIO_GEN( pragma, Pragma ) \
RESTINIO_GEN( prefer, Prefer ) \
RESTINIO_GEN( preference_applied, Preference-Applied ) \
RESTINIO_GEN( profileobject, ProfileObject ) \
RESTINIO_GEN( protocol, Protocol ) \
RESTINIO_GEN( protocol_info, Protocol-Info ) \
RESTINIO_GEN( protocol_query, Protocol-Query ) \
RESTINIO_GEN( protocol_request, Protocol-Request ) \
RESTINIO_GEN( proxy_authenticate, Proxy-Authenticate ) \
RESTINIO_GEN( proxy_authentication_info, Proxy-Authentication-Info ) \
RESTINIO_GEN( proxy_authorization, Proxy-Authorization ) \
RESTINIO_GEN( proxy_features, Proxy-Features ) \
RESTINIO_GEN( proxy_instruction, Proxy-Instruction ) \
RESTINIO_GEN( public_, Public ) \
RESTINIO_GEN( public_key_pins, Public-Key-Pins ) \
RESTINIO_GEN( public_key_pins_report_only, Public-Key-Pins-Report-Only ) \
RESTINIO_GEN( range, Range ) \
RESTINIO_GEN( redirect_ref, Redirect-Ref ) \
RESTINIO_GEN( referer, Referer ) \
RESTINIO_GEN( retry_after, Retry-After ) \
RESTINIO_GEN( safe, Safe ) \
RESTINIO_GEN( schedule_reply, Schedule-Reply ) \
RESTINIO_GEN( schedule_tag, Schedule-Tag ) \
RESTINIO_GEN( sec_websocket_accept, Sec-WebSocket-Accept ) \
RESTINIO_GEN( sec_websocket_extensions, Sec-WebSocket-Extensions ) \
RESTINIO_GEN( sec_websocket_key, Sec-WebSocket-Key ) \
RESTINIO_GEN( sec_websocket_protocol, Sec-WebSocket-Protocol ) \
RESTINIO_GEN( sec_websocket_version, Sec-WebSocket-Version ) \
RESTINIO_GEN( security_scheme, Security-Scheme ) \
RESTINIO_GEN( server, Server ) \
RESTINIO_GEN( set_cookie, Set-Cookie ) \
RESTINIO_GEN( set_cookie2, Set-Cookie2 ) \
RESTINIO_GEN( setprofile, SetProfile ) \
RESTINIO_GEN( slug, SLUG ) \
RESTINIO_GEN( soapaction, SoapAction ) \
RESTINIO_GEN( status_uri, Status-URI ) \
RESTINIO_GEN( strict_transport_security, Strict-Transport-Security ) \
RESTINIO_GEN( surrogate_capability, Surrogate-Capability ) \
RESTINIO_GEN( surrogate_control, Surrogate-Control ) \
RESTINIO_GEN( tcn, TCN ) \
RESTINIO_GEN( te, TE ) \
RESTINIO_GEN( timeout, Timeout ) \
RESTINIO_GEN( topic, Topic ) \
RESTINIO_GEN( trailer, Trailer ) \
RESTINIO_GEN( transfer_encoding, Transfer-Encoding ) \
RESTINIO_GEN( ttl, TTL ) \
RESTINIO_GEN( urgency, Urgency ) \
RESTINIO_GEN( uri, URI ) \
RESTINIO_GEN( upgrade, Upgrade ) \
RESTINIO_GEN( user_agent, User-Agent ) \
RESTINIO_GEN( variant_vary, Variant-Vary ) \
RESTINIO_GEN( vary, Vary ) \
RESTINIO_GEN( via, Via ) \
RESTINIO_GEN( www_authenticate, WWW-Authenticate ) \
RESTINIO_GEN( want_digest, Want-Digest ) \
RESTINIO_GEN( warning, Warning ) \
RESTINIO_GEN( x_frame_options, X-Frame-Options ) \
\
RESTINIO_GEN( access_control, Access-Control ) \
RESTINIO_GEN( access_control_allow_credentials, Access-Control-Allow-Credentials ) \
RESTINIO_GEN( access_control_allow_headers, Access-Control-Allow-Headers )\
RESTINIO_GEN( access_control_allow_methods, Access-Control-Allow-Methods )\
RESTINIO_GEN( access_control_allow_origin, Access-Control-Allow-Origin ) \
RESTINIO_GEN( access_control_max_age, Access-Control-Max-Age ) \
RESTINIO_GEN( access_control_request_method, Access-Control-Request-Method ) \
RESTINIO_GEN( access_control_request_headers, Access-Control-Request-Headers ) \
RESTINIO_GEN( compliance, Compliance ) \
RESTINIO_GEN( content_transfer_encoding, Content-Transfer-Encoding ) \
RESTINIO_GEN( cost, Cost ) \
RESTINIO_GEN( ediint_features, EDIINT-Features ) \
RESTINIO_GEN( message_id, Message-ID ) \
RESTINIO_GEN( method_check, Method-Check ) \
RESTINIO_GEN( method_check_expires, Method-Check-Expires ) \
RESTINIO_GEN( non_compliance, Non-Compliance ) \
RESTINIO_GEN( optional, Optional ) \
RESTINIO_GEN( referer_root, Referer-Root ) \
RESTINIO_GEN( resolution_hint, Resolution-Hint ) \
RESTINIO_GEN( resolver_location, Resolver-Location ) \
RESTINIO_GEN( subok, SubOK ) \
RESTINIO_GEN( subst, Subst ) \
RESTINIO_GEN( title, Title ) \
RESTINIO_GEN( ua_color, UA-Color ) \
RESTINIO_GEN( ua_media, UA-Media ) \
RESTINIO_GEN( ua_pixels, UA-Pixels ) \
RESTINIO_GEN( ua_resolution, UA-Resolution ) \
RESTINIO_GEN( ua_windowpixels, UA-Windowpixels ) \
RESTINIO_GEN( version, Version ) \
RESTINIO_GEN( x_device_accept, X-Device-Accept ) \
RESTINIO_GEN( x_device_accept_charset, X-Device-Accept-Charset ) \
RESTINIO_GEN( x_device_accept_encoding, X-Device-Accept-Encoding ) \
RESTINIO_GEN( x_device_accept_language, X-Device-Accept-Language ) \
RESTINIO_GEN( x_device_user_agent, X-Device-User-Agent )
// SPECIAL CASE: RESTINIO_GEN( connection, Connection )
// SPECIAL CASE: RESTINIO_GEN( content_length, Content-Length )
//
// http_field_t
//
enum class http_field_t : std::uint8_t //By now 152 + 34 + 1 items fits to uint8_t
{
#define RESTINIO_HTTP_FIELD_GEN( name, ignored ) name,
RESTINIO_HTTP_FIELDS_MAP( RESTINIO_HTTP_FIELD_GEN )
#undef RESTINIO_HTTP_FIELD_GEN
// Unspecified field.
field_unspecified
};
using http_field = http_field_t;
//
// string_to_field()
//
inline http_field_t
string_to_field( string_view_t field ) noexcept
{
const char * field_name = field.data();
const std::size_t field_name_size = field.size();
#define RESTINIO_HTTP_CHECK_FOR_FIELD( field_id, candidate_field_name ) \
if( impl::is_equal_caseless(field_name, #candidate_field_name , field_name_size ) ) \
return http_field_t:: field_id;
// TODO: make most popular fields to be checked first.
switch( field_name_size )
{
case 2:
RESTINIO_HTTP_CHECK_FOR_FIELD( if_, If )
RESTINIO_HTTP_CHECK_FOR_FIELD( im, IM )
RESTINIO_HTTP_CHECK_FOR_FIELD( te, TE )
break;
case 3:
RESTINIO_HTTP_CHECK_FOR_FIELD( age, Age )
RESTINIO_HTTP_CHECK_FOR_FIELD( dav, DAV )
RESTINIO_HTTP_CHECK_FOR_FIELD( ext, Ext )
RESTINIO_HTTP_CHECK_FOR_FIELD( man, Man )
RESTINIO_HTTP_CHECK_FOR_FIELD( opt, Opt )
RESTINIO_HTTP_CHECK_FOR_FIELD( p3p, P3P )
RESTINIO_HTTP_CHECK_FOR_FIELD( pep, PEP )
RESTINIO_HTTP_CHECK_FOR_FIELD( tcn, TCN )
RESTINIO_HTTP_CHECK_FOR_FIELD( ttl, TTL )
RESTINIO_HTTP_CHECK_FOR_FIELD( uri, URI )
RESTINIO_HTTP_CHECK_FOR_FIELD( via, Via )
break;
case 4:
// Known to be more used first:
RESTINIO_HTTP_CHECK_FOR_FIELD( host, Host )
RESTINIO_HTTP_CHECK_FOR_FIELD( a_im, A-IM )
RESTINIO_HTTP_CHECK_FOR_FIELD( alpn, ALPN )
RESTINIO_HTTP_CHECK_FOR_FIELD( dasl, DASL )
RESTINIO_HTTP_CHECK_FOR_FIELD( date, Date )
RESTINIO_HTTP_CHECK_FOR_FIELD( etag, ETag )
RESTINIO_HTTP_CHECK_FOR_FIELD( from, From )
RESTINIO_HTTP_CHECK_FOR_FIELD( link, Link )
RESTINIO_HTTP_CHECK_FOR_FIELD( safe, Safe )
RESTINIO_HTTP_CHECK_FOR_FIELD( slug, SLUG )
RESTINIO_HTTP_CHECK_FOR_FIELD( vary, Vary )
RESTINIO_HTTP_CHECK_FOR_FIELD( cost, Cost )
break;
case 5:
RESTINIO_HTTP_CHECK_FOR_FIELD( allow, Allow )
RESTINIO_HTTP_CHECK_FOR_FIELD( c_ext, C-Ext )
RESTINIO_HTTP_CHECK_FOR_FIELD( c_man, C-Man )
RESTINIO_HTTP_CHECK_FOR_FIELD( c_opt, C-Opt )
RESTINIO_HTTP_CHECK_FOR_FIELD( c_pep, C-PEP )
RESTINIO_HTTP_CHECK_FOR_FIELD( close, Close )
RESTINIO_HTTP_CHECK_FOR_FIELD( depth, Depth )
RESTINIO_HTTP_CHECK_FOR_FIELD( label, Label )
RESTINIO_HTTP_CHECK_FOR_FIELD( meter, Meter )
RESTINIO_HTTP_CHECK_FOR_FIELD( range, Range )
RESTINIO_HTTP_CHECK_FOR_FIELD( topic, Topic )
RESTINIO_HTTP_CHECK_FOR_FIELD( subok, SubOK )
RESTINIO_HTTP_CHECK_FOR_FIELD( subst, Subst )
RESTINIO_HTTP_CHECK_FOR_FIELD( title, Title )
break;
case 6:
// Known to be more used first:
RESTINIO_HTTP_CHECK_FOR_FIELD( accept, Accept )
RESTINIO_HTTP_CHECK_FOR_FIELD( cookie, Cookie )
RESTINIO_HTTP_CHECK_FOR_FIELD( server, Server )
RESTINIO_HTTP_CHECK_FOR_FIELD( digest, Digest )
RESTINIO_HTTP_CHECK_FOR_FIELD( expect, Expect )
RESTINIO_HTTP_CHECK_FOR_FIELD( origin, Origin )
RESTINIO_HTTP_CHECK_FOR_FIELD( pragma, Pragma )
RESTINIO_HTTP_CHECK_FOR_FIELD( prefer, Prefer )
RESTINIO_HTTP_CHECK_FOR_FIELD( public_, Public )
break;
case 7:
RESTINIO_HTTP_CHECK_FOR_FIELD( alt_svc, Alt-Svc )
RESTINIO_HTTP_CHECK_FOR_FIELD( cookie2, Cookie2 )
RESTINIO_HTTP_CHECK_FOR_FIELD( expires, Expires )
RESTINIO_HTTP_CHECK_FOR_FIELD( hobareg, Hobareg )
RESTINIO_HTTP_CHECK_FOR_FIELD( referer, Referer )
RESTINIO_HTTP_CHECK_FOR_FIELD( timeout, Timeout )
RESTINIO_HTTP_CHECK_FOR_FIELD( trailer, Trailer )
RESTINIO_HTTP_CHECK_FOR_FIELD( urgency, Urgency )
RESTINIO_HTTP_CHECK_FOR_FIELD( upgrade, Upgrade )
RESTINIO_HTTP_CHECK_FOR_FIELD( warning, Warning )
RESTINIO_HTTP_CHECK_FOR_FIELD( version, Version )
break;
case 8:
RESTINIO_HTTP_CHECK_FOR_FIELD( alt_used, Alt-Used )
RESTINIO_HTTP_CHECK_FOR_FIELD( if_match, If-Match )
RESTINIO_HTTP_CHECK_FOR_FIELD( if_range, If-Range )
RESTINIO_HTTP_CHECK_FOR_FIELD( location, Location )
RESTINIO_HTTP_CHECK_FOR_FIELD( pep_info, Pep-Info )
RESTINIO_HTTP_CHECK_FOR_FIELD( position, Position )
RESTINIO_HTTP_CHECK_FOR_FIELD( protocol, Protocol )
RESTINIO_HTTP_CHECK_FOR_FIELD( optional, Optional )
RESTINIO_HTTP_CHECK_FOR_FIELD( ua_color, UA-Color )
RESTINIO_HTTP_CHECK_FOR_FIELD( ua_media, UA-Media )
break;
case 9:
RESTINIO_HTTP_CHECK_FOR_FIELD( forwarded, Forwarded )
RESTINIO_HTTP_CHECK_FOR_FIELD( negotiate, Negotiate )
RESTINIO_HTTP_CHECK_FOR_FIELD( overwrite, Overwrite )
RESTINIO_HTTP_CHECK_FOR_FIELD( ua_pixels, UA-Pixels )
break;
case 10:
RESTINIO_HTTP_CHECK_FOR_FIELD( alternates, Alternates )
RESTINIO_HTTP_CHECK_FOR_FIELD( c_pep_info, C-PEP-Info )
RESTINIO_HTTP_CHECK_FOR_FIELD( content_id, Content-ID )
RESTINIO_HTTP_CHECK_FOR_FIELD( delta_base, Delta-Base )
RESTINIO_HTTP_CHECK_FOR_FIELD( getprofile, GetProfile )
RESTINIO_HTTP_CHECK_FOR_FIELD( keep_alive, Keep-Alive )
RESTINIO_HTTP_CHECK_FOR_FIELD( lock_token, Lock-Token )
RESTINIO_HTTP_CHECK_FOR_FIELD( pics_label, PICS-Label )
RESTINIO_HTTP_CHECK_FOR_FIELD( set_cookie, Set-Cookie )
RESTINIO_HTTP_CHECK_FOR_FIELD( setprofile, SetProfile )
RESTINIO_HTTP_CHECK_FOR_FIELD( soapaction, SoapAction )
RESTINIO_HTTP_CHECK_FOR_FIELD( status_uri, Status-URI )
RESTINIO_HTTP_CHECK_FOR_FIELD( user_agent, User-Agent )
RESTINIO_HTTP_CHECK_FOR_FIELD( compliance, Compliance )
RESTINIO_HTTP_CHECK_FOR_FIELD( message_id, Message-ID )
break;
case 11:
RESTINIO_HTTP_CHECK_FOR_FIELD( accept_post, Accept-Post )
RESTINIO_HTTP_CHECK_FOR_FIELD( content_md5, Content-MD5 )
RESTINIO_HTTP_CHECK_FOR_FIELD( destination, Destination )
RESTINIO_HTTP_CHECK_FOR_FIELD( retry_after, Retry-After )
RESTINIO_HTTP_CHECK_FOR_FIELD( set_cookie2, Set-Cookie2 )
RESTINIO_HTTP_CHECK_FOR_FIELD( want_digest, Want-Digest )
break;
case 12:
// Known to be more used first:
RESTINIO_HTTP_CHECK_FOR_FIELD( content_type, Content-Type )
RESTINIO_HTTP_CHECK_FOR_FIELD( accept_patch, Accept-Patch )
RESTINIO_HTTP_CHECK_FOR_FIELD( content_base, Content-Base )
RESTINIO_HTTP_CHECK_FOR_FIELD( derived_from, Derived-From )
RESTINIO_HTTP_CHECK_FOR_FIELD( max_forwards, Max-Forwards )
RESTINIO_HTTP_CHECK_FOR_FIELD( mime_version, MIME-Version )
RESTINIO_HTTP_CHECK_FOR_FIELD( schedule_tag, Schedule-Tag )
RESTINIO_HTTP_CHECK_FOR_FIELD( redirect_ref, Redirect-Ref )
RESTINIO_HTTP_CHECK_FOR_FIELD( variant_vary, Variant-Vary )
RESTINIO_HTTP_CHECK_FOR_FIELD( method_check, Method-Check )
RESTINIO_HTTP_CHECK_FOR_FIELD( referer_root, Referer-Root )
break;
case 13:
RESTINIO_HTTP_CHECK_FOR_FIELD( accept_ranges, Accept-Ranges )
RESTINIO_HTTP_CHECK_FOR_FIELD( authorization, Authorization )
RESTINIO_HTTP_CHECK_FOR_FIELD( cache_control, Cache-Control )
RESTINIO_HTTP_CHECK_FOR_FIELD( content_range, Content-Range )
RESTINIO_HTTP_CHECK_FOR_FIELD( default_style, Default-Style )
RESTINIO_HTTP_CHECK_FOR_FIELD( if_none_match, If-None-Match )
RESTINIO_HTTP_CHECK_FOR_FIELD( last_modified, Last-Modified )
RESTINIO_HTTP_CHECK_FOR_FIELD( ordering_type, Ordering-Type )
RESTINIO_HTTP_CHECK_FOR_FIELD( profileobject, ProfileObject )
RESTINIO_HTTP_CHECK_FOR_FIELD( protocol_info, Protocol-Info )
RESTINIO_HTTP_CHECK_FOR_FIELD( ua_resolution, UA-Resolution )
break;
case 14:
RESTINIO_HTTP_CHECK_FOR_FIELD( accept_charset, Accept-Charset )
RESTINIO_HTTP_CHECK_FOR_FIELD( http2_settings, HTTP2-Settings )
RESTINIO_HTTP_CHECK_FOR_FIELD( protocol_query, Protocol-Query )
RESTINIO_HTTP_CHECK_FOR_FIELD( proxy_features, Proxy-Features )
RESTINIO_HTTP_CHECK_FOR_FIELD( schedule_reply, Schedule-Reply )
RESTINIO_HTTP_CHECK_FOR_FIELD( non_compliance, Non-Compliance )
RESTINIO_HTTP_CHECK_FOR_FIELD( access_control, Access-Control )
break;
case 15:
RESTINIO_HTTP_CHECK_FOR_FIELD( accept_encoding, Accept-Encoding )
RESTINIO_HTTP_CHECK_FOR_FIELD( accept_features, Accept-Features )
RESTINIO_HTTP_CHECK_FOR_FIELD( accept_language, Accept-Language )
RESTINIO_HTTP_CHECK_FOR_FIELD( accept_datetime, Accept-Datetime )
RESTINIO_HTTP_CHECK_FOR_FIELD( content_version, Content-Version )
RESTINIO_HTTP_CHECK_FOR_FIELD( differential_id, Differential-ID )
RESTINIO_HTTP_CHECK_FOR_FIELD( public_key_pins, Public-Key-Pins )
RESTINIO_HTTP_CHECK_FOR_FIELD( security_scheme, Security-Scheme )
RESTINIO_HTTP_CHECK_FOR_FIELD( x_frame_options, X-Frame-Options )
RESTINIO_HTTP_CHECK_FOR_FIELD( x_device_accept, X-Device-Accept )
RESTINIO_HTTP_CHECK_FOR_FIELD( resolution_hint, Resolution-Hint )
RESTINIO_HTTP_CHECK_FOR_FIELD( ediint_features, EDIINT-Features )
RESTINIO_HTTP_CHECK_FOR_FIELD( ua_windowpixels, UA-Windowpixels )
break;
case 16:
RESTINIO_HTTP_CHECK_FOR_FIELD( accept_additions, Accept-Additions )
RESTINIO_HTTP_CHECK_FOR_FIELD( caldav_timezones, CalDAV-Timezones )
RESTINIO_HTTP_CHECK_FOR_FIELD( content_encoding, Content-Encoding )
RESTINIO_HTTP_CHECK_FOR_FIELD( content_language, Content-Language )
RESTINIO_HTTP_CHECK_FOR_FIELD( content_location, Content-Location )
RESTINIO_HTTP_CHECK_FOR_FIELD( memento_datetime, Memento-Datetime )
RESTINIO_HTTP_CHECK_FOR_FIELD( protocol_request, Protocol-Request )
RESTINIO_HTTP_CHECK_FOR_FIELD( www_authenticate, WWW-Authenticate )
break;
case 17:
RESTINIO_HTTP_CHECK_FOR_FIELD( if_modified_since, If-Modified-Since )
RESTINIO_HTTP_CHECK_FOR_FIELD( proxy_instruction, Proxy-Instruction )
RESTINIO_HTTP_CHECK_FOR_FIELD( sec_websocket_key, Sec-WebSocket-Key )
RESTINIO_HTTP_CHECK_FOR_FIELD( surrogate_control, Surrogate-Control )
RESTINIO_HTTP_CHECK_FOR_FIELD( transfer_encoding, Transfer-Encoding )
RESTINIO_HTTP_CHECK_FOR_FIELD( resolver_location, Resolver-Location )
break;
case 18:
RESTINIO_HTTP_CHECK_FOR_FIELD( content_style_type, Content-Style-Type )
RESTINIO_HTTP_CHECK_FOR_FIELD( preference_applied, Preference-Applied )
RESTINIO_HTTP_CHECK_FOR_FIELD( proxy_authenticate, Proxy-Authenticate )
break;
case 19:
RESTINIO_HTTP_CHECK_FOR_FIELD( authentication_info, Authentication-Info )
RESTINIO_HTTP_CHECK_FOR_FIELD( content_disposition, Content-Disposition )
RESTINIO_HTTP_CHECK_FOR_FIELD( content_script_type, Content-Script-Type )
RESTINIO_HTTP_CHECK_FOR_FIELD( if_unmodified_since, If-Unmodified-Since )
RESTINIO_HTTP_CHECK_FOR_FIELD( proxy_authorization, Proxy-Authorization )
RESTINIO_HTTP_CHECK_FOR_FIELD( x_device_user_agent, X-Device-User-Agent )
break;
case 20:
RESTINIO_HTTP_CHECK_FOR_FIELD( sec_websocket_accept, Sec-WebSocket-Accept )
RESTINIO_HTTP_CHECK_FOR_FIELD( surrogate_capability, Surrogate-Capability )
RESTINIO_HTTP_CHECK_FOR_FIELD( method_check_expires, Method-Check-Expires )
break;
case 21:
RESTINIO_HTTP_CHECK_FOR_FIELD( apply_to_redirect_ref, Apply-To-Redirect-Ref )
RESTINIO_HTTP_CHECK_FOR_FIELD( if_schedule_tag_match, If-Schedule-Tag-Match )
RESTINIO_HTTP_CHECK_FOR_FIELD( sec_websocket_version, Sec-WebSocket-Version )
break;
case 22:
RESTINIO_HTTP_CHECK_FOR_FIELD( authentication_control, Authentication-Control )
RESTINIO_HTTP_CHECK_FOR_FIELD( sec_websocket_protocol, Sec-WebSocket-Protocol )
RESTINIO_HTTP_CHECK_FOR_FIELD( access_control_max_age, Access-Control-Max-Age )
break;
case 23:
RESTINIO_HTTP_CHECK_FOR_FIELD( x_device_accept_charset, X-Device-Accept-Charset )
break;
case 24:
RESTINIO_HTTP_CHECK_FOR_FIELD( sec_websocket_extensions, Sec-WebSocket-Extensions )
RESTINIO_HTTP_CHECK_FOR_FIELD( x_device_accept_encoding, X-Device-Accept-Encoding )
RESTINIO_HTTP_CHECK_FOR_FIELD( x_device_accept_language, X-Device-Accept-Language )
break;
case 25:
RESTINIO_HTTP_CHECK_FOR_FIELD( optional_www_authenticate, Optional-WWW-Authenticate )
RESTINIO_HTTP_CHECK_FOR_FIELD( proxy_authentication_info, Proxy-Authentication-Info )
RESTINIO_HTTP_CHECK_FOR_FIELD( strict_transport_security, Strict-Transport-Security )
RESTINIO_HTTP_CHECK_FOR_FIELD( content_transfer_encoding, Content-Transfer-Encoding )
break;
case 27:
RESTINIO_HTTP_CHECK_FOR_FIELD( public_key_pins_report_only, Public-Key-Pins-Report-Only )
RESTINIO_HTTP_CHECK_FOR_FIELD( access_control_allow_origin, Access-Control-Allow-Origin )
break;
case 28:
RESTINIO_HTTP_CHECK_FOR_FIELD( access_control_allow_headers, Access-Control-Allow-Headers )
RESTINIO_HTTP_CHECK_FOR_FIELD( access_control_allow_methods, Access-Control-Allow-Methods )
break;
case 29:
RESTINIO_HTTP_CHECK_FOR_FIELD( access_control_request_method, Access-Control-Request-Method )
break;
case 30:
RESTINIO_HTTP_CHECK_FOR_FIELD( access_control_request_headers, Access-Control-Request-Headers )
break;
case 32:
RESTINIO_HTTP_CHECK_FOR_FIELD( access_control_allow_credentials, Access-Control-Allow-Credentials )
break;
}
#undef RESTINIO_HTTP_CHECK_FOR_FIELD
return http_field_t::field_unspecified;
}
//
// field_to_string()
//
inline const char *
field_to_string( http_field_t f ) noexcept
{
const char * result = "";
switch( f )
{
#define RESTINIO_HTTP_FIELD_STR_GEN( name, string_name ) \
case http_field_t::name: result = #string_name; break;
RESTINIO_HTTP_FIELDS_MAP( RESTINIO_HTTP_FIELD_STR_GEN )
#undef RESTINIO_HTTP_FIELD_STR_GEN
case http_field_t::field_unspecified: break; // Ignore.
}
return result;
}
//
// http_header_field_t
//
class http_header_field_t
{
public:
http_header_field_t()
: m_field_id{ http_field_t::field_unspecified }
{}
http_header_field_t(
std::string name,
std::string value )
: m_name{ std::move( name ) }
, m_value{ std::move( value ) }
, m_field_id{ string_to_field( m_name ) }
{}
http_header_field_t(
string_view_t name,
string_view_t value )
: m_name{ name.data(), name.size() }
, m_value{ value.data(), value.size() }
, m_field_id{ string_to_field( m_name ) }
{}
http_header_field_t(
http_field_t field_id,
std::string value )
: m_name{ field_to_string( field_id ) }
, m_value{ std::move( value ) }
, m_field_id{ field_id }
{}
http_header_field_t(
http_field_t field_id,
string_view_t value )
: m_name{ field_to_string( field_id ) }
, m_value{ std::move( value ) }
, m_field_id{ field_id }
{}
const std::string & name() const noexcept { return m_name; }
const std::string & value() const noexcept { return m_value; }
http_field_t field_id() const noexcept { return m_field_id; }
void
name( std::string n )
{
m_name = std::move( n );
m_field_id = string_to_field( m_name );
}
void
value( std::string v )
{
m_value = std::move( v );
}
void
append_value( string_view_t v )
{
m_value.append( v.data(), v.size() );
}
void
field_id( http_field_t field_id )
{
m_field_id = field_id;
m_name = field_to_string( m_field_id );
}
private:
std::string m_name;
std::string m_value;
http_field_t m_field_id;
};
// Make neccessary forward declarations.
class http_header_fields_t;
namespace impl
{
void
append_last_field_accessor( http_header_fields_t &, string_view_t );
} /* namespace impl */
#if !defined( RESTINIO_HEADER_FIELDS_DEFAULT_RESERVE_COUNT )
#define RESTINIO_HEADER_FIELDS_DEFAULT_RESERVE_COUNT 4
#endif
//
// http_header_fields_t
//
class http_header_fields_t
{
friend void
impl::append_last_field_accessor( http_header_fields_t &, string_view_t );
public:
using fields_container_t = std::vector< http_header_field_t >;
using const_iterator = fields_container_t::const_iterator;
enum class handling_result_t
{
continue_enumeration,
stop_enumeration
};
constexpr static handling_result_t continue_enumeration() noexcept
{ return handling_result_t::continue_enumeration; }
constexpr static handling_result_t stop_enumeration() noexcept
{ return handling_result_t::stop_enumeration; }
http_header_fields_t()
{
m_fields.reserve( RESTINIO_HEADER_FIELDS_DEFAULT_RESERVE_COUNT );
}
http_header_fields_t(const http_header_fields_t &) = default;
http_header_fields_t(http_header_fields_t &&) = default;
virtual ~http_header_fields_t() {}
http_header_fields_t & operator=(const http_header_fields_t &) = default;
http_header_fields_t & operator=(http_header_fields_t &&) = default;
void
swap_fields( http_header_fields_t & http_header_fields )
{
std::swap( m_fields, http_header_fields.m_fields );
}
bool
has_field( string_view_t field_name ) const noexcept
{
return m_fields.cend() != cfind( field_name );
}
bool
has_field( http_field_t field_id ) const noexcept
{
return m_fields.cend() != cfind( field_id );
}
void
set_field( http_header_field_t http_header_field )
{
fields_container_t::iterator it;
if( http_field_t::field_unspecified != http_header_field.field_id() )
{
// Field has a standard name.
// Search it by id.
it = find( http_header_field.field_id() );
}
else
{
// Field has a non standard name.
// Search it by name.
it = find( http_header_field.name() );
}
if( m_fields.end() != it )
{
*it = std::move( http_header_field );
}
else
{
m_fields.emplace_back( std::move( http_header_field ) );
}
}
void
set_field(
std::string field_name,
std::string field_value )
{
const auto it = find( field_name );
if( m_fields.end() != it )
{
it->name( std::move( field_name ) );
it->value( std::move( field_value ) );
}
else
{
m_fields.emplace_back(
std::move( field_name ),
std::move( field_value ) );
}
}
void
set_field(
http_field_t field_id,
std::string field_value )
{
if( http_field_t::field_unspecified != field_id )
{
const auto it = find( field_id );
if( m_fields.end() != it )
{
it->value( std::move( field_value ) );
}
else
{
m_fields.emplace_back(
field_id,
std::move( field_value ) );
}
}
}
void
add_field(
http_field_t field_id,
std::string field_value )
{
if( http_field_t::field_unspecified != field_id )
{
m_fields.emplace_back(
field_id,
std::move( field_value ) );
}
}
void
add_field(
std::string field_name,
std::string field_value )
{
m_fields.emplace_back(
std::move( field_name ),
std::move( field_value ) );
}
void
add_field( http_header_field_t http_header_field )
{
m_fields.push_back( std::move(http_header_field) );
}
void
append_field(
string_view_t field_name,
string_view_t field_value )
{
const auto it = find( field_name );
if( m_fields.end() != it )
{
it->append_value( field_value );
}
else
{
m_fields.emplace_back( field_name, field_value );
}
}
void
append_field(
http_field_t field_id,
string_view_t field_value )
{
if( http_field_t::field_unspecified != field_id )
{
const auto it = find( field_id );
if( m_fields.end() != it )
{
it->append_value( field_value );
}
else
{
m_fields.emplace_back( field_id, field_value );
}
}
}
const std::string &
get_field( string_view_t field_name ) const
{
const auto it = cfind( field_name );
if( m_fields.end() == it )
throw exception_t{
fmt::format( "field '{}' doesn't exist", field_name ) };
return it->value();
}
nullable_pointer_t<const std::string>
try_get_field( string_view_t field_name ) const noexcept
{
const auto it = cfind( field_name );
if( m_fields.end() == it )
return nullptr;
else
return std::addressof(it->value());
}
const std::string &
get_field( http_field_t field_id ) const
{
if( http_field_t::field_unspecified == field_id )
{
throw exception_t{
fmt::format(
"unspecified fields cannot be searched by id" ) };
}
const auto it = cfind( field_id );
if( m_fields.end() == it )
{
throw exception_t{
fmt::format(
"field '{}' doesn't exist",
field_to_string( field_id ) ) };
}
return it->value();
}
nullable_pointer_t<const std::string>
try_get_field( http_field_t field_id ) const noexcept
{
if( http_field_t::field_unspecified != field_id )
{
const auto it = cfind( field_id );
if( m_fields.end() != it )
return std::addressof(it->value());
}
return nullptr;
}
std::string
get_field_or(
string_view_t field_name,
string_view_t default_value ) const
{
const auto it = cfind( field_name );
if( m_fields.end() == it )
return std::string( default_value.data(), default_value.size() );
return it->value();
}
std::string
get_field_or(
string_view_t field_name,
std::string && default_value ) const
{
const auto it = cfind( field_name );
if( m_fields.end() == it )
return std::move(default_value);
return it->value();
}
auto
get_field_or(
string_view_t field_name,
const char * default_value ) const
{
return this->get_field_or( field_name, string_view_t{ default_value } );
}
auto
get_field_or(
string_view_t field_name,
const std::string & default_value ) const
{
return this->get_field_or( field_name, string_view_t{ default_value } );
}
std::string
get_field_or(
http_field_t field_id,
string_view_t default_value ) const
{
if( http_field_t::field_unspecified != field_id )
{
const auto it = cfind( field_id );
if( m_fields.end() != it )
return it->value();
}
return std::string( default_value.data(), default_value.size() );
}
auto
get_field_or(
http_field_t field_id,
const char * default_value ) const
{
return this->get_field_or( field_id, string_view_t{ default_value } );
}
auto
get_field_or(
http_field_t field_id,
const std::string & default_value ) const
{
return this->get_field_or( field_id, string_view_t{ default_value } );
}
std::string
get_field_or(
http_field_t field_id,
std::string && default_value ) const
{
if( http_field_t::field_unspecified != field_id )
{
const auto it = cfind( field_id );
if( m_fields.end() != it )
return it->value();
}
return std::move( default_value );
}
bool
remove_field( string_view_t field_name ) noexcept
{
const auto it = find( field_name );
if( m_fields.end() != it )
{
m_fields.erase( it );
return true;
}
return false;
}
bool
remove_field( http_field_t field_id ) noexcept
{
if( http_field_t::field_unspecified != field_id )
{
const auto it = find( field_id );
if( m_fields.end() != it )
{
m_fields.erase( it );
return true;
}
}
return false;
}
std::size_t
remove_all_of( string_view_t field_name ) noexcept
{
std::size_t count{};
for( auto it = m_fields.begin(); it != m_fields.end(); )
{
if( impl::is_equal_caseless( it->name(), field_name ) )
{
it = m_fields.erase( it );
++count;
}
else
++it;
}
return count;
}
std::size_t
remove_all_of( http_field_t field_id ) noexcept
{
std::size_t count{};
if( http_field_t::field_unspecified != field_id )
{
for( auto it = m_fields.begin(); it != m_fields.end(); )
{
if( it->field_id() == field_id )
{
it = m_fields.erase( it );
++count;
}
else
++it;
}
}
return count;
}
string_view_t
value_of(
string_view_t name ) const
{
return { this->get_field(name) };
}
string_view_t
value_of(
http_field_t field_id ) const
{
return { this->get_field(field_id) };
}
optional_t< string_view_t >
opt_value_of(
string_view_t name ) const noexcept
{
optional_t< string_view_t > result;
if( auto * ptr = this->try_get_field(name) )
result = string_view_t{ *ptr };
return result;
}
optional_t< string_view_t >
opt_value_of(
http_field_t field_id ) const noexcept
{
optional_t< string_view_t > result;
if( auto * ptr = this->try_get_field(field_id) )
result = string_view_t{ *ptr };
return result;
}
template< typename Lambda >
void
for_each_field( Lambda && lambda ) const
noexcept(noexcept(lambda(
std::declval<const http_header_field_t &>())))
{
for( const auto & f : m_fields )
lambda( f );
}
template< typename Lambda >
void
for_each_value_of(
http_field_t field_id,
Lambda && lambda ) const
noexcept(noexcept(lambda(
std::declval<const string_view_t &>())))
{
static_assert(
std::is_same<
handling_result_t,
decltype(lambda(std::declval<const string_view_t &>()))
>::value,
"lambda should return restinio::http_header_fields_t::handling_result_t" );
for( const auto & f : m_fields )
{
if( field_id == f.field_id() )
{
const handling_result_t r = lambda( f.value() );
if( stop_enumeration() == r )
break;
}
}
}
template< typename Lambda >
void
for_each_value_of(
string_view_t field_name,
Lambda && lambda ) const
noexcept(noexcept(lambda(
std::declval<const string_view_t &>())))
{
static_assert(
std::is_same<
handling_result_t,
decltype(lambda(std::declval<const string_view_t &>()))
>::value,
"lambda should return restinio::http_header_fields_t::handling_result_t" );
for( const auto & f : m_fields )
{
if( impl::is_equal_caseless( f.name(), field_name ) )
{
const handling_result_t r = lambda( f.value() );
if( stop_enumeration() == r )
break;
}
}
}
const_iterator
begin() const noexcept
{
return m_fields.cbegin();
}
const_iterator
end() const noexcept
{
return m_fields.cend();
}
auto fields_count() const noexcept
{
return m_fields.size();
}
private:
void
append_last_field( string_view_t field_value )
{
m_fields.back().append_value( field_value );
}
fields_container_t::iterator
find( string_view_t field_name ) noexcept
{
return std::find_if(
m_fields.begin(),
m_fields.end(),
[&]( const auto & f ){
return impl::is_equal_caseless( f.name(), field_name );
} );
}
fields_container_t::const_iterator
cfind( string_view_t field_name ) const noexcept
{
return std::find_if(
m_fields.cbegin(),
m_fields.cend(),
[&]( const auto & f ){
return impl::is_equal_caseless( f.name(), field_name );
} );
}
fields_container_t::iterator
find( http_field_t field_id ) noexcept
{
return std::find_if(
m_fields.begin(),
m_fields.end(),
[&]( const auto & f ){
return f.field_id() == field_id;
} );
}
fields_container_t::const_iterator
cfind( http_field_t field_id ) const noexcept
{
return std::find_if(
m_fields.cbegin(),
m_fields.cend(),
[&]( const auto & f ){
return f.field_id() == field_id;
} );
}
fields_container_t m_fields;
};
//
// http_connection_header_t
//
enum class http_connection_header_t : std::uint8_t
{
keep_alive,
close,
upgrade
};
//
// http_header_common_t
//
struct http_header_common_t
: public http_header_fields_t
{
public:
std::uint16_t
http_major() const noexcept
{ return m_http_major; }
void
http_major( std::uint16_t v ) noexcept
{ m_http_major = v; }
std::uint16_t
http_minor() const noexcept
{ return m_http_minor; }
void
http_minor( std::uint16_t v ) noexcept
{ m_http_minor = v; }
std::uint64_t
content_length() const noexcept
{ return m_content_length; }
void
content_length( std::uint64_t l ) noexcept
{ m_content_length = l; }
bool
should_keep_alive() const noexcept
{
return http_connection_header_t::keep_alive == m_http_connection_header_field_value;
}
void
should_keep_alive( bool keep_alive ) noexcept
{
connection( keep_alive?
http_connection_header_t::keep_alive :
http_connection_header_t::close );
}
http_connection_header_t
connection() const
{
return m_http_connection_header_field_value;
}
void
connection( http_connection_header_t ch ) noexcept
{
m_http_connection_header_field_value = ch;
}
private:
std::uint16_t m_http_major{1};
std::uint16_t m_http_minor{1};
std::uint64_t m_content_length{ 0 };
http_connection_header_t m_http_connection_header_field_value{ http_connection_header_t::close };
};
#define RESTINIO_HTTP_METHOD_MAP(RESTINIO_GEN) \
RESTINIO_GEN( http_method_delete, HTTP_DELETE, DELETE ) \
RESTINIO_GEN( http_method_get, HTTP_GET, GET ) \
RESTINIO_GEN( http_method_head, HTTP_HEAD, HEAD ) \
RESTINIO_GEN( http_method_post, HTTP_POST, POST ) \
RESTINIO_GEN( http_method_put, HTTP_PUT, PUT ) \
/* pathological */ \
RESTINIO_GEN( http_method_connect, HTTP_CONNECT, CONNECT ) \
RESTINIO_GEN( http_method_options, HTTP_OPTIONS, OPTIONS ) \
RESTINIO_GEN( http_method_trace, HTTP_TRACE, TRACE ) \
/* WebDAV */ \
RESTINIO_GEN( http_method_copy, HTTP_COPY, COPY ) \
RESTINIO_GEN( http_method_lock, HTTP_LOCK, LOCK ) \
RESTINIO_GEN( http_method_mkcol, HTTP_MKCOL, MKCOL ) \
RESTINIO_GEN( http_method_move, HTTP_MOVE, MOVE ) \
RESTINIO_GEN( http_method_propfind, HTTP_PROPFIND, PROPFIND ) \
RESTINIO_GEN( http_method_proppatch, HTTP_PROPPATCH, PROPPATCH ) \
RESTINIO_GEN( http_method_search, HTTP_SEARCH, SEARCH ) \
RESTINIO_GEN( http_method_unlock, HTTP_UNLOCK, UNLOCK ) \
RESTINIO_GEN( http_method_bind, HTTP_BIND, BIND ) \
RESTINIO_GEN( http_method_rebind, HTTP_REBIND, REBIND ) \
RESTINIO_GEN( http_method_unbind, HTTP_UNBIND, UNBIND ) \
RESTINIO_GEN( http_method_acl, HTTP_ACL, ACL ) \
/* subversion */ \
RESTINIO_GEN( http_method_report, HTTP_REPORT, REPORT ) \
RESTINIO_GEN( http_method_mkactivity, HTTP_MKACTIVITY, MKACTIVITY ) \
RESTINIO_GEN( http_method_checkout, HTTP_CHECKOUT, CHECKOUT ) \
RESTINIO_GEN( http_method_merge, HTTP_MERGE, MERGE ) \
/* upnp */ \
RESTINIO_GEN( http_method_msearch, HTTP_MSEARCH, M-SEARCH) \
RESTINIO_GEN( http_method_notify, HTTP_NOTIFY, NOTIFY ) \
RESTINIO_GEN( http_method_subscribe, HTTP_SUBSCRIBE, SUBSCRIBE ) \
RESTINIO_GEN( http_method_unsubscribe, HTTP_UNSUBSCRIBE, UNSUBSCRIBE ) \
/* RFC-5789 */ \
RESTINIO_GEN( http_method_patch, HTTP_PATCH, PATCH ) \
RESTINIO_GEN( http_method_purge, HTTP_PURGE, PURGE ) \
/* CalDAV */ \
RESTINIO_GEN( http_method_mkcalendar, HTTP_MKCALENDAR, MKCALENDAR ) \
/* RFC-2068, section 19.6.1.2 */ \
RESTINIO_GEN( http_method_link, HTTP_LINK, LINK ) \
RESTINIO_GEN( http_method_unlink, HTTP_UNLINK, UNLINK )
//
// http_method_id_t
//
class http_method_id_t
{
int m_value;
const char * m_name;
public:
static constexpr const int unknown_method = -1;
constexpr http_method_id_t() noexcept
: m_value{ unknown_method }
, m_name{ "<undefined>" }
{}
constexpr http_method_id_t(
int value,
const char * name ) noexcept
: m_value{ value }
, m_name{ name }
{}
constexpr http_method_id_t( const http_method_id_t & ) noexcept = default;
constexpr http_method_id_t &
operator=( const http_method_id_t & ) noexcept = default;
constexpr http_method_id_t( http_method_id_t && ) noexcept = default;
constexpr http_method_id_t &
operator=( http_method_id_t && ) noexcept = default;
constexpr auto
raw_id() const noexcept { return m_value; }
constexpr const char *
c_str() const noexcept { return m_name; }
friend constexpr bool
operator==( const http_method_id_t & a, const http_method_id_t & b ) noexcept {
return a.raw_id() == b.raw_id();
}
friend constexpr bool
operator!=( const http_method_id_t & a, const http_method_id_t & b ) noexcept {
return a.raw_id() != b.raw_id();
}
friend constexpr bool
operator<( const http_method_id_t & a, const http_method_id_t & b ) noexcept {
return a.raw_id() < b.raw_id();
}
};
inline std::ostream &
operator<<( std::ostream & to, const http_method_id_t & m )
{
return to << m.c_str();
}
// Generate helper funcs.
#define RESTINIO_HTTP_METHOD_FUNC_GEN( func_name, nodejs_code, method_name ) \
inline constexpr http_method_id_t func_name() { \
return { nodejs_code, #method_name }; \
}
RESTINIO_HTTP_METHOD_MAP( RESTINIO_HTTP_METHOD_FUNC_GEN )
#undef RESTINIO_HTTP_METHOD_FUNC_GEN
inline constexpr http_method_id_t
http_method_unknown()
{
return http_method_id_t{};
}
//
// default_http_methods_t
//
class default_http_methods_t
{
public :
inline static constexpr http_method_id_t
from_nodejs( int value ) noexcept
{
http_method_id_t result;
switch( value )
{
#define RESTINIO_HTTP_METHOD_FUNC_GEN( func_name, nodejs_code, method_name ) \
case nodejs_code : result = func_name(); break;
RESTINIO_HTTP_METHOD_MAP( RESTINIO_HTTP_METHOD_FUNC_GEN )
#undef RESTINIO_HTTP_METHOD_FUNC_GEN
default : ; // Nothing to do.
}
return result;
}
};
//
// http_request_header
//
struct http_request_header_t final
: public http_header_common_t
{
static std::size_t
memchr_helper( int chr , const char * from, std::size_t size )
{
const char * result = static_cast< const char * >(
std::memchr( from, chr, size ) );
return result ? static_cast< std::size_t >( result - from ) : size;
}
public:
http_request_header_t() = default;
http_request_header_t(
http_method_id_t method,
std::string request_target_ )
: m_method{ method }
{
request_target( std::move( request_target_ ) );
}
http_method_id_t
method() const noexcept
{ return m_method; }
void
method( http_method_id_t m ) noexcept
{ m_method = m; }
const std::string &
request_target() const noexcept
{ return m_request_target; }
void
request_target( std::string t )
{
m_request_target.assign( std::move( t ) );
m_fragment_separator_pos =
memchr_helper( '#', m_request_target.data(), m_request_target.size() );
m_query_separator_pos =
memchr_helper( '?', m_request_target.data(), m_fragment_separator_pos );
}
string_view_t
path() const noexcept
{
return string_view_t{ m_request_target.data(), m_query_separator_pos };
}
string_view_t
query() const noexcept
{
return
m_fragment_separator_pos == m_query_separator_pos ?
string_view_t{ nullptr, 0 } :
string_view_t{
m_request_target.data() + m_query_separator_pos + 1,
m_fragment_separator_pos - m_query_separator_pos - 1 };
}
string_view_t
fragment() const
{
return
m_request_target.size() == m_fragment_separator_pos ?
string_view_t{ nullptr, 0 } :
string_view_t{
m_request_target.data() + m_fragment_separator_pos + 1,
m_request_target.size() - m_fragment_separator_pos - 1 };
}
void
append_request_target( const char * at, size_t length )
{
if( m_request_target.size() == m_fragment_separator_pos )
{
// If fragment separator hadn't already appeared,
// search for it in a new block.
const auto fragment_separator_pos_inc =
memchr_helper( '#', at, length );
m_fragment_separator_pos += fragment_separator_pos_inc;
if( m_request_target.size() == m_query_separator_pos )
{
// If request separator hadn't already appeared,
// search for it in a new block.
m_query_separator_pos +=
memchr_helper( '?', at, fragment_separator_pos_inc );
}
}
// Else fragment separator appeared
// (req separator is either already defined or does not exist)
m_request_target.append( at, length );
}
private:
http_method_id_t m_method{ http_method_get() };
std::string m_request_target;
std::size_t m_query_separator_pos{ 0 };
std::size_t m_fragment_separator_pos{ 0 };
};
//
// http_status_code_t
//
class http_status_code_t
{
public:
constexpr http_status_code_t() noexcept
{}
constexpr explicit http_status_code_t( std::uint16_t status_code ) noexcept
: m_status_code{ status_code }
{}
constexpr auto
raw_code() const noexcept
{
return m_status_code;
}
constexpr bool
operator == ( const http_status_code_t & sc ) const noexcept
{
return raw_code() == sc.raw_code();
}
constexpr bool
operator != ( const http_status_code_t & sc ) const noexcept
{
return sc.raw_code() != sc.raw_code();
}
constexpr bool
operator < ( const http_status_code_t & sc ) const noexcept
{
return sc.raw_code() < sc.raw_code();
}
private:
std::uint16_t m_status_code{ 0 };
};
namespace status_code
{
// Add '_', because 'continue is reserved word.'
constexpr http_status_code_t continue_{ 100 };
constexpr http_status_code_t switching_protocols{ 101 };
constexpr http_status_code_t ok{ 200 };
constexpr http_status_code_t created{ 201 };
constexpr http_status_code_t accepted{ 202 };
constexpr http_status_code_t non_authoritative_information{ 203 };
constexpr http_status_code_t no_content{ 204 };
constexpr http_status_code_t reset_content{ 205 };
constexpr http_status_code_t partial_content{ 206 };
constexpr http_status_code_t multiple_choices{ 300 };
constexpr http_status_code_t moved_permanently{ 301 };
constexpr http_status_code_t found{ 302 };
constexpr http_status_code_t see_other{ 303 };
constexpr http_status_code_t not_modified{ 304 };
constexpr http_status_code_t use_proxy{ 305 };
constexpr http_status_code_t temporary_redirect{ 307 };
constexpr http_status_code_t bad_request{ 400 };
constexpr http_status_code_t unauthorized{ 401 };
constexpr http_status_code_t payment_required{ 402 };
constexpr http_status_code_t forbidden{ 403 };
constexpr http_status_code_t not_found{ 404 };
constexpr http_status_code_t method_not_allowed{ 405 };
constexpr http_status_code_t not_acceptable{ 406 };
constexpr http_status_code_t proxy_authentication_required{ 407 };
constexpr http_status_code_t request_time_out{ 408 };
constexpr http_status_code_t conflict{ 409 };
constexpr http_status_code_t gone{ 410 };
constexpr http_status_code_t length_required{ 411 };
constexpr http_status_code_t precondition_failed{ 412 };
//413 Payload Too Large (RFC 7231)
// The request is larger than the server is willing or able to process.
// Previously called "Request Entity Too Large".[44]
constexpr http_status_code_t payload_too_large{ 413 };
// 414 URI Too Long (RFC 7231)
// The URI provided was too long for the server to process.
// Often the result of too much data being encoded as a query-string of a GET request,
// in which case it should be converted to a POST request.
// Called "Request-URI Too Long" previously.[46]
constexpr http_status_code_t uri_too_long{ 414 };
constexpr http_status_code_t unsupported_media_type{ 415 };
constexpr http_status_code_t requested_range_not_satisfiable{ 416 };
constexpr http_status_code_t expectation_failed{ 417 };
constexpr http_status_code_t internal_server_error{ 500 };
constexpr http_status_code_t not_implemented{ 501 };
constexpr http_status_code_t bad_gateway{ 502 };
constexpr http_status_code_t service_unavailable{ 503 };
constexpr http_status_code_t gateway_time_out{ 504 };
constexpr http_status_code_t http_version_not_supported{ 505 };
// RFC 7538
constexpr http_status_code_t permanent_redirect{ 308 };
// RFC 2518
constexpr http_status_code_t processing{ 102 };
constexpr http_status_code_t multi_status{ 207 };
constexpr http_status_code_t unprocessable_entity{ 422 };
constexpr http_status_code_t locked{ 423 };
constexpr http_status_code_t failed_dependency{ 424 };
constexpr http_status_code_t insufficient_storage{ 507 };
// RFC 6585
constexpr http_status_code_t precondition_required{ 428 };
constexpr http_status_code_t too_many_requests{ 429 };
constexpr http_status_code_t request_header_fields_too_large{ 431 };
constexpr http_status_code_t network_authentication_required{ 511 };
} /* namespace status_code */
//
// http_status_line_t
//
class http_status_line_t
{
public:
http_status_line_t()
{}
http_status_line_t(
http_status_code_t sc,
std::string reason_phrase )
: m_status_code{ sc }
, m_reason_phrase{ std::move( reason_phrase ) }
{}
http_status_code_t
status_code() const noexcept
{ return m_status_code; }
void
status_code( http_status_code_t c ) noexcept
{ m_status_code = c; }
const std::string &
reason_phrase() const noexcept
{ return m_reason_phrase; }
void
reason_phrase( std::string r )
{ m_reason_phrase.assign( std::move( r ) ); }
private:
http_status_code_t m_status_code{ status_code::ok };
std::string m_reason_phrase;
};
inline std::ostream &
operator << ( std::ostream & o, const http_status_line_t & status_line )
{
return o << "{" << status_line.status_code().raw_code() << ", "
<< status_line.reason_phrase() << "}";
}
inline http_status_line_t status_continue()
{ return http_status_line_t{ status_code::continue_, "Continue" }; }
inline http_status_line_t status_switching_protocols()
{ return http_status_line_t{ status_code::switching_protocols, "Switching Protocols" }; }
inline http_status_line_t status_ok()
{ return http_status_line_t{ status_code::ok, "OK" }; }
inline http_status_line_t status_created()
{ return http_status_line_t{ status_code::created, "Created" }; }
inline http_status_line_t status_accepted()
{ return http_status_line_t{ status_code::accepted, "Accepted" }; }
inline http_status_line_t status_non_authoritative_information()
{ return http_status_line_t{ status_code::non_authoritative_information, "Non-Authoritative Information" }; }
inline http_status_line_t status_no_content()
{ return http_status_line_t{ status_code::no_content, "No Content" }; }
inline http_status_line_t status_reset_content()
{ return http_status_line_t{ status_code::reset_content, "Reset Content" }; }
inline http_status_line_t status_partial_content()
{ return http_status_line_t{ status_code::partial_content, "Partial Content" }; }
inline http_status_line_t status_multiple_choices()
{ return http_status_line_t{ status_code::multiple_choices, "Multiple Choices" }; }
inline http_status_line_t status_moved_permanently()
{ return http_status_line_t{ status_code::moved_permanently, "Moved Permanently" }; }
inline http_status_line_t status_found()
{ return http_status_line_t{ status_code::found, "Found" }; }
inline http_status_line_t status_see_other()
{ return http_status_line_t{ status_code::see_other, "See Other" }; }
inline http_status_line_t status_not_modified()
{ return http_status_line_t{ status_code::not_modified, "Not Modified" }; }
inline http_status_line_t status_use_proxy()
{ return http_status_line_t{ status_code::use_proxy, "Use Proxy" }; }
inline http_status_line_t status_temporary_redirect()
{ return http_status_line_t{ status_code::temporary_redirect, "Temporary Redirect" }; }
inline http_status_line_t status_bad_request()
{ return http_status_line_t{ status_code::bad_request, "Bad Request" }; }
inline http_status_line_t status_unauthorized()
{ return http_status_line_t{ status_code::unauthorized, "Unauthorized" }; }
inline http_status_line_t status_payment_required()
{ return http_status_line_t{ status_code::payment_required, "Payment Required" }; }
inline http_status_line_t status_forbidden()
{ return http_status_line_t{ status_code::forbidden, "Forbidden" }; }
inline http_status_line_t status_not_found()
{ return http_status_line_t{ status_code::not_found, "Not Found" }; }
inline http_status_line_t status_method_not_allowed()
{ return http_status_line_t{ status_code::method_not_allowed, "Method Not Allowed" }; }
inline http_status_line_t status_not_acceptable()
{ return http_status_line_t{ status_code::not_acceptable, "Not Acceptable" }; }
inline http_status_line_t status_proxy_authentication_required()
{ return http_status_line_t{status_code::proxy_authentication_required, "Proxy Authentication Required" }; }
inline http_status_line_t status_request_time_out()
{ return http_status_line_t{ status_code::request_time_out, "Request Timeout" }; }
inline http_status_line_t status_conflict()
{ return http_status_line_t{ status_code::conflict, "Conflict" }; }
inline http_status_line_t status_gone()
{ return http_status_line_t{ status_code::gone, "Gone" }; }
inline http_status_line_t status_length_required()
{ return http_status_line_t{ status_code::length_required, "Length Required" }; }
inline http_status_line_t status_precondition_failed()
{ return http_status_line_t{ status_code::precondition_failed, "Precondition Failed" }; }
inline http_status_line_t status_payload_too_large()
{ return http_status_line_t{ status_code::payload_too_large, "Payload Too Large" }; }
inline http_status_line_t status_uri_too_long()
{ return http_status_line_t{ status_code::uri_too_long, "URI Too Long" }; }
inline http_status_line_t status_unsupported_media_type()
{ return http_status_line_t{ status_code::unsupported_media_type, "Unsupported Media Type" }; }
inline http_status_line_t status_requested_range_not_satisfiable()
{ return http_status_line_t{ status_code::requested_range_not_satisfiable, "Requested Range Not Satisfiable" }; }
inline http_status_line_t status_expectation_failed()
{ return http_status_line_t{ status_code::expectation_failed, "Expectation Failed" }; }
inline http_status_line_t status_internal_server_error()
{ return http_status_line_t{ status_code::internal_server_error, "Internal Server Error" }; }
inline http_status_line_t status_not_implemented()
{ return http_status_line_t{ status_code::not_implemented, "Not Implemented" }; }
inline http_status_line_t status_bad_gateway()
{ return http_status_line_t{ status_code::bad_gateway, "Bad Gateway" }; }
inline http_status_line_t status_service_unavailable()
{ return http_status_line_t{ status_code::service_unavailable, "Service Unavailable" }; }
inline http_status_line_t status_gateway_time_out()
{ return http_status_line_t{ status_code::gateway_time_out, "Gateway Timeout" }; }
inline http_status_line_t status_http_version_not_supported()
{ return http_status_line_t{ status_code::http_version_not_supported, "HTTP Version not supported" }; }
// RFC 7538
inline http_status_line_t status_permanent_redirect()
{ return http_status_line_t{ status_code::permanent_redirect, "Permanent Redirect" }; }
// RFC 2518
inline http_status_line_t status_processing()
{ return http_status_line_t{ status_code::processing, "Processing" }; }
inline http_status_line_t status_multi_status()
{ return http_status_line_t{ status_code::multi_status, "Multi-Status" }; }
inline http_status_line_t status_unprocessable_entity()
{ return http_status_line_t{ status_code::unprocessable_entity, "Unprocessable Entity" }; }
inline http_status_line_t status_locked()
{ return http_status_line_t{ status_code::locked, "Locked" }; }
inline http_status_line_t status_failed_dependency()
{ return http_status_line_t{ status_code::failed_dependency, "Failed Dependency" }; }
inline http_status_line_t status_insufficient_storage()
{ return http_status_line_t{ status_code::insufficient_storage, "Insufficient Storage" }; }
// RFC 6585
inline http_status_line_t status_precondition_required()
{ return http_status_line_t{ status_code::precondition_required, "Precondition Required" }; }
inline http_status_line_t status_too_many_requests()
{ return http_status_line_t{ status_code::too_many_requests, "Too Many Requests" }; }
inline http_status_line_t status_request_header_fields_too_large()
{ return http_status_line_t{ status_code::request_header_fields_too_large, "Request Header Fields Too Large" }; }
inline http_status_line_t status_network_authentication_required()
{ return http_status_line_t{ status_code::network_authentication_required, "Network Authentication Required" }; }
//
// http_response_header_t
//
struct http_response_header_t final
: public http_header_common_t
{
public:
http_response_header_t()
{}
http_response_header_t( http_status_line_t status_line )
: m_status_line{ std::move( status_line ) }
{}
http_status_code_t
status_code() const noexcept
{ return m_status_line.status_code(); }
void
status_code( http_status_code_t c ) noexcept
{ m_status_line.status_code( c ); }
const std::string &
reason_phrase() const noexcept
{ return m_status_line.reason_phrase(); }
void
reason_phrase( std::string r )
{ m_status_line.reason_phrase( std::move( r ) ); }
const http_status_line_t &
status_line() const noexcept
{
return m_status_line;
}
void
status_line( http_status_line_t sl )
{
m_status_line = std::move( sl );
}
private:
http_status_line_t m_status_line;
};
} /* namespace restinio */
nonstd::optional_lite::optional
class optional
Definition: optional.hpp:919
restinio::default_http_methods_t
The default implementation for http_method_mapper.
Definition: http_headers.hpp:1832
restinio::default_http_methods_t::from_nodejs
static constexpr http_method_id_t from_nodejs(int value) noexcept
Definition: http_headers.hpp:1835
restinio::exception_t
Exception class for all exceptions thrown by RESTinio.
Definition: exception.hpp:26
restinio::http_header_field_t
A single header field.
Definition: http_headers.hpp:583
restinio::http_header_field_t::http_header_field_t
http_header_field_t(http_field_t field_id, string_view_t value)
Definition: http_headers.hpp:613
restinio::http_header_field_t::field_id
void field_id(http_field_t field_id)
Definition: http_headers.hpp:645
restinio::http_header_field_t::m_value
std::string m_value
Definition: http_headers.hpp:653
restinio::http_header_field_t::m_name
std::string m_name
Definition: http_headers.hpp:652
restinio::http_header_field_t::http_header_field_t
http_header_field_t(std::string name, std::string value)
Definition: http_headers.hpp:589
restinio::http_header_field_t::m_field_id
http_field_t m_field_id
Definition: http_headers.hpp:654
restinio::http_header_field_t::value
void value(std::string v)
Definition: http_headers.hpp:633
restinio::http_header_field_t::value
const std::string & value() const noexcept
Definition: http_headers.hpp:622
restinio::http_header_field_t::http_header_field_t
http_header_field_t(string_view_t name, string_view_t value)
Definition: http_headers.hpp:597
restinio::http_header_field_t::name
void name(std::string n)
Definition: http_headers.hpp:626
restinio::http_header_field_t::name
const std::string & name() const noexcept
Definition: http_headers.hpp:621
restinio::http_header_field_t::field_id
http_field_t field_id() const noexcept
Definition: http_headers.hpp:623
restinio::http_header_field_t::http_header_field_t
http_header_field_t(http_field_t field_id, std::string value)
Definition: http_headers.hpp:605
restinio::http_header_field_t::append_value
void append_value(string_view_t v)
Definition: http_headers.hpp:639
restinio::http_header_field_t::http_header_field_t
http_header_field_t()
Definition: http_headers.hpp:585
restinio::http_header_fields_t
Header fields map.
Definition: http_headers.hpp:703
restinio::http_header_fields_t::has_field
bool has_field(string_view_t field_name) const noexcept
Check field by name.
Definition: http_headers.hpp:754
restinio::http_header_fields_t::value_of
string_view_t value_of(string_view_t name) const
Get the value of a field or throw if the field not found.
Definition: http_headers.hpp:1271
restinio::http_header_fields_t::add_field
void add_field(http_header_field_t http_header_field)
Add a field in the form of http_header_field object.
Definition: http_headers.hpp:901
restinio::http_header_fields_t::http_header_fields_t
http_header_fields_t(const http_header_fields_t &)=default
restinio::http_header_fields_t::add_field
void add_field(http_field_t field_id, std::string field_value)
Add a field in the form of id-value pair.
Definition: http_headers.hpp:860
restinio::http_header_fields_t::value_of
string_view_t value_of(http_field_t field_id) const
Get the value of a field or throw if the field not found.
Definition: http_headers.hpp:1280
restinio::http_header_fields_t::find
fields_container_t::iterator find(string_view_t field_name) noexcept
Definition: http_headers.hpp:1515
restinio::http_header_fields_t::try_get_field
nullable_pointer_t< const std::string > try_get_field(http_field_t field_id) const noexcept
Try to get the value of a field by field ID.
Definition: http_headers.hpp:1021
restinio::http_header_fields_t::remove_all_of
std::size_t remove_all_of(string_view_t field_name) noexcept
Remove all occurences of a field with specified name.
Definition: http_headers.hpp:1221
restinio::http_header_fields_t::http_header_fields_t
http_header_fields_t(http_header_fields_t &&)=default
restinio::http_header_fields_t::const_iterator
fields_container_t::const_iterator const_iterator
Type of const_iterator for enumeration of fields.
Definition: http_headers.hpp:711
restinio::http_header_fields_t::stop_enumeration
static constexpr handling_result_t stop_enumeration() noexcept
Definition: http_headers.hpp:732
restinio::http_header_fields_t::~http_header_fields_t
virtual ~http_header_fields_t()
Definition: http_headers.hpp:741
restinio::http_header_fields_t::swap_fields
void swap_fields(http_header_fields_t &http_header_fields)
Definition: http_headers.hpp:747
restinio::http_header_fields_t::get_field_or
auto get_field_or(string_view_t field_name, const char *default_value) const
Get field by name or default value if the field not found.
Definition: http_headers.hpp:1076
restinio::http_header_fields_t::fields_container_t
std::vector< http_header_field_t > fields_container_t
Definition: http_headers.hpp:708
restinio::http_header_fields_t::m_fields
fields_container_t m_fields
Definition: http_headers.hpp:1558
restinio::http_header_fields_t::opt_value_of
optional_t< string_view_t > opt_value_of(string_view_t name) const noexcept
Get optional value of a field.
Definition: http_headers.hpp:1300
restinio::http_header_fields_t::continue_enumeration
static constexpr handling_result_t continue_enumeration() noexcept
Definition: http_headers.hpp:729
restinio::http_header_fields_t::cfind
fields_container_t::const_iterator cfind(string_view_t field_name) const noexcept
Definition: http_headers.hpp:1526
restinio::http_header_fields_t::for_each_value_of
void for_each_value_of(http_field_t field_id, Lambda &&lambda) const noexcept(noexcept(lambda(std::declval< const string_view_t & >())))
Enumeration of each value of a field.
Definition: http_headers.hpp:1401
restinio::http_header_fields_t::add_field
void add_field(std::string field_name, std::string field_value)
Add a field in the form of name-value pair.
Definition: http_headers.hpp:882
restinio::http_header_fields_t::for_each_value_of
void for_each_value_of(string_view_t field_name, Lambda &&lambda) const noexcept(noexcept(lambda(std::declval< const string_view_t & >())))
Enumeration of each value of a field.
Definition: http_headers.hpp:1457
restinio::http_header_fields_t::remove_field
bool remove_field(http_field_t field_id) noexcept
Remove field by id.
Definition: http_headers.hpp:1198
restinio::http_header_fields_t::operator=
http_header_fields_t & operator=(const http_header_fields_t &)=default
restinio::http_header_fields_t::get_field
const std::string & get_field(http_field_t field_id) const
Get field by id.
Definition: http_headers.hpp:986
restinio::http_header_fields_t::set_field
void set_field(std::string field_name, std::string field_value)
Set field with string pair.
Definition: http_headers.hpp:801
restinio::http_header_fields_t::get_field_or
std::string get_field_or(string_view_t field_name, std::string &&default_value) const
Get field value by field name or default value if the field not found.
Definition: http_headers.hpp:1059
restinio::http_header_fields_t::set_field
void set_field(http_field_t field_id, std::string field_value)
Set field with id-value pair.
Definition: http_headers.hpp:826
restinio::http_header_fields_t::operator=
http_header_fields_t & operator=(http_header_fields_t &&)=default
restinio::http_header_fields_t::get_field_or
std::string get_field_or(http_field_t field_id, std::string &&default_value) const
Get field by id or default value if the field not found.
Definition: http_headers.hpp:1148
restinio::http_header_fields_t::handling_result_t
handling_result_t
The result of handling yet another field value.
Definition: http_headers.hpp:721
restinio::http_header_fields_t::handling_result_t::stop_enumeration
@ stop_enumeration
The loop on field values should be stopped.
restinio::http_header_fields_t::handling_result_t::continue_enumeration
@ continue_enumeration
Next value of field should be found and passed to the next invocation of handler.
restinio::http_header_fields_t::http_header_fields_t
http_header_fields_t()
Definition: http_headers.hpp:735
restinio::http_header_fields_t::try_get_field
nullable_pointer_t< const std::string > try_get_field(string_view_t field_name) const noexcept
Try to get the value of a field by field name.
Definition: http_headers.hpp:975
restinio::http_header_fields_t::append_last_field
void append_last_field(string_view_t field_value)
Appends last added field.
Definition: http_headers.hpp:1509
restinio::http_header_fields_t::opt_value_of
optional_t< string_view_t > opt_value_of(http_field_t field_id) const noexcept
Get optional value of a field.
Definition: http_headers.hpp:1325
restinio::http_header_fields_t::get_field_or
std::string get_field_or(http_field_t field_id, string_view_t default_value) const
Get field by id or default value if the field not found.
Definition: http_headers.hpp:1102
restinio::http_header_fields_t::set_field
void set_field(http_header_field_t http_header_field)
Set header field via http_header_field_t.
Definition: http_headers.hpp:773
restinio::http_header_fields_t::for_each_field
void for_each_field(Lambda &&lambda) const noexcept(noexcept(lambda(std::declval< const http_header_field_t & >())))
Enumeration of fields.
Definition: http_headers.hpp:1361
restinio::http_header_fields_t::append_field
void append_field(string_view_t field_name, string_view_t field_value)
Append field with name.
Definition: http_headers.hpp:908
restinio::http_header_fields_t::get_field_or
auto get_field_or(http_field_t field_id, const char *default_value) const
Get field by id or default value if the field not found.
Definition: http_headers.hpp:1122
restinio::http_header_fields_t::end
const_iterator end() const noexcept
Definition: http_headers.hpp:1488
restinio::http_header_fields_t::get_field
const std::string & get_field(string_view_t field_name) const
Get field by name.
Definition: http_headers.hpp:951
restinio::http_header_fields_t::fields_count
auto fields_count() const noexcept
Definition: http_headers.hpp:1493
restinio::http_header_fields_t::get_field_or
auto get_field_or(string_view_t field_name, const std::string &default_value) const
Get field by name or default value if the field not found.
Definition: http_headers.hpp:1088
restinio::http_header_fields_t::begin
const_iterator begin() const noexcept
Definition: http_headers.hpp:1482
restinio::http_header_fields_t::remove_field
bool remove_field(string_view_t field_name) noexcept
Remove field by name.
Definition: http_headers.hpp:1174
restinio::http_header_fields_t::get_field_or
std::string get_field_or(string_view_t field_name, string_view_t default_value) const
Get field value by field name or default value if the field not found.
Definition: http_headers.hpp:1040
restinio::http_header_fields_t::has_field
bool has_field(http_field_t field_id) const noexcept
Check field by field-id.
Definition: http_headers.hpp:766
restinio::http_header_fields_t::cfind
fields_container_t::const_iterator cfind(http_field_t field_id) const noexcept
Definition: http_headers.hpp:1548
restinio::http_header_fields_t::get_field_or
auto get_field_or(http_field_t field_id, const std::string &default_value) const
Get field by id or default value if the field not found.
Definition: http_headers.hpp:1134
restinio::http_header_fields_t::remove_all_of
std::size_t remove_all_of(http_field_t field_id) noexcept
Remove all occurences of a field with specified id.
Definition: http_headers.hpp:1245
restinio::http_header_fields_t::find
fields_container_t::iterator find(http_field_t field_id) noexcept
Definition: http_headers.hpp:1537
restinio::http_header_fields_t::append_field
void append_field(http_field_t field_id, string_view_t field_value)
Append field with id.
Definition: http_headers.hpp:930
restinio::http_method_id_t
A type for representation of HTTP method ID.
Definition: http_headers.hpp:1744
restinio::http_method_id_t::m_value
int m_value
Definition: http_headers.hpp:1745
restinio::http_method_id_t::operator<
friend constexpr bool operator<(const http_method_id_t &a, const http_method_id_t &b) noexcept
Definition: http_headers.hpp:1787
restinio::http_method_id_t::unknown_method
static constexpr const int unknown_method
Definition: http_headers.hpp:1749
restinio::http_method_id_t::http_method_id_t
constexpr http_method_id_t(const http_method_id_t &) noexcept=default
restinio::http_method_id_t::operator!=
friend constexpr bool operator!=(const http_method_id_t &a, const http_method_id_t &b) noexcept
Definition: http_headers.hpp:1782
restinio::http_method_id_t::http_method_id_t
constexpr http_method_id_t() noexcept
Definition: http_headers.hpp:1751
restinio::http_method_id_t::http_method_id_t
constexpr http_method_id_t(http_method_id_t &&) noexcept=default
restinio::http_method_id_t::m_name
const char * m_name
Definition: http_headers.hpp:1746
restinio::http_method_id_t::raw_id
constexpr auto raw_id() const noexcept
Definition: http_headers.hpp:1771
restinio::http_method_id_t::operator=
constexpr http_method_id_t & operator=(const http_method_id_t &) noexcept=default
restinio::http_method_id_t::http_method_id_t
constexpr http_method_id_t(int value, const char *name) noexcept
Definition: http_headers.hpp:1755
restinio::http_method_id_t::operator==
friend constexpr bool operator==(const http_method_id_t &a, const http_method_id_t &b) noexcept
Definition: http_headers.hpp:1777
restinio::http_method_id_t::c_str
constexpr const char * c_str() const noexcept
Definition: http_headers.hpp:1774
restinio::http_status_code_t
A handy wrapper for HTTP response status code.
Definition: http_headers.hpp:1993
restinio::http_status_code_t::raw_code
constexpr auto raw_code() const noexcept
Definition: http_headers.hpp:2003
restinio::http_status_code_t::operator==
constexpr bool operator==(const http_status_code_t &sc) const noexcept
Definition: http_headers.hpp:2009
restinio::http_status_code_t::operator!=
constexpr bool operator!=(const http_status_code_t &sc) const noexcept
Definition: http_headers.hpp:2015
restinio::http_status_code_t::http_status_code_t
constexpr http_status_code_t() noexcept
Definition: http_headers.hpp:1995
restinio::http_status_code_t::operator<
constexpr bool operator<(const http_status_code_t &sc) const noexcept
Definition: http_headers.hpp:2021
restinio::http_status_code_t::http_status_code_t
constexpr http_status_code_t(std::uint16_t status_code) noexcept
Definition: http_headers.hpp:1998
restinio::http_status_code_t::m_status_code
std::uint16_t m_status_code
Status code value.
Definition: http_headers.hpp:2028
restinio::http_status_line_t
HTTP response header status line.
Definition: http_headers.hpp:2124
restinio::http_status_line_t::reason_phrase
void reason_phrase(std::string r)
Definition: http_headers.hpp:2149
restinio::http_status_line_t::status_code
void status_code(http_status_code_t c) noexcept
Definition: http_headers.hpp:2141
restinio::http_status_line_t::http_status_line_t
http_status_line_t(http_status_code_t sc, std::string reason_phrase)
Definition: http_headers.hpp:2129
restinio::http_status_line_t::m_reason_phrase
std::string m_reason_phrase
Definition: http_headers.hpp:2154
restinio::http_status_line_t::status_code
http_status_code_t status_code() const noexcept
Definition: http_headers.hpp:2137
restinio::http_status_line_t::m_status_code
http_status_code_t m_status_code
Definition: http_headers.hpp:2153
restinio::http_status_line_t::reason_phrase
const std::string & reason_phrase() const noexcept
Definition: http_headers.hpp:2145
restinio::http_status_line_t::http_status_line_t
http_status_line_t()
Definition: http_headers.hpp:2126
common_types.hpp
exception.hpp
RESTINIO_HTTP_METHOD_MAP
#define RESTINIO_HTTP_METHOD_MAP(RESTINIO_GEN)
HTTP methods mapping with nodejs http methods.
Definition: http_headers.hpp:1652
RESTINIO_HEADER_FIELDS_DEFAULT_RESERVE_COUNT
#define RESTINIO_HEADER_FIELDS_DEFAULT_RESERVE_COUNT
Definition: http_headers.hpp:668
RESTINIO_HTTP_METHOD_FUNC_GEN
#define RESTINIO_HTTP_METHOD_FUNC_GEN(func_name, nodejs_code, method_name)
Definition: http_headers.hpp:1799
RESTINIO_HTTP_FIELD_STR_GEN
#define RESTINIO_HTTP_FIELD_STR_GEN(name, string_name)
RESTINIO_HTTP_FIELDS_MAP
#define RESTINIO_HTTP_FIELDS_MAP(RESTINIO_GEN)
Definition: http_headers.hpp:34
RESTINIO_HTTP_CHECK_FOR_FIELD
#define RESTINIO_HTTP_CHECK_FOR_FIELD(field_id, candidate_field_name)
include_fmtlib.hpp
A special wrapper around fmtlib include files.
nonstd::optional_lite::std11::move
T & move(T &t)
Definition: optional.hpp:465
nonstd::optional_lite::swap
void swap(optional< T > &x, optional< T > &y)
Definition: optional.hpp:1705
restinio::impl::is_equal_caseless
bool is_equal_caseless(const char *a, const char *b, std::size_t size) noexcept
Comparator for fields names.
Definition: string_caseless_compare.hpp:40
restinio::impl::append_last_field_accessor
void append_last_field_accessor(http_header_fields_t &, string_view_t)
restinio::status_code::switching_protocols
constexpr http_status_code_t switching_protocols
Definition: http_headers.hpp:2042
restinio::status_code::gone
constexpr http_status_code_t gone
Definition: http_headers.hpp:2067
restinio::status_code::precondition_failed
constexpr http_status_code_t precondition_failed
Definition: http_headers.hpp:2069
restinio::status_code::ok
constexpr http_status_code_t ok
Definition: http_headers.hpp:2043
restinio::status_code::unauthorized
constexpr http_status_code_t unauthorized
Definition: http_headers.hpp:2058
restinio::status_code::bad_request
constexpr http_status_code_t bad_request
Definition: http_headers.hpp:2057
restinio::status_code::see_other
constexpr http_status_code_t see_other
Definition: http_headers.hpp:2053
restinio::status_code::multiple_choices
constexpr http_status_code_t multiple_choices
Definition: http_headers.hpp:2050
restinio::status_code::not_acceptable
constexpr http_status_code_t not_acceptable
Definition: http_headers.hpp:2063
restinio::status_code::not_found
constexpr http_status_code_t not_found
Definition: http_headers.hpp:2061
restinio::status_code::forbidden
constexpr http_status_code_t forbidden
Definition: http_headers.hpp:2060
restinio::status_code::gateway_time_out
constexpr http_status_code_t gateway_time_out
Definition: http_headers.hpp:2090
restinio::status_code::uri_too_long
constexpr http_status_code_t uri_too_long
Definition: http_headers.hpp:2081
restinio::status_code::partial_content
constexpr http_status_code_t partial_content
Definition: http_headers.hpp:2049
restinio::status_code::requested_range_not_satisfiable
constexpr http_status_code_t requested_range_not_satisfiable
Definition: http_headers.hpp:2084
restinio::status_code::unsupported_media_type
constexpr http_status_code_t unsupported_media_type
Definition: http_headers.hpp:2083
restinio::status_code::locked
constexpr http_status_code_t locked
Definition: http_headers.hpp:2105
restinio::status_code::not_implemented
constexpr http_status_code_t not_implemented
Definition: http_headers.hpp:2087
restinio::status_code::request_header_fields_too_large
constexpr http_status_code_t request_header_fields_too_large
Definition: http_headers.hpp:2112
restinio::status_code::payload_too_large
constexpr http_status_code_t payload_too_large
Definition: http_headers.hpp:2074
restinio::status_code::failed_dependency
constexpr http_status_code_t failed_dependency
Definition: http_headers.hpp:2106
restinio::status_code::unprocessable_entity
constexpr http_status_code_t unprocessable_entity
Definition: http_headers.hpp:2104
restinio::status_code::conflict
constexpr http_status_code_t conflict
Definition: http_headers.hpp:2066
restinio::status_code::network_authentication_required
constexpr http_status_code_t network_authentication_required
Definition: http_headers.hpp:2113
restinio::status_code::not_modified
constexpr http_status_code_t not_modified
Definition: http_headers.hpp:2054
restinio::status_code::no_content
constexpr http_status_code_t no_content
Definition: http_headers.hpp:2047
restinio::status_code::accepted
constexpr http_status_code_t accepted
Definition: http_headers.hpp:2045
restinio::status_code::created
constexpr http_status_code_t created
Definition: http_headers.hpp:2044
restinio::status_code::http_version_not_supported
constexpr http_status_code_t http_version_not_supported
Definition: http_headers.hpp:2091
restinio::status_code::multi_status
constexpr http_status_code_t multi_status
Definition: http_headers.hpp:2103
restinio::status_code::processing
constexpr http_status_code_t processing
Definition: http_headers.hpp:2102
restinio::status_code::bad_gateway
constexpr http_status_code_t bad_gateway
Definition: http_headers.hpp:2088
restinio::status_code::use_proxy
constexpr http_status_code_t use_proxy
Definition: http_headers.hpp:2055
restinio::status_code::found
constexpr http_status_code_t found
Definition: http_headers.hpp:2052
restinio::status_code::continue_
constexpr http_status_code_t continue_
Definition: http_headers.hpp:2040
restinio::status_code::temporary_redirect
constexpr http_status_code_t temporary_redirect
Definition: http_headers.hpp:2056
restinio::status_code::method_not_allowed
constexpr http_status_code_t method_not_allowed
Definition: http_headers.hpp:2062
restinio::status_code::permanent_redirect
constexpr http_status_code_t permanent_redirect
Definition: http_headers.hpp:2099
restinio::status_code::length_required
constexpr http_status_code_t length_required
Definition: http_headers.hpp:2068
restinio::status_code::insufficient_storage
constexpr http_status_code_t insufficient_storage
Definition: http_headers.hpp:2107
restinio::status_code::service_unavailable
constexpr http_status_code_t service_unavailable
Definition: http_headers.hpp:2089
restinio::status_code::precondition_required
constexpr http_status_code_t precondition_required
Definition: http_headers.hpp:2110
restinio::status_code::request_time_out
constexpr http_status_code_t request_time_out
Definition: http_headers.hpp:2065
restinio::status_code::internal_server_error
constexpr http_status_code_t internal_server_error
Definition: http_headers.hpp:2086
restinio::status_code::too_many_requests
constexpr http_status_code_t too_many_requests
Definition: http_headers.hpp:2111
restinio::status_code::proxy_authentication_required
constexpr http_status_code_t proxy_authentication_required
Definition: http_headers.hpp:2064
restinio::status_code::payment_required
constexpr http_status_code_t payment_required
Definition: http_headers.hpp:2059
restinio::status_code::moved_permanently
constexpr http_status_code_t moved_permanently
Definition: http_headers.hpp:2051
restinio::status_code::reset_content
constexpr http_status_code_t reset_content
Definition: http_headers.hpp:2048
restinio::status_code::expectation_failed
constexpr http_status_code_t expectation_failed
Definition: http_headers.hpp:2085
restinio::status_code::non_authoritative_information
constexpr http_status_code_t non_authoritative_information
Definition: http_headers.hpp:2046
restinio
Definition: asio_include.hpp:21
restinio::status_gone
http_status_line_t status_gone()
Definition: http_headers.hpp:2247
restinio::status_not_acceptable
http_status_line_t status_not_acceptable()
Definition: http_headers.hpp:2235
restinio::status_non_authoritative_information
http_status_line_t status_non_authoritative_information()
Definition: http_headers.hpp:2184
restinio::status_locked
http_status_line_t status_locked()
Definition: http_headers.hpp:2308
restinio::status_not_implemented
http_status_line_t status_not_implemented()
Definition: http_headers.hpp:2274
restinio::status_unprocessable_entity
http_status_line_t status_unprocessable_entity()
Definition: http_headers.hpp:2305
restinio::nullable_pointer_t
T * nullable_pointer_t
Type for pointer that can be nullptr.
Definition: common_types.hpp:154
restinio::status_http_version_not_supported
http_status_line_t status_http_version_not_supported()
Definition: http_headers.hpp:2286
restinio::status_payment_required
http_status_line_t status_payment_required()
Definition: http_headers.hpp:2223
restinio::status_conflict
http_status_line_t status_conflict()
Definition: http_headers.hpp:2244
restinio::status_permanent_redirect
http_status_line_t status_permanent_redirect()
Definition: http_headers.hpp:2295
restinio::status_partial_content
http_status_line_t status_partial_content()
Definition: http_headers.hpp:2193
restinio::string_view_t
nonstd::string_view string_view_t
Definition: string_view.hpp:19
restinio::status_no_content
http_status_line_t status_no_content()
Definition: http_headers.hpp:2187
restinio::status_network_authentication_required
http_status_line_t status_network_authentication_required()
Definition: http_headers.hpp:2327
restinio::status_not_modified
http_status_line_t status_not_modified()
Definition: http_headers.hpp:2208
restinio::status_failed_dependency
http_status_line_t status_failed_dependency()
Definition: http_headers.hpp:2311
restinio::status_moved_permanently
http_status_line_t status_moved_permanently()
Definition: http_headers.hpp:2199
restinio::status_forbidden
http_status_line_t status_forbidden()
Definition: http_headers.hpp:2226
restinio::http_connection_header_t
http_connection_header_t
Values for conection header field.
Definition: http_headers.hpp:1567
restinio::http_connection_header_t::close
@ close
restinio::http_connection_header_t::keep_alive
@ keep_alive
restinio::operator<<
std::ostream & operator<<(std::ostream &o, response_parts_attr_t attr)
Definition: common_types.hpp:82
restinio::status_continue
http_status_line_t status_continue()
Definition: http_headers.hpp:2169
restinio::status_requested_range_not_satisfiable
http_status_line_t status_requested_range_not_satisfiable()
Definition: http_headers.hpp:2265
restinio::status_internal_server_error
http_status_line_t status_internal_server_error()
Definition: http_headers.hpp:2271
restinio::status_use_proxy
http_status_line_t status_use_proxy()
Definition: http_headers.hpp:2211
restinio::status_request_time_out
http_status_line_t status_request_time_out()
Definition: http_headers.hpp:2241
restinio::status_created
http_status_line_t status_created()
Definition: http_headers.hpp:2178
restinio::status_unauthorized
http_status_line_t status_unauthorized()
Definition: http_headers.hpp:2220
restinio::status_temporary_redirect
http_status_line_t status_temporary_redirect()
Definition: http_headers.hpp:2214
restinio::status_gateway_time_out
http_status_line_t status_gateway_time_out()
Definition: http_headers.hpp:2283
restinio::status_found
http_status_line_t status_found()
Definition: http_headers.hpp:2202
restinio::status_multiple_choices
http_status_line_t status_multiple_choices()
Definition: http_headers.hpp:2196
restinio::http_method_unknown
constexpr http_method_id_t http_method_unknown()
Definition: http_headers.hpp:1808
restinio::status_insufficient_storage
http_status_line_t status_insufficient_storage()
Definition: http_headers.hpp:2314
restinio::status_unsupported_media_type
http_status_line_t status_unsupported_media_type()
Definition: http_headers.hpp:2262
restinio::status_too_many_requests
http_status_line_t status_too_many_requests()
Definition: http_headers.hpp:2321
restinio::status_bad_gateway
http_status_line_t status_bad_gateway()
Definition: http_headers.hpp:2277
restinio::status_expectation_failed
http_status_line_t status_expectation_failed()
Definition: http_headers.hpp:2268
restinio::status_see_other
http_status_line_t status_see_other()
Definition: http_headers.hpp:2205
restinio::string_to_field
http_field_t string_to_field(string_view_t field) noexcept
Helper function to get method string name.
Definition: http_headers.hpp:251
restinio::field_to_string
const char * field_to_string(http_field_t f) noexcept
Helper sunction to get method string name.
Definition: http_headers.hpp:553
restinio::status_reset_content
http_status_line_t status_reset_content()
Definition: http_headers.hpp:2190
restinio::status_ok
http_status_line_t status_ok()
Definition: http_headers.hpp:2175
restinio::http_field_t
http_field_t
C++ enum that repeats nodejs c-style enum.
Definition: http_headers.hpp:233
restinio::http_field_t::field_unspecified
@ field_unspecified
restinio::status_switching_protocols
http_status_line_t status_switching_protocols()
Definition: http_headers.hpp:2172
restinio::status_payload_too_large
http_status_line_t status_payload_too_large()
Definition: http_headers.hpp:2256
restinio::status_uri_too_long
http_status_line_t status_uri_too_long()
Definition: http_headers.hpp:2259
restinio::status_request_header_fields_too_large
http_status_line_t status_request_header_fields_too_large()
Definition: http_headers.hpp:2324
restinio::status_processing
http_status_line_t status_processing()
Definition: http_headers.hpp:2299
restinio::status_precondition_failed
http_status_line_t status_precondition_failed()
Definition: http_headers.hpp:2253
restinio::status_method_not_allowed
http_status_line_t status_method_not_allowed()
Definition: http_headers.hpp:2232
restinio::status_accepted
http_status_line_t status_accepted()
Definition: http_headers.hpp:2181
restinio::status_proxy_authentication_required
http_status_line_t status_proxy_authentication_required()
Definition: http_headers.hpp:2238
restinio::status_precondition_required
http_status_line_t status_precondition_required()
Definition: http_headers.hpp:2318
restinio::status_bad_request
http_status_line_t status_bad_request()
Definition: http_headers.hpp:2217
restinio::status_not_found
http_status_line_t status_not_found()
Definition: http_headers.hpp:2229
restinio::status_multi_status
http_status_line_t status_multi_status()
Definition: http_headers.hpp:2302
restinio::status_service_unavailable
http_status_line_t status_service_unavailable()
Definition: http_headers.hpp:2280
restinio::status_length_required
http_status_line_t status_length_required()
Definition: http_headers.hpp:2250
std
STL namespace.
optional.hpp
string_caseless_compare.hpp
Helpers for caseless comparison of strings.
string_view.hpp
restinio::http_header_common_t
Req/Resp headers common data.
Definition: http_headers.hpp:1580
restinio::http_header_common_t::should_keep_alive
void should_keep_alive(bool keep_alive) noexcept
Definition: http_headers.hpp:1617
restinio::http_header_common_t::content_length
void content_length(std::uint64_t l) noexcept
Definition: http_headers.hpp:1607
restinio::http_header_common_t::http_major
void http_major(std::uint16_t v) noexcept
Definition: http_headers.hpp:1589
restinio::http_header_common_t::should_keep_alive
bool should_keep_alive() const noexcept
Definition: http_headers.hpp:1611
restinio::http_header_common_t::m_http_connection_header_field_value
http_connection_header_t m_http_connection_header_field_value
Definition: http_headers.hpp:1648
restinio::http_header_common_t::http_major
std::uint16_t http_major() const noexcept
Http version.
Definition: http_headers.hpp:1585
restinio::http_header_common_t::connection
http_connection_header_t connection() const
Get the value of 'connection' header field.
Definition: http_headers.hpp:1626
restinio::http_header_common_t::m_http_major
std::uint16_t m_http_major
Http version.
Definition: http_headers.hpp:1641
restinio::http_header_common_t::m_content_length
std::uint64_t m_content_length
Length of body of an http-message.
Definition: http_headers.hpp:1646
restinio::http_header_common_t::content_length
std::uint64_t content_length() const noexcept
Length of body of an http-message.
Definition: http_headers.hpp:1603
restinio::http_header_common_t::http_minor
void http_minor(std::uint16_t v) noexcept
Definition: http_headers.hpp:1597
restinio::http_header_common_t::http_minor
std::uint16_t http_minor() const noexcept
Definition: http_headers.hpp:1593
restinio::http_header_common_t::m_http_minor
std::uint16_t m_http_minor
Definition: http_headers.hpp:1642
restinio::http_header_common_t::connection
void connection(http_connection_header_t ch) noexcept
Set the value of 'connection' header field.
Definition: http_headers.hpp:1633
restinio::http_request_header_t
Req header.
Definition: http_headers.hpp:1859
restinio::http_request_header_t::method
void method(http_method_id_t m) noexcept
Definition: http_headers.hpp:1885
restinio::http_request_header_t::request_target
void request_target(std::string t)
Definition: http_headers.hpp:1893
restinio::http_request_header_t::fragment
string_view_t fragment() const
Get the fragment part of the request URL.
Definition: http_headers.hpp:1941
restinio::http_request_header_t::m_method
http_method_id_t m_method
Definition: http_headers.hpp:1981
restinio::http_request_header_t::path
string_view_t path() const noexcept
Request URL-structure.
Definition: http_headers.hpp:1913
restinio::http_request_header_t::m_query_separator_pos
std::size_t m_query_separator_pos
Definition: http_headers.hpp:1983
restinio::http_request_header_t::request_target
const std::string & request_target() const noexcept
Definition: http_headers.hpp:1889
restinio::http_request_header_t::append_request_target
void append_request_target(const char *at, size_t length)
Helpfull function for using in parser callback.
Definition: http_headers.hpp:1954
restinio::http_request_header_t::m_fragment_separator_pos
std::size_t m_fragment_separator_pos
Definition: http_headers.hpp:1984
restinio::http_request_header_t::memchr_helper
static std::size_t memchr_helper(int chr, const char *from, std::size_t size)
Definition: http_headers.hpp:1861
restinio::http_request_header_t::method
http_method_id_t method() const noexcept
Definition: http_headers.hpp:1881
restinio::http_request_header_t::query
string_view_t query() const noexcept
Get the query part of the request URL.
Definition: http_headers.hpp:1924
restinio::http_request_header_t::http_request_header_t
http_request_header_t()=default
restinio::http_request_header_t::http_request_header_t
http_request_header_t(http_method_id_t method, std::string request_target_)
Definition: http_headers.hpp:1872
restinio::http_request_header_t::m_request_target
std::string m_request_target
Definition: http_headers.hpp:1982
restinio::http_response_header_t
Resp header.
Definition: http_headers.hpp:2338
restinio::http_response_header_t::status_code
void status_code(http_status_code_t c) noexcept
Definition: http_headers.hpp:2352
restinio::http_response_header_t::http_response_header_t
http_response_header_t()
Definition: http_headers.hpp:2340
restinio::http_response_header_t::status_line
const http_status_line_t & status_line() const noexcept
Definition: http_headers.hpp:2364
restinio::http_response_header_t::reason_phrase
void reason_phrase(std::string r)
Definition: http_headers.hpp:2360
restinio::http_response_header_t::status_line
void status_line(http_status_line_t sl)
Definition: http_headers.hpp:2370
restinio::http_response_header_t::status_code
http_status_code_t status_code() const noexcept
Definition: http_headers.hpp:2348
restinio::http_response_header_t::m_status_line
http_status_line_t m_status_line
Definition: http_headers.hpp:2376
restinio::http_response_header_t::http_response_header_t
http_response_header_t(http_status_line_t status_line)
Definition: http_headers.hpp:2343
restinio::http_response_header_t::reason_phrase
const std::string & reason_phrase() const noexcept
Definition: http_headers.hpp:2356
const
#define const
Definition: zconf.h:230