2
3
6
7
11#include <restinio/impl/include_fmtlib.hpp>
13#include <restinio/impl/string_caseless_compare.hpp>
15#include <restinio/exception.hpp>
16#include <restinio/string_view.hpp>
17#include <restinio/common_types.hpp>
35#define RESTINIO_HTTP_FIELDS_MAP( RESTINIO_GEN )
36 RESTINIO_GEN( a_im, A-IM )
37 RESTINIO_GEN( accept, Accept )
38 RESTINIO_GEN( accept_additions, Accept-Additions )
39 RESTINIO_GEN( accept_charset, Accept-Charset )
40 RESTINIO_GEN( accept_datetime, Accept-Datetime )
41 RESTINIO_GEN( accept_encoding, Accept-Encoding )
42 RESTINIO_GEN( accept_features, Accept-Features )
43 RESTINIO_GEN( accept_language, Accept-Language )
44 RESTINIO_GEN( accept_patch, Accept-Patch )
45 RESTINIO_GEN( accept_post, Accept-Post )
46 RESTINIO_GEN( accept_ranges, Accept-Ranges )
47 RESTINIO_GEN( age, Age )
48 RESTINIO_GEN( allow, Allow )
49 RESTINIO_GEN( alpn, ALPN )
50 RESTINIO_GEN( alt_svc, Alt-Svc )
51 RESTINIO_GEN( alt_used, Alt-Used )
52 RESTINIO_GEN( alternates, Alternates )
53 RESTINIO_GEN( apply_to_redirect_ref, Apply-To-Redirect-Ref )
54 RESTINIO_GEN( authentication_control, Authentication-Control )
55 RESTINIO_GEN( authentication_info, Authentication-Info )
56 RESTINIO_GEN( authorization, Authorization )
57 RESTINIO_GEN( c_ext, C-Ext )
58 RESTINIO_GEN( c_man, C-Man )
59 RESTINIO_GEN( c_opt, C-Opt )
60 RESTINIO_GEN( c_pep, C-PEP )
61 RESTINIO_GEN( c_pep_info, C-PEP-Info )
62 RESTINIO_GEN( cache_control, Cache-Control )
63 RESTINIO_GEN( caldav_timezones, CalDAV-Timezones )
64 RESTINIO_GEN( close, Close )
65 RESTINIO_GEN( content_base, Content-Base )
66 RESTINIO_GEN( content_disposition, Content-Disposition )
67 RESTINIO_GEN( content_encoding, Content-Encoding )
68 RESTINIO_GEN( content_id, Content-ID )
69 RESTINIO_GEN( content_language, Content-Language )
70 RESTINIO_GEN( content_location, Content-Location )
71 RESTINIO_GEN( content_md5, Content-MD5 )
72 RESTINIO_GEN( content_range, Content-Range )
73 RESTINIO_GEN( content_script_type, Content-Script-Type )
74 RESTINIO_GEN( content_style_type, Content-Style-Type )
75 RESTINIO_GEN( content_type, Content-Type )
76 RESTINIO_GEN( content_version, Content-Version )
77 RESTINIO_GEN( cookie, Cookie )
78 RESTINIO_GEN( cookie2, Cookie2 )
79 RESTINIO_GEN( dasl, DASL )
80 RESTINIO_GEN( dav, DAV )
81 RESTINIO_GEN( date, Date )
82 RESTINIO_GEN( default_style, Default-Style )
83 RESTINIO_GEN( delta_base, Delta-Base )
84 RESTINIO_GEN( depth, Depth )
85 RESTINIO_GEN( derived_from, Derived-From )
86 RESTINIO_GEN( destination, Destination )
87 RESTINIO_GEN( differential_id, Differential-ID )
88 RESTINIO_GEN( digest, Digest )
89 RESTINIO_GEN( etag, ETag )
90 RESTINIO_GEN( expect, Expect )
91 RESTINIO_GEN( expires, Expires )
92 RESTINIO_GEN( ext, Ext )
93 RESTINIO_GEN( forwarded, Forwarded )
94 RESTINIO_GEN( from, From )
95 RESTINIO_GEN( getprofile, GetProfile )
96 RESTINIO_GEN( hobareg, Hobareg )
97 RESTINIO_GEN( host, Host )
98 RESTINIO_GEN( http2_settings, HTTP2-Settings )
99 RESTINIO_GEN( im, IM )
100 RESTINIO_GEN( if_, If )
101 RESTINIO_GEN( if_match, If-Match )
102 RESTINIO_GEN( if_modified_since, If-Modified-Since )
103 RESTINIO_GEN( if_none_match, If-None-Match )
104 RESTINIO_GEN( if_range, If-Range )
105 RESTINIO_GEN( if_schedule_tag_match, If-Schedule-Tag-Match )
106 RESTINIO_GEN( if_unmodified_since, If-Unmodified-Since )
107 RESTINIO_GEN( keep_alive, Keep-Alive )
108 RESTINIO_GEN( label, Label )
109 RESTINIO_GEN( last_modified, Last-Modified )
110 RESTINIO_GEN( link, Link )
111 RESTINIO_GEN( location, Location )
112 RESTINIO_GEN( lock_token, Lock-Token )
113 RESTINIO_GEN( man, Man )
114 RESTINIO_GEN( max_forwards, Max-Forwards )
115 RESTINIO_GEN( memento_datetime, Memento-Datetime )
116 RESTINIO_GEN( meter, Meter )
117 RESTINIO_GEN( mime_version, MIME-Version )
118 RESTINIO_GEN( negotiate, Negotiate )
119 RESTINIO_GEN( opt, Opt )
120 RESTINIO_GEN( optional_www_authenticate, Optional-WWW-Authenticate )
121 RESTINIO_GEN( ordering_type, Ordering-Type )
122 RESTINIO_GEN( origin, Origin )
123 RESTINIO_GEN( overwrite, Overwrite )
124 RESTINIO_GEN( p3p, P3P )
125 RESTINIO_GEN( pep, PEP )
126 RESTINIO_GEN( pics_label, PICS-Label )
127 RESTINIO_GEN( pep_info, Pep-Info )
128 RESTINIO_GEN( position, Position )
129 RESTINIO_GEN( pragma, Pragma )
130 RESTINIO_GEN( prefer, Prefer )
131 RESTINIO_GEN( preference_applied, Preference-Applied )
132 RESTINIO_GEN( profileobject, ProfileObject )
133 RESTINIO_GEN( protocol, Protocol )
134 RESTINIO_GEN( protocol_info, Protocol-Info )
135 RESTINIO_GEN( protocol_query, Protocol-Query )
136 RESTINIO_GEN( protocol_request, Protocol-Request )
137 RESTINIO_GEN( proxy_authenticate, Proxy-Authenticate )
138 RESTINIO_GEN( proxy_authentication_info, Proxy-Authentication-Info )
139 RESTINIO_GEN( proxy_authorization, Proxy-Authorization )
140 RESTINIO_GEN( proxy_features, Proxy-Features )
141 RESTINIO_GEN( proxy_instruction, Proxy-Instruction )
142 RESTINIO_GEN( public_, Public )
143 RESTINIO_GEN( public_key_pins, Public-Key-Pins )
144 RESTINIO_GEN( public_key_pins_report_only, Public-Key-Pins-Report-Only )
145 RESTINIO_GEN( range, Range )
146 RESTINIO_GEN( redirect_ref, Redirect-Ref )
147 RESTINIO_GEN( referer, Referer )
148 RESTINIO_GEN( retry_after, Retry-After )
149 RESTINIO_GEN( safe, Safe )
150 RESTINIO_GEN( schedule_reply, Schedule-Reply )
151 RESTINIO_GEN( schedule_tag, Schedule-Tag )
152 RESTINIO_GEN( sec_websocket_accept, Sec-WebSocket-Accept )
153 RESTINIO_GEN( sec_websocket_extensions, Sec-WebSocket-Extensions )
154 RESTINIO_GEN( sec_websocket_key, Sec-WebSocket-Key )
155 RESTINIO_GEN( sec_websocket_protocol, Sec-WebSocket-Protocol )
156 RESTINIO_GEN( sec_websocket_version, Sec-WebSocket-Version )
157 RESTINIO_GEN( security_scheme, Security-Scheme )
158 RESTINIO_GEN( server, Server )
159 RESTINIO_GEN( set_cookie, Set-Cookie )
160 RESTINIO_GEN( set_cookie2, Set-Cookie2 )
161 RESTINIO_GEN( setprofile, SetProfile )
162 RESTINIO_GEN( slug, SLUG )
163 RESTINIO_GEN( soapaction, SoapAction )
164 RESTINIO_GEN( status_uri, Status-URI )
165 RESTINIO_GEN( strict_transport_security, Strict-Transport-Security )
166 RESTINIO_GEN( surrogate_capability, Surrogate-Capability )
167 RESTINIO_GEN( surrogate_control, Surrogate-Control )
168 RESTINIO_GEN( tcn, TCN )
169 RESTINIO_GEN( te, TE )
170 RESTINIO_GEN( timeout, Timeout )
171 RESTINIO_GEN( topic, Topic )
172 RESTINIO_GEN( trailer, Trailer )
173 RESTINIO_GEN( transfer_encoding, Transfer-Encoding )
174 RESTINIO_GEN( ttl, TTL )
175 RESTINIO_GEN( urgency, Urgency )
176 RESTINIO_GEN( uri, URI )
177 RESTINIO_GEN( upgrade, Upgrade )
178 RESTINIO_GEN( user_agent, User-Agent )
179 RESTINIO_GEN( variant_vary, Variant-Vary )
180 RESTINIO_GEN( vary, Vary )
181 RESTINIO_GEN( via, Via )
182 RESTINIO_GEN( www_authenticate, WWW-Authenticate )
183 RESTINIO_GEN( want_digest, Want-Digest )
184 RESTINIO_GEN( warning, Warning )
185 RESTINIO_GEN( x_frame_options, X-Frame-Options )
187 RESTINIO_GEN( access_control, Access-Control )
188 RESTINIO_GEN( access_control_allow_credentials, Access-Control-Allow-Credentials )
189 RESTINIO_GEN( access_control_allow_headers, Access-Control-Allow-Headers )
190 RESTINIO_GEN( access_control_allow_methods, Access-Control-Allow-Methods )
191 RESTINIO_GEN( access_control_allow_origin, Access-Control-Allow-Origin )
192 RESTINIO_GEN( access_control_max_age, Access-Control-Max-Age )
193 RESTINIO_GEN( access_control_request_method, Access-Control-Request-Method )
194 RESTINIO_GEN( access_control_request_headers, Access-Control-Request-Headers )
195 RESTINIO_GEN( compliance, Compliance )
196 RESTINIO_GEN( content_transfer_encoding, Content-Transfer-Encoding )
197 RESTINIO_GEN( cost, Cost )
198 RESTINIO_GEN( ediint_features, EDIINT-Features )
199 RESTINIO_GEN( message_id, Message-ID )
200 RESTINIO_GEN( method_check, Method-Check )
201 RESTINIO_GEN( method_check_expires, Method-Check-Expires )
202 RESTINIO_GEN( non_compliance, Non-Compliance )
203 RESTINIO_GEN( optional, Optional )
204 RESTINIO_GEN( referer_root, Referer-Root )
205 RESTINIO_GEN( resolution_hint, Resolution-Hint )
206 RESTINIO_GEN( resolver_location, Resolver-Location )
207 RESTINIO_GEN( subok, SubOK )
208 RESTINIO_GEN( subst, Subst )
209 RESTINIO_GEN( title, Title )
210 RESTINIO_GEN( ua_color, UA-Color )
211 RESTINIO_GEN( ua_media, UA-Media )
212 RESTINIO_GEN( ua_pixels, UA-Pixels )
213 RESTINIO_GEN( ua_resolution, UA-Resolution )
214 RESTINIO_GEN( ua_windowpixels, UA-Windowpixels )
215 RESTINIO_GEN( version, Version )
216 RESTINIO_GEN( x_device_accept, X-Device-Accept )
217 RESTINIO_GEN( x_device_accept_charset, X-Device-Accept-Charset )
218 RESTINIO_GEN( x_device_accept_encoding, X-Device-Accept-Encoding )
219 RESTINIO_GEN( x_device_accept_language, X-Device-Accept-Language )
220 RESTINIO_GEN( x_device_user_agent, X-Device-User-Agent )
230
231
232
235#define RESTINIO_HTTP_FIELD_GEN( name, ignored ) name,
237#undef RESTINIO_HTTP_FIELD_GEN
254 const char * field_name = field.data();
255 const std::size_t field_name_size = field.size();
257#define RESTINIO_HTTP_CHECK_FOR_FIELD( field_id, candidate_field_name )
258 if( impl::is_equal_caseless(field_name, #candidate_field_name , field_name_size ) )
259 return http_field_t:: field_id;
263 switch( field_name_size )
543#undef RESTINIO_HTTP_CHECK_FOR_FIELD
556 const char * result =
"";
559 #define RESTINIO_HTTP_FIELD_STR_GEN( name, string_name )
560 case http_field_t::name: result = #string_name; break;
563 #undef RESTINIO_HTTP_FIELD_STR_GEN
577
578
579
580
581
582
593 :
m_name{ std::move( name ) }
594 ,
m_value{ std::move( value ) }
600 string_view_t value )
601 :
m_name{ name.data(), name.size() }
602 ,
m_value{ value.data(), value.size() }
610 ,
m_value{ std::move( value ) }
616 string_view_t value )
618 ,
m_value{ std::move( value ) }
630 m_field_id = string_to_field( m_name );
642 m_value.append( v.data(), v.size() );
668#if !defined( RESTINIO_HEADER_FIELDS_DEFAULT_RESERVE_COUNT )
669 #define RESTINIO_HEADER_FIELDS_DEFAULT_RESERVE_COUNT 4
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
716
717
718
719
720
750 std::swap( m_fields, http_header_fields.m_fields );
757 return m_fields.cend() != cfind( field_name );
762
763
764
765
769 return m_fields.cend() != cfind( field_id );
776 fields_container_t::iterator it;
781 it = find( http_header_field.field_id() );
787 it = find( http_header_field.name() );
790 if( m_fields.end() != it )
792 *it = std::move( http_header_field );
796 m_fields.emplace_back( std::move( http_header_field ) );
803 std::string field_name,
804 std::string field_value )
806 const auto it = find( field_name );
808 if( m_fields.end() != it )
810 it->name( std::move( field_name ) );
811 it->value( std::move( field_value ) );
815 m_fields.emplace_back(
816 std::move( field_name ),
817 std::move( field_value ) );
823
824
825
829 std::string field_value )
833 const auto it = find( field_id );
835 if( m_fields.end() != it )
837 it->value( std::move( field_value ) );
841 m_fields.emplace_back(
843 std::move( field_value ) );
849
850
851
852
853
854
855
856
857
858
859
863 std::string field_value )
867 m_fields.emplace_back(
869 std::move( field_value ) );
874
875
876
877
878
879
880
881
884 std::string field_name,
885 std::string field_value )
887 m_fields.emplace_back(
888 std::move( field_name ),
889 std::move( field_value ) );
893
894
895
896
897
898
899
900
904 m_fields.push_back( std::move(http_header_field) );
910 string_view_t field_name,
911 string_view_t field_value )
913 const auto it = find( field_name );
915 if( m_fields.end() != it )
917 it->append_value( field_value );
921 m_fields.emplace_back( field_name, field_value );
927
928
929
933 string_view_t field_value )
937 const auto it = find( field_id );
939 if( m_fields.end() != it )
941 it->append_value( field_value );
945 m_fields.emplace_back( field_id, field_value );
954 const auto it = cfind( field_name );
956 if( m_fields.end() == it )
967
968
969
970
971
972
973
974
975
976
980 const auto it = cfind( field_name );
981 if( m_fields.end() == it )
984 return std::addressof(it->value());
994 "unspecified fields cannot be searched by id" };
997 const auto it = cfind( field_id );
999 if( m_fields.end() == it )
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1027 const auto it = cfind( field_id );
1028 if( m_fields.end() != it )
1029 return std::addressof(it->value());
1037
1038
1039
1040
1043 string_view_t field_name,
1044 string_view_t default_value )
const
1046 const auto it = cfind( field_name );
1048 if( m_fields.end() == it )
1049 return std::string( default_value.data(), default_value.size() );
1056
1057
1058
1059
1062 string_view_t field_name,
1063 std::string && default_value )
const
1065 const auto it = cfind( field_name );
1067 if( m_fields.end() == it )
1068 return std::move(default_value);
1075
1076
1079 string_view_t field_name,
1080 const char * default_value )
const
1082 return this->get_field_or( field_name, string_view_t{ default_value } );
1087
1088
1091 string_view_t field_name,
1092 const std::string & default_value )
const
1094 return this->get_field_or( field_name, string_view_t{ default_value } );
1099
1100
1101
1102
1106 string_view_t default_value )
const
1110 const auto it = cfind( field_id );
1112 if( m_fields.end() != it )
1116 return std::string( default_value.data(), default_value.size() );
1121
1122
1126 const char * default_value )
const
1128 return this->get_field_or( field_id, string_view_t{ default_value } );
1133
1134
1138 const std::string & default_value )
const
1140 return this->get_field_or( field_id, string_view_t{ default_value } );
1145
1146
1147
1148
1152 std::string && default_value )
const
1156 const auto it = cfind( field_id );
1158 if( m_fields.end() != it )
1162 return std::move( default_value );
1167
1168
1169
1170
1171
1172
1173
1174
1178 const auto it = find( field_name );
1180 if( m_fields.end() != it )
1182 m_fields.erase( it );
1191
1192
1193
1194
1195
1196
1197
1198
1204 const auto it = find( field_id );
1206 if( m_fields.end() != it )
1208 m_fields.erase( it );
1218
1219
1220
1221
1225 std::size_t count{};
1226 for(
auto it = m_fields.begin(); it != m_fields.end(); )
1228 if(
impl::is_equal_caseless( it->name(), field_name ) )
1230 it = m_fields.erase( it );
1242
1243
1244
1245
1249 std::size_t count{};
1252 for(
auto it = m_fields.begin(); it != m_fields.end(); )
1254 if( it->field_id() == field_id )
1256 it = m_fields.erase( it );
1268
1269
1270
1275 string_view_t name )
const
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1304 string_view_t name )
const noexcept
1306 std::optional< string_view_t > result;
1308 if(
auto * ptr =
this->try_get_field(name) )
1309 result = string_view_t{ *ptr };
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1331 std::optional< string_view_t > result;
1333 if(
auto * ptr =
this->try_get_field(field_id) )
1334 result = string_view_t{ *ptr };
1339
1340
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361 template<
typename Lambda >
1364 noexcept(
noexcept(
lambda(
1367 for(
const auto & f : m_fields )
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401 template<
typename Lambda >
1405 Lambda && lambda )
const
1406 noexcept(
noexcept(
lambda(
1412 decltype(lambda(std::declval<
const string_view_t &>()))
1414 "lambda should return restinio::http_header_fields_t::handling_result_t" );
1416 for(
const auto & f : m_fields )
1418 if( field_id == f.field_id() )
1420 const handling_result_t r = lambda( f.value() );
1421 if( stop_enumeration() == r )
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457 template<
typename Lambda >
1460 string_view_t field_name,
1461 Lambda && lambda )
const
1462 noexcept(
noexcept(
lambda(
1468 decltype(lambda(std::declval<
const string_view_t &>()))
1470 "lambda should return restinio::http_header_fields_t::handling_result_t" );
1472 for(
const auto & f : m_fields )
1474 if( impl::is_equal_caseless( f.name(), field_name ) )
1476 const handling_result_t r = lambda( f.value() );
1477 if( stop_enumeration() == r )
1486 return m_fields.cbegin();
1492 return m_fields.cend();
1497 return m_fields.size();
1503
1504
1505
1506
1507
1508
1509
1513 m_fields.back().append_value( field_value );
1517 find( string_view_t field_name )
noexcept
1519 return std::find_if(
1522 [&](
const auto & f ){
1523 return impl::is_equal_caseless( f.name(), field_name );
1528 cfind( string_view_t field_name )
const noexcept
1530 return std::find_if(
1533 [&](
const auto & f ){
1534 return impl::is_equal_caseless( f.name(), field_name );
1541 return std::find_if(
1544 [&](
const auto & f ){
1545 return f.field_id() == field_id;
1552 return std::find_if(
1555 [&](
const auto & f ){
1556 return f.field_id() == field_id;
1654#define RESTINIO_HTTP_METHOD_MAP(RESTINIO_GEN)
1655 RESTINIO_GEN( http_method_delete, HTTP_DELETE, DELETE )
1656 RESTINIO_GEN( http_method_get, HTTP_GET, GET )
1657 RESTINIO_GEN( http_method_head, HTTP_HEAD, HEAD )
1658 RESTINIO_GEN( http_method_post, HTTP_POST, POST )
1659 RESTINIO_GEN( http_method_put, HTTP_PUT, PUT )
1661 RESTINIO_GEN( http_method_connect, HTTP_CONNECT, CONNECT )
1662 RESTINIO_GEN( http_method_options, HTTP_OPTIONS, OPTIONS )
1663 RESTINIO_GEN( http_method_trace, HTTP_TRACE, TRACE )
1665 RESTINIO_GEN( http_method_copy, HTTP_COPY, COPY )
1666 RESTINIO_GEN( http_method_lock, HTTP_LOCK, LOCK )
1667 RESTINIO_GEN( http_method_mkcol, HTTP_MKCOL, MKCOL )
1668 RESTINIO_GEN( http_method_move, HTTP_MOVE, MOVE )
1669 RESTINIO_GEN( http_method_propfind, HTTP_PROPFIND, PROPFIND )
1670 RESTINIO_GEN( http_method_proppatch, HTTP_PROPPATCH, PROPPATCH )
1671 RESTINIO_GEN( http_method_search, HTTP_SEARCH, SEARCH )
1672 RESTINIO_GEN( http_method_unlock, HTTP_UNLOCK, UNLOCK )
1673 RESTINIO_GEN( http_method_bind, HTTP_BIND, BIND )
1674 RESTINIO_GEN( http_method_rebind, HTTP_REBIND, REBIND )
1675 RESTINIO_GEN( http_method_unbind, HTTP_UNBIND, UNBIND )
1676 RESTINIO_GEN( http_method_acl, HTTP_ACL, ACL )
1678 RESTINIO_GEN( http_method_report, HTTP_REPORT, REPORT )
1679 RESTINIO_GEN( http_method_mkactivity, HTTP_MKACTIVITY, MKACTIVITY )
1680 RESTINIO_GEN( http_method_checkout, HTTP_CHECKOUT, CHECKOUT )
1681 RESTINIO_GEN( http_method_merge, HTTP_MERGE, MERGE )
1683 RESTINIO_GEN( http_method_msearch, HTTP_MSEARCH, M-SEARCH)
1684 RESTINIO_GEN( http_method_notify, HTTP_NOTIFY, NOTIFY )
1685 RESTINIO_GEN( http_method_subscribe, HTTP_SUBSCRIBE, SUBSCRIBE )
1686 RESTINIO_GEN( http_method_unsubscribe, HTTP_UNSUBSCRIBE, UNSUBSCRIBE )
1688 RESTINIO_GEN( http_method_patch, HTTP_PATCH, PATCH )
1689 RESTINIO_GEN( http_method_purge, HTTP_PURGE, PURGE )
1691 RESTINIO_GEN( http_method_mkcalendar, HTTP_MKCALENDAR, MKCALENDAR )
1693 RESTINIO_GEN( http_method_link, HTTP_LINK, LINK )
1694 RESTINIO_GEN( http_method_unlink, HTTP_UNLINK, UNLINK )
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1755 ,
m_name{
"<undefined>" }
1759 const char * name )
noexcept
1775 constexpr const char *
1778 friend constexpr bool
1783 friend constexpr bool
1788 friend constexpr bool
1794inline std::ostream &
1801#define RESTINIO_HTTP_METHOD_FUNC_GEN( func_name, nodejs_code, method_name )
1802 inline constexpr http_method_id_t func_name() {
1803 return { nodejs_code, #method_name };
1807#undef RESTINIO_HTTP_METHOD_FUNC_GEN
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1842#define RESTINIO_HTTP_METHOD_FUNC_GEN( func_name, nodejs_code, method_name )
1843 case nodejs_code : result = func_name(); break;
1846#undef RESTINIO_HTTP_METHOD_FUNC_GEN
1859struct http_request_header_t
final
1865 const char * result =
static_cast<
const char * >(
1866 std::memchr( from, chr, size ) );
1868 return result ?
static_cast< std::size_t >( result - from ) : size;
1876 std::string request_target_ )
1879 request_target( std::move( request_target_ ) );
1911
1912
1913
1917 return string_view_t{ m_request_target.data(), m_query_separator_pos };
1922
1923
1924
1929 m_fragment_separator_pos == m_query_separator_pos ?
1930 string_view_t{
nullptr, 0 } :
1932 m_request_target.data() + m_query_separator_pos + 1,
1933 m_fragment_separator_pos - m_query_separator_pos - 1 };
1939
1940
1941
1946 m_request_target.size() == m_fragment_separator_pos ?
1947 string_view_t{
nullptr, 0 } :
1949 m_request_target.data() + m_fragment_separator_pos + 1,
1950 m_request_target.size() - m_fragment_separator_pos - 1 };
1963 const auto fragment_separator_pos_inc =
2035
2036
2037template<
typename CharT,
typename Traits >
2038inline std::basic_ostream<CharT, Traits> &
2040 std::basic_ostream<CharT, Traits> & to,
2146 std::string reason_phrase )
2172inline std::ostream &
2180
2181
2306
2307
2351struct http_response_header_t
final
The default implementation for http_method_mapper.
static constexpr http_method_id_t from_nodejs(int value) noexcept
Exception class for all exceptions thrown by RESTinio.
exception_t(const char *err)
A type for representation of HTTP method ID.
friend constexpr bool operator<(const http_method_id_t &a, const http_method_id_t &b) noexcept
static constexpr const int unknown_method
constexpr http_method_id_t & operator=(http_method_id_t &&) noexcept=default
constexpr http_method_id_t(const http_method_id_t &) noexcept=default
friend constexpr bool operator!=(const http_method_id_t &a, const http_method_id_t &b) noexcept
constexpr http_method_id_t() noexcept
constexpr http_method_id_t(http_method_id_t &&) noexcept=default
constexpr auto raw_id() const noexcept
constexpr http_method_id_t & operator=(const http_method_id_t &) noexcept=default
constexpr http_method_id_t(int value, const char *name) noexcept
friend constexpr bool operator==(const http_method_id_t &a, const http_method_id_t &b) noexcept
constexpr const char * c_str() const noexcept
A handy wrapper for HTTP response status code.
constexpr auto raw_code() const noexcept
constexpr bool operator==(const http_status_code_t &sc) const noexcept
constexpr bool operator!=(const http_status_code_t &sc) const noexcept
constexpr http_status_code_t() noexcept
constexpr bool operator<(const http_status_code_t &sc) const noexcept
constexpr http_status_code_t(std::uint16_t status_code) noexcept
std::uint16_t m_status_code
Status code value.
HTTP response header status line.
void reason_phrase(std::string r)
void status_code(http_status_code_t c) noexcept
http_status_line_t(http_status_code_t sc, std::string reason_phrase)
std::string m_reason_phrase
http_status_code_t status_code() const noexcept
http_status_code_t m_status_code
const std::string & reason_phrase() const noexcept
#define RESTINIO_FMT_FORMAT_STRING(s)
void append_last_field_accessor(http_header_fields_t &, string_view_t)
constexpr http_status_code_t switching_protocols
constexpr http_status_code_t gone
constexpr http_status_code_t precondition_failed
constexpr http_status_code_t ok
constexpr http_status_code_t unauthorized
constexpr http_status_code_t bad_request
constexpr http_status_code_t see_other
constexpr http_status_code_t multiple_choices
constexpr http_status_code_t not_acceptable
constexpr http_status_code_t not_found
constexpr http_status_code_t forbidden
constexpr http_status_code_t gateway_time_out
constexpr http_status_code_t uri_too_long
constexpr http_status_code_t partial_content
constexpr http_status_code_t requested_range_not_satisfiable
constexpr http_status_code_t unsupported_media_type
constexpr http_status_code_t locked
constexpr http_status_code_t not_implemented
constexpr http_status_code_t request_header_fields_too_large
constexpr http_status_code_t payload_too_large
constexpr http_status_code_t failed_dependency
constexpr http_status_code_t unprocessable_entity
constexpr http_status_code_t conflict
constexpr http_status_code_t network_authentication_required
constexpr http_status_code_t not_modified
constexpr http_status_code_t no_content
constexpr http_status_code_t accepted
constexpr http_status_code_t created
constexpr http_status_code_t http_version_not_supported
constexpr http_status_code_t multi_status
constexpr http_status_code_t processing
constexpr http_status_code_t bad_gateway
constexpr http_status_code_t use_proxy
constexpr http_status_code_t found
constexpr http_status_code_t continue_
constexpr http_status_code_t temporary_redirect
constexpr http_status_code_t method_not_allowed
constexpr http_status_code_t permanent_redirect
constexpr http_status_code_t length_required
constexpr http_status_code_t insufficient_storage
constexpr http_status_code_t service_unavailable
constexpr http_status_code_t precondition_required
constexpr http_status_code_t request_time_out
constexpr http_status_code_t internal_server_error
constexpr http_status_code_t too_many_requests
constexpr http_status_code_t proxy_authentication_required
constexpr http_status_code_t payment_required
constexpr http_status_code_t moved_permanently
constexpr http_status_code_t reset_content
constexpr http_status_code_t expectation_failed
constexpr http_status_code_t non_authoritative_information
http_status_line_t status_gone()
http_status_line_t status_not_acceptable()
http_status_line_t status_non_authoritative_information()
http_status_line_t status_locked()
http_status_line_t status_not_implemented()
http_status_line_t status_unprocessable_entity()
http_status_line_t status_http_version_not_supported()
http_field_t http_field
Helper alies to omitt _t suffix.
http_status_line_t status_payment_required()
http_status_line_t status_conflict()
http_status_line_t status_permanent_redirect()
http_status_line_t status_partial_content()
http_status_line_t status_no_content()
http_status_line_t status_network_authentication_required()
http_status_line_t status_not_modified()
http_status_line_t status_failed_dependency()
http_status_line_t status_moved_permanently()
http_status_line_t status_forbidden()
http_connection_header_t
Values for conection header field.
http_status_line_t status_continue()
http_status_line_t status_requested_range_not_satisfiable()
http_status_line_t status_internal_server_error()
http_status_line_t status_use_proxy()
http_status_line_t status_request_time_out()
http_status_line_t status_created()
http_status_line_t status_unauthorized()
http_status_line_t status_temporary_redirect()
http_status_line_t status_gateway_time_out()
http_status_line_t status_found()
http_status_line_t status_multiple_choices()
constexpr http_method_id_t http_method_unknown()
http_status_line_t status_insufficient_storage()
http_status_line_t status_unsupported_media_type()
http_status_line_t status_too_many_requests()
http_status_line_t status_bad_gateway()
http_status_line_t status_expectation_failed()
http_status_line_t status_see_other()
http_field_t string_to_field(string_view_t field) noexcept
Helper function to get method string name.
const char * field_to_string(http_field_t f) noexcept
Helper sunction to get method string name.
http_status_line_t status_reset_content()
http_status_line_t status_ok()
http_field_t
C++ enum that repeats nodejs c-style enum.
http_status_line_t status_switching_protocols()
http_status_line_t status_payload_too_large()
http_status_line_t status_uri_too_long()
http_status_line_t status_request_header_fields_too_large()
http_status_line_t status_processing()
http_status_line_t status_precondition_failed()
http_status_line_t status_method_not_allowed()
http_status_line_t status_accepted()
http_status_line_t status_proxy_authentication_required()
http_status_line_t status_precondition_required()
http_status_line_t status_bad_request()
http_status_line_t status_not_found()
http_status_line_t status_multi_status()
http_status_line_t status_service_unavailable()
http_status_line_t status_length_required()