1 //
2 // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
3 //
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 //
7 // Official repository: https://github.com/boostorg/beast
8 //
9 
10 // Test that header file is self-contained.
11 #include <boost/beast/http/field.hpp>
12 
13 #include <boost/beast/_experimental/unit_test/suite.hpp>
14 
15 namespace boost {
16 namespace beast {
17 namespace http {
18 
19 class field_test : public beast::unit_test::suite
20 {
21 public:
22     void
testField()23     testField()
24     {
25         auto const match =
26             [&](field f, string_view s)
27             {
28                 BEAST_EXPECT(iequals(to_string(f), s));
29                 BEAST_EXPECT(string_to_field(s) == f);
30             };
31 
32         match(field::accept, "accept");
33         match(field::accept, "aCcept");
34         match(field::accept, "ACCEPT");
35 
36 
37         match(field::a_im, "A-IM");
38         match(field::accept, "Accept");
39         match(field::accept_additions, "Accept-Additions");
40         match(field::accept_charset, "Accept-Charset");
41         match(field::accept_datetime, "Accept-Datetime");
42         match(field::accept_encoding, "Accept-Encoding");
43         match(field::accept_features, "Accept-Features");
44         match(field::accept_language, "Accept-Language");
45         match(field::accept_patch, "Accept-Patch");
46         match(field::accept_post, "Accept-Post");
47         match(field::accept_ranges, "Accept-Ranges");
48         match(field::access_control, "Access-Control");
49         match(field::access_control_allow_credentials, "Access-Control-Allow-Credentials");
50         match(field::access_control_allow_headers, "Access-Control-Allow-Headers");
51         match(field::access_control_allow_methods, "Access-Control-Allow-Methods");
52         match(field::access_control_allow_origin, "Access-Control-Allow-Origin");
53         match(field::access_control_expose_headers, "Access-Control-Expose-Headers");
54         match(field::access_control_max_age, "Access-Control-Max-Age");
55         match(field::access_control_request_headers, "Access-Control-Request-Headers");
56         match(field::access_control_request_method, "Access-Control-Request-Method");
57         match(field::age, "Age");
58         match(field::allow, "Allow");
59         match(field::alpn, "ALPN");
60         match(field::also_control, "Also-Control");
61         match(field::alt_svc, "Alt-Svc");
62         match(field::alt_used, "Alt-Used");
63         match(field::alternate_recipient, "Alternate-Recipient");
64         match(field::alternates, "Alternates");
65         match(field::apparently_to, "Apparently-To");
66         match(field::apply_to_redirect_ref, "Apply-To-Redirect-Ref");
67         match(field::approved, "Approved");
68         match(field::archive, "Archive");
69         match(field::archived_at, "Archived-At");
70         match(field::article_names, "Article-Names");
71         match(field::article_updates, "Article-Updates");
72         match(field::authentication_control, "Authentication-Control");
73         match(field::authentication_info, "Authentication-Info");
74         match(field::authentication_results, "Authentication-Results");
75         match(field::authorization, "Authorization");
76         match(field::auto_submitted, "Auto-Submitted");
77         match(field::autoforwarded, "Autoforwarded");
78         match(field::autosubmitted, "Autosubmitted");
79         match(field::base, "Base");
80         match(field::bcc, "Bcc");
81         match(field::body, "Body");
82         match(field::c_ext, "C-Ext");
83         match(field::c_man, "C-Man");
84         match(field::c_opt, "C-Opt");
85         match(field::c_pep, "C-PEP");
86         match(field::c_pep_info, "C-PEP-Info");
87         match(field::cache_control, "Cache-Control");
88         match(field::caldav_timezones, "CalDAV-Timezones");
89         match(field::cancel_key, "Cancel-Key");
90         match(field::cancel_lock, "Cancel-Lock");
91         match(field::cc, "Cc");
92         match(field::close, "Close");
93         match(field::comments, "Comments");
94         match(field::compliance, "Compliance");
95         match(field::connection, "Connection");
96         match(field::content_alternative, "Content-Alternative");
97         match(field::content_base, "Content-Base");
98         match(field::content_description, "Content-Description");
99         match(field::content_disposition, "Content-Disposition");
100         match(field::content_duration, "Content-Duration");
101         match(field::content_encoding, "Content-Encoding");
102         match(field::content_features, "Content-features");
103         match(field::content_id, "Content-ID");
104         match(field::content_identifier, "Content-Identifier");
105         match(field::content_language, "Content-Language");
106         match(field::content_length, "Content-Length");
107         match(field::content_location, "Content-Location");
108         match(field::content_md5, "Content-MD5");
109         match(field::content_range, "Content-Range");
110         match(field::content_return, "Content-Return");
111         match(field::content_script_type, "Content-Script-Type");
112         match(field::content_style_type, "Content-Style-Type");
113         match(field::content_transfer_encoding, "Content-Transfer-Encoding");
114         match(field::content_type, "Content-Type");
115         match(field::content_version, "Content-Version");
116         match(field::control, "Control");
117         match(field::conversion, "Conversion");
118         match(field::conversion_with_loss, "Conversion-With-Loss");
119         match(field::cookie, "Cookie");
120         match(field::cookie2, "Cookie2");
121         match(field::cost, "Cost");
122         match(field::dasl, "DASL");
123         match(field::date, "Date");
124         match(field::date_received, "Date-Received");
125         match(field::dav, "DAV");
126         match(field::default_style, "Default-Style");
127         match(field::deferred_delivery, "Deferred-Delivery");
128         match(field::delivery_date, "Delivery-Date");
129         match(field::delta_base, "Delta-Base");
130         match(field::depth, "Depth");
131         match(field::derived_from, "Derived-From");
132         match(field::destination, "Destination");
133         match(field::differential_id, "Differential-ID");
134         match(field::digest, "Digest");
135         match(field::discarded_x400_ipms_extensions, "Discarded-X400-IPMS-Extensions");
136         match(field::discarded_x400_mts_extensions, "Discarded-X400-MTS-Extensions");
137         match(field::disclose_recipients, "Disclose-Recipients");
138         match(field::disposition_notification_options, "Disposition-Notification-Options");
139         match(field::disposition_notification_to, "Disposition-Notification-To");
140         match(field::distribution, "Distribution");
141         match(field::dkim_signature, "DKIM-Signature");
142         match(field::dl_expansion_history, "DL-Expansion-History");
143         match(field::downgraded_bcc, "Downgraded-Bcc");
144         match(field::downgraded_cc, "Downgraded-Cc");
145         match(field::downgraded_disposition_notification_to, "Downgraded-Disposition-Notification-To");
146         match(field::downgraded_final_recipient, "Downgraded-Final-Recipient");
147         match(field::downgraded_from, "Downgraded-From");
148         match(field::downgraded_in_reply_to, "Downgraded-In-Reply-To");
149         match(field::downgraded_mail_from, "Downgraded-Mail-From");
150         match(field::downgraded_message_id, "Downgraded-Message-Id");
151         match(field::downgraded_original_recipient, "Downgraded-Original-Recipient");
152         match(field::downgraded_rcpt_to, "Downgraded-Rcpt-To");
153         match(field::downgraded_references, "Downgraded-References");
154         match(field::downgraded_reply_to, "Downgraded-Reply-To");
155         match(field::downgraded_resent_bcc, "Downgraded-Resent-Bcc");
156         match(field::downgraded_resent_cc, "Downgraded-Resent-Cc");
157         match(field::downgraded_resent_from, "Downgraded-Resent-From");
158         match(field::downgraded_resent_reply_to, "Downgraded-Resent-Reply-To");
159         match(field::downgraded_resent_sender, "Downgraded-Resent-Sender");
160         match(field::downgraded_resent_to, "Downgraded-Resent-To");
161         match(field::downgraded_return_path, "Downgraded-Return-Path");
162         match(field::downgraded_sender, "Downgraded-Sender");
163         match(field::downgraded_to, "Downgraded-To");
164         match(field::ediint_features, "EDIINT-Features");
165         match(field::eesst_version, "Eesst-Version");
166         match(field::encoding, "Encoding");
167         match(field::encrypted, "Encrypted");
168         match(field::errors_to, "Errors-To");
169         match(field::etag, "ETag");
170         match(field::expect, "Expect");
171         match(field::expires, "Expires");
172         match(field::expiry_date, "Expiry-Date");
173         match(field::ext, "Ext");
174         match(field::followup_to, "Followup-To");
175         match(field::forwarded, "Forwarded");
176         match(field::from, "From");
177         match(field::generate_delivery_report, "Generate-Delivery-Report");
178         match(field::getprofile, "GetProfile");
179         match(field::hobareg, "Hobareg");
180         match(field::host, "Host");
181         match(field::http2_settings, "HTTP2-Settings");
182         match(field::if_, "If");
183         match(field::if_match, "If-Match");
184         match(field::if_modified_since, "If-Modified-Since");
185         match(field::if_none_match, "If-None-Match");
186         match(field::if_range, "If-Range");
187         match(field::if_schedule_tag_match, "If-Schedule-Tag-Match");
188         match(field::if_unmodified_since, "If-Unmodified-Since");
189         match(field::im, "IM");
190         match(field::importance, "Importance");
191         match(field::in_reply_to, "In-Reply-To");
192         match(field::incomplete_copy, "Incomplete-Copy");
193         match(field::injection_date, "Injection-Date");
194         match(field::injection_info, "Injection-Info");
195         match(field::jabber_id, "Jabber-ID");
196         match(field::keep_alive, "Keep-Alive");
197         match(field::keywords, "Keywords");
198         match(field::label, "Label");
199         match(field::language, "Language");
200         match(field::last_modified, "Last-Modified");
201         match(field::latest_delivery_time, "Latest-Delivery-Time");
202         match(field::lines, "Lines");
203         match(field::link, "Link");
204         match(field::list_archive, "List-Archive");
205         match(field::list_help, "List-Help");
206         match(field::list_id, "List-ID");
207         match(field::list_owner, "List-Owner");
208         match(field::list_post, "List-Post");
209         match(field::list_subscribe, "List-Subscribe");
210         match(field::list_unsubscribe, "List-Unsubscribe");
211         match(field::list_unsubscribe_post, "List-Unsubscribe-Post");
212         match(field::location, "Location");
213         match(field::lock_token, "Lock-Token");
214         match(field::man, "Man");
215         match(field::max_forwards, "Max-Forwards");
216         match(field::memento_datetime, "Memento-Datetime");
217         match(field::message_context, "Message-Context");
218         match(field::message_id, "Message-ID");
219         match(field::message_type, "Message-Type");
220         match(field::meter, "Meter");
221         match(field::method_check, "Method-Check");
222         match(field::method_check_expires, "Method-Check-Expires");
223         match(field::mime_version, "MIME-Version");
224         match(field::mmhs_acp127_message_identifier, "MMHS-Acp127-Message-Identifier");
225         match(field::mmhs_authorizing_users, "MMHS-Authorizing-Users");
226         match(field::mmhs_codress_message_indicator, "MMHS-Codress-Message-Indicator");
227         match(field::mmhs_copy_precedence, "MMHS-Copy-Precedence");
228         match(field::mmhs_exempted_address, "MMHS-Exempted-Address");
229         match(field::mmhs_extended_authorisation_info, "MMHS-Extended-Authorisation-Info");
230         match(field::mmhs_handling_instructions, "MMHS-Handling-Instructions");
231         match(field::mmhs_message_instructions, "MMHS-Message-Instructions");
232         match(field::mmhs_message_type, "MMHS-Message-Type");
233         match(field::mmhs_originator_plad, "MMHS-Originator-PLAD");
234         match(field::mmhs_originator_reference, "MMHS-Originator-Reference");
235         match(field::mmhs_other_recipients_indicator_cc, "MMHS-Other-Recipients-Indicator-CC");
236         match(field::mmhs_other_recipients_indicator_to, "MMHS-Other-Recipients-Indicator-To");
237         match(field::mmhs_primary_precedence, "MMHS-Primary-Precedence");
238         match(field::mmhs_subject_indicator_codes, "MMHS-Subject-Indicator-Codes");
239         match(field::mt_priority, "MT-Priority");
240         match(field::negotiate, "Negotiate");
241         match(field::newsgroups, "Newsgroups");
242         match(field::nntp_posting_date, "NNTP-Posting-Date");
243         match(field::nntp_posting_host, "NNTP-Posting-Host");
244         match(field::non_compliance, "Non-Compliance");
245         match(field::obsoletes, "Obsoletes");
246         match(field::opt, "Opt");
247         match(field::optional, "Optional");
248         match(field::optional_www_authenticate, "Optional-WWW-Authenticate");
249         match(field::ordering_type, "Ordering-Type");
250         match(field::organization, "Organization");
251         match(field::origin, "Origin");
252         match(field::original_encoded_information_types, "Original-Encoded-Information-Types");
253         match(field::original_from, "Original-From");
254         match(field::original_message_id, "Original-Message-ID");
255         match(field::original_recipient, "Original-Recipient");
256         match(field::original_sender, "Original-Sender");
257         match(field::original_subject, "Original-Subject");
258         match(field::originator_return_address, "Originator-Return-Address");
259         match(field::overwrite, "Overwrite");
260         match(field::p3p, "P3P");
261         match(field::path, "Path");
262         match(field::pep, "PEP");
263         match(field::pep_info, "Pep-Info");
264         match(field::pics_label, "PICS-Label");
265         match(field::position, "Position");
266         match(field::posting_version, "Posting-Version");
267         match(field::pragma, "Pragma");
268         match(field::prefer, "Prefer");
269         match(field::preference_applied, "Preference-Applied");
270         match(field::prevent_nondelivery_report, "Prevent-NonDelivery-Report");
271         match(field::priority, "Priority");
272         match(field::privicon, "Privicon");
273         match(field::profileobject, "ProfileObject");
274         match(field::protocol, "Protocol");
275         match(field::protocol_info, "Protocol-Info");
276         match(field::protocol_query, "Protocol-Query");
277         match(field::protocol_request, "Protocol-Request");
278         match(field::proxy_authenticate, "Proxy-Authenticate");
279         match(field::proxy_authentication_info, "Proxy-Authentication-Info");
280         match(field::proxy_authorization, "Proxy-Authorization");
281         match(field::proxy_connection, "Proxy-Connection");
282         match(field::proxy_features, "Proxy-Features");
283         match(field::proxy_instruction, "Proxy-Instruction");
284         match(field::public_, "Public");
285         match(field::public_key_pins, "Public-Key-Pins");
286         match(field::public_key_pins_report_only, "Public-Key-Pins-Report-Only");
287         match(field::range, "Range");
288         match(field::received, "Received");
289         match(field::received_spf, "Received-SPF");
290         match(field::redirect_ref, "Redirect-Ref");
291         match(field::references, "References");
292         match(field::referer, "Referer");
293         match(field::referer_root, "Referer-Root");
294         match(field::relay_version, "Relay-Version");
295         match(field::reply_by, "Reply-By");
296         match(field::reply_to, "Reply-To");
297         match(field::require_recipient_valid_since, "Require-Recipient-Valid-Since");
298         match(field::resent_bcc, "Resent-Bcc");
299         match(field::resent_cc, "Resent-Cc");
300         match(field::resent_date, "Resent-Date");
301         match(field::resent_from, "Resent-From");
302         match(field::resent_message_id, "Resent-Message-ID");
303         match(field::resent_reply_to, "Resent-Reply-To");
304         match(field::resent_sender, "Resent-Sender");
305         match(field::resent_to, "Resent-To");
306         match(field::resolution_hint, "Resolution-Hint");
307         match(field::resolver_location, "Resolver-Location");
308         match(field::retry_after, "Retry-After");
309         match(field::return_path, "Return-Path");
310         match(field::safe, "Safe");
311         match(field::schedule_reply, "Schedule-Reply");
312         match(field::schedule_tag, "Schedule-Tag");
313         match(field::sec_websocket_accept, "Sec-WebSocket-Accept");
314         match(field::sec_websocket_extensions, "Sec-WebSocket-Extensions");
315         match(field::sec_websocket_key, "Sec-WebSocket-Key");
316         match(field::sec_websocket_protocol, "Sec-WebSocket-Protocol");
317         match(field::sec_websocket_version, "Sec-WebSocket-Version");
318         match(field::security_scheme, "Security-Scheme");
319         match(field::see_also, "See-Also");
320         match(field::sender, "Sender");
321         match(field::sensitivity, "Sensitivity");
322         match(field::server, "Server");
323         match(field::set_cookie, "Set-Cookie");
324         match(field::set_cookie2, "Set-Cookie2");
325         match(field::setprofile, "SetProfile");
326         match(field::sio_label, "SIO-Label");
327         match(field::sio_label_history, "SIO-Label-History");
328         match(field::slug, "SLUG");
329         match(field::soapaction, "SoapAction");
330         match(field::solicitation, "Solicitation");
331         match(field::status_uri, "Status-URI");
332         match(field::strict_transport_security, "Strict-Transport-Security");
333         match(field::subject, "Subject");
334         match(field::subok, "SubOK");
335         match(field::subst, "Subst");
336         match(field::summary, "Summary");
337         match(field::supersedes, "Supersedes");
338         match(field::surrogate_capability, "Surrogate-Capability");
339         match(field::surrogate_control, "Surrogate-Control");
340         match(field::tcn, "TCN");
341         match(field::te, "TE");
342         match(field::timeout, "Timeout");
343         match(field::title, "Title");
344         match(field::to, "To");
345         match(field::topic, "Topic");
346         match(field::trailer, "Trailer");
347         match(field::transfer_encoding, "Transfer-Encoding");
348         match(field::ttl, "TTL");
349         match(field::ua_color, "UA-Color");
350         match(field::ua_media, "UA-Media");
351         match(field::ua_pixels, "UA-Pixels");
352         match(field::ua_resolution, "UA-Resolution");
353         match(field::ua_windowpixels, "UA-Windowpixels");
354         match(field::upgrade, "Upgrade");
355         match(field::urgency, "Urgency");
356         match(field::uri, "URI");
357         match(field::user_agent, "User-Agent");
358         match(field::variant_vary, "Variant-Vary");
359         match(field::vary, "Vary");
360         match(field::vbr_info, "VBR-Info");
361         match(field::version, "Version");
362         match(field::via, "Via");
363         match(field::want_digest, "Want-Digest");
364         match(field::warning, "Warning");
365         match(field::www_authenticate, "WWW-Authenticate");
366         match(field::x_archived_at, "X-Archived-At");
367         match(field::x_device_accept, "X-Device-Accept");
368         match(field::x_device_accept_charset, "X-Device-Accept-Charset");
369         match(field::x_device_accept_encoding, "X-Device-Accept-Encoding");
370         match(field::x_device_accept_language, "X-Device-Accept-Language");
371         match(field::x_device_user_agent, "X-Device-User-Agent");
372         match(field::x_frame_options, "X-Frame-Options");
373         match(field::x_mittente, "X-Mittente");
374         match(field::x_pgp_sig, "X-PGP-Sig");
375         match(field::x_ricevuta, "X-Ricevuta");
376         match(field::x_riferimento_message_id, "X-Riferimento-Message-ID");
377         match(field::x_tiporicevuta, "X-TipoRicevuta");
378         match(field::x_trasporto, "X-Trasporto");
379         match(field::x_verificasicurezza, "X-VerificaSicurezza");
380         match(field::x400_content_identifier, "X400-Content-Identifier");
381         match(field::x400_content_return, "X400-Content-Return");
382         match(field::x400_content_type, "X400-Content-Type");
383         match(field::x400_mts_identifier, "X400-MTS-Identifier");
384         match(field::x400_originator, "X400-Originator");
385         match(field::x400_received, "X400-Received");
386         match(field::x400_recipients, "X400-Recipients");
387         match(field::x400_trace, "X400-Trace");
388         match(field::xref, "Xref");
389 
390         auto const unknown =
391             [&](string_view s)
392             {
393                 BEAST_EXPECT(string_to_field(s) == field::unknown);
394             };
395         unknown("");
396         unknown("x");
397     }
398 
run()399     void run() override
400     {
401         testField();
402         pass();
403     }
404 };
405 
406 BEAST_DEFINE_TESTSUITE(beast,http,field);
407 
408 } // http
409 } // beast
410 } // boost
411