@@ -290,7 +290,7 @@ class helmet
290290 @return A reference to this object for chaining.
291291 */
292292 BOOST_HTTP_PROTO_DECL
293- csp_policy& set (const core::string_view& allow,
293+ csp_policy& allow (const core::string_view& allow,
294294 const csp_type& type);
295295
296296 /* * Remove a CSP directive.
@@ -314,161 +314,37 @@ class helmet
314314 @throws std::invalid_argument if parameters are empty.
315315 */
316316 BOOST_HTTP_PROTO_DECL
317- csp_policy& set (const core::string_view& allow,
317+ csp_policy& allow (const core::string_view& allow,
318318 const urls::url_view& source);
319319 };
320320};
321321
322- /* * Return X-Download-Options header configuration.
323-
324- Controls file download behavior in Internet Explorer 8+.
325-
326- @param type The download restriction type.
327-
328- @return Header name and value pair.
329- */
330322option_pair x_download_options (const helmet_download_type& type);
331323
332- /* * Return X-Frame-Options header configuration.
333-
334- Prevents clickjacking attacks by controlling frame embedding.
335-
336- @param origin The frame embedding policy.
337-
338- @return Header name and value pair.
339- */
340324option_pair x_frame_origin (const helmet_origin_type& origin);
341325
342- /* * Return X-XSS-Protection header configuration.
343-
344- Disables legacy XSS filtering which can create vulnerabilities.
345- Modern browsers rely on CSP instead.
346-
347- @return Header name and value pair (always "0").
348- */
349326option_pair x_xss_protection ();
350327
351- /* * Return X-Content-Type-Options header configuration.
352-
353- Prevents MIME-type sniffing attacks.
354-
355- @return Header name and value pair (always "nosniff").
356- */
357328option_pair x_content_type_options ();
358329
359- /* * Return Content-Security-Policy header configuration.
360-
361- Configures CSP to prevent XSS and data injection attacks.
362-
363- @param sp The CSP policy with directives.
364-
365- @return Header name and value pair.
366-
367- @throws std::invalid_argument if the policy is empty.
368- */
369330option_pair content_security_policy (const helmet::csp_policy& sp);
370331
371- /* * Return Strict-Transport-Security header configuration.
372-
373- Enforces HTTPS connections to prevent downgrade attacks.
374-
375- @param options HSTS configuration parameters.
376-
377- @return Header name and value pair.
378- */
379- template <const std::size_t Age, const bool IncludeDomains = true , const bool Preload = true >
380- inline option_pair strict_transport_security ()
381- {
382- std::string value = " max-age=" + std::to_string (Age);
383-
384- if constexpr (IncludeDomains)
385- {
386- value += " ; includeSubDomains" ;
387- }
388-
389- if constexpr (Preload)
390- {
391- value += " ; preload" ;
392- }
393-
394- return {" Strict-Transport-Security" , {value}};
395- }
396-
397- /* * Return Cross-Origin-Opener-Policy header configuration.
398-
399- Controls cross-origin window isolation.
400-
401- @param policy The COOP policy type.
332+ option_pair strict_transport_security (const std::size_t age, const bool include_domains = true , const bool preload = false );
402333
403- @return Header name and value pair.
404- */
405334option_pair cross_origin_opener_policy (const coop_policy_type& policy = coop_policy_type::same_origin);
406335
407- /* * Return Cross-Origin-Resource-Policy header configuration.
408-
409- Controls cross-origin resource sharing.
410-
411- @param policy The CORP policy type.
412-
413- @return Header name and value pair.
414- */
415336option_pair cross_origin_resource_policy (const corp_policy_type& policy = corp_policy_type::same_origin);
416337
417- /* * Return Cross-Origin-Embedder-Policy header configuration.
418-
419- Controls embedding of cross-origin resources.
420-
421- @param policy The COEP policy type.
422-
423- @return Header name and value pair.
424- */
425338option_pair cross_origin_embedder_policy (const coep_policy_type& policy = coep_policy_type::require_corp);
426339
427- /* * Return Referrer-Policy header configuration.
428-
429- Controls how much referrer information is sent with requests.
430-
431- @param policy The referrer policy type.
432-
433- @return Header name and value pair.
434- */
435340option_pair referrer_policy (const referrer_policy_type& policy = referrer_policy_type::no_referrer);
436341
437- /* * Return Origin-Agent-Cluster header configuration.
438-
439- Requests origin-keyed agent clusters for better isolation.
440-
441- @return Header name and value pair (always "?1").
442- */
443342option_pair origin_agent_cluster ();
444343
445- /* * Return X-DNS-Prefetch-Control header configuration.
446-
447- Controls DNS prefetching to balance performance and privacy.
448-
449- @param allow Whether to enable DNS prefetching.
450-
451- @return Header name and value pair.
452- */
453344option_pair dns_prefetch_control (bool allow = false );
454345
455- /* * Return X-Permitted-Cross-Domain-Policies header configuration.
456-
457- Controls cross-domain policy files for Flash and Adobe Acrobat.
458-
459- @param policy The cross-domain policy type.
460-
461- @return Header name and value pair.
462- */
463346option_pair permitted_cross_domain_policies (const cross_domain_policy_type& policy = cross_domain_policy_type::none);
464347
465- /* * Return configuration to remove X-Powered-By header.
466-
467- Removes the X-Powered-By header to avoid revealing
468- server technology details.
469-
470- @return Header name with empty value (triggers removal).
471- */
472348option_pair hide_powered_by ();
473349
474350}
0 commit comments