rustolio_utils/http/headers.rs
1//
2// SPDX-License-Identifier: MPL-2.0
3//
4// Copyright (c) 2026 Tobias Binnewies. All rights reserved.
5//
6// This Source Code Form is subject to the terms of the Mozilla Public
7// License, v. 2.0. If a copy of the MPL was not distributed with this
8// file, You can obtain one at http://mozilla.org/MPL/2.0/.
9//
10
11pub use http::HeaderValue;
12
13pub struct HeaderName;
14
15macro_rules! standard_headers {
16 (
17 $(
18 $(#[$docs:meta])*
19 ($name:ident, $konst:ident, $str:literal);
20 )+
21 ) => {
22 impl HeaderName {
23 $(
24 $(#[$docs])*
25 pub const $konst: &'static str = $str;
26 )*
27 }
28 };
29}
30
31// Generate constants for all standard HTTP headers. This includes a static hash
32// code for the "fast hash" path. The hash code for static headers *do not* have
33// to match the text representation of those headers. This is because header
34// strings are always converted to the static values (when they match) before
35// being hashed. This means that it is impossible to compare the static hash
36// code of CONTENT_LENGTH with "content-length".
37standard_headers! {
38 /// Advertises which content types the client is able to understand.
39 ///
40 /// The Accept request HTTP header advertises which content types, expressed
41 /// as MIME types, the client is able to understand. Using content
42 /// negotiation, the server then selects one of the proposals, uses it and
43 /// informs the client of its choice with the Content-Type response header.
44 /// Browsers set adequate values for this header depending of the context
45 /// where the request is done: when fetching a CSS stylesheet a different
46 /// value is set for the request than when fetching an image, video or a
47 /// script.
48 (Accept, ACCEPT, "Accept");
49
50 /// Advertises which character set the client is able to understand.
51 ///
52 /// The Accept-Charset request HTTP header advertises which character set
53 /// the client is able to understand. Using content negotiation, the server
54 /// then selects one of the proposals, uses it and informs the client of its
55 /// choice within the Content-Type response header. Browsers usually don't
56 /// set this header as the default value for each content type is usually
57 /// correct and transmitting it would allow easier fingerprinting.
58 ///
59 /// If the server cannot serve any matching character set, it can
60 /// theoretically send back a 406 (Not Acceptable) error code. But, for a
61 /// better user experience, this is rarely done and the more common way is
62 /// to ignore the Accept-Charset header in this case.
63 (AcceptCharset, ACCEPT_CHARSET, "Accept-Charset");
64
65 /// Advertises which content encoding the client is able to understand.
66 ///
67 /// The Accept-Encoding request HTTP header advertises which content
68 /// encoding, usually a compression algorithm, the client is able to
69 /// understand. Using content negotiation, the server selects one of the
70 /// proposals, uses it and informs the client of its choice with the
71 /// Content-Encoding response header.
72 ///
73 /// Even if both the client and the server supports the same compression
74 /// algorithms, the server may choose not to compress the body of a
75 /// response, if the identity value is also acceptable. Two common cases
76 /// lead to this:
77 ///
78 /// * The data to be sent is already compressed and a second compression
79 /// won't lead to smaller data to be transmitted. This may the case with
80 /// some image formats;
81 ///
82 /// * The server is overloaded and cannot afford the computational overhead
83 /// induced by the compression requirement. Typically, Microsoft recommends
84 /// not to compress if a server use more than 80 % of its computational
85 /// power.
86 ///
87 /// As long as the identity value, meaning no compression, is not explicitly
88 /// forbidden, by an identity;q=0 or a *;q=0 without another explicitly set
89 /// value for identity, the server must never send back a 406 Not Acceptable
90 /// error.
91 (AcceptEncoding, ACCEPT_ENCODING, "Accept-Encoding");
92
93 /// Advertises which languages the client is able to understand.
94 ///
95 /// The Accept-Language request HTTP header advertises which languages the
96 /// client is able to understand, and which locale variant is preferred.
97 /// Using content negotiation, the server then selects one of the proposals,
98 /// uses it and informs the client of its choice with the Content-Language
99 /// response header. Browsers set adequate values for this header according
100 /// their user interface language and even if a user can change it, this
101 /// happens rarely (and is frown upon as it leads to fingerprinting).
102 ///
103 /// This header is a hint to be used when the server has no way of
104 /// determining the language via another way, like a specific URL, that is
105 /// controlled by an explicit user decision. It is recommended that the
106 /// server never overrides an explicit decision. The content of the
107 /// Accept-Language is often out of the control of the user (like when
108 /// traveling and using an Internet Cafe in a different country); the user
109 /// may also want to visit a page in another language than the locale of
110 /// their user interface.
111 ///
112 /// If the server cannot serve any matching language, it can theoretically
113 /// send back a 406 (Not Acceptable) error code. But, for a better user
114 /// experience, this is rarely done and more common way is to ignore the
115 /// Accept-Language header in this case.
116 (AcceptLanguage, ACCEPT_LANGUAGE, "Accept-Language");
117
118 /// Marker used by the server to advertise partial request support.
119 ///
120 /// The Accept-Ranges response HTTP header is a marker used by the server to
121 /// advertise its support of partial requests. The value of this field
122 /// indicates the unit that can be used to define a range.
123 ///
124 /// In presence of an Accept-Ranges header, the browser may try to resume an
125 /// interrupted download, rather than to start it from the start again.
126 (AcceptRanges, ACCEPT_RANGES, "Accept-Ranges");
127
128 /// Preflight response indicating if the response to the request can be
129 /// exposed to the page.
130 ///
131 /// The Access-Control-Allow-Credentials response header indicates whether
132 /// or not the response to the request can be exposed to the page. It can be
133 /// exposed when the true value is returned; it can't in other cases.
134 ///
135 /// Credentials are cookies, authorization headers or TLS client
136 /// certificates.
137 ///
138 /// When used as part of a response to a preflight request, this indicates
139 /// whether or not the actual request can be made using credentials. Note
140 /// that simple GET requests are not preflighted, and so if a request is
141 /// made for a resource with credentials, if this header is not returned
142 /// with the resource, the response is ignored by the browser and not
143 /// returned to web content.
144 ///
145 /// The Access-Control-Allow-Credentials header works in conjunction with
146 /// the XMLHttpRequest.withCredentials property or with the credentials
147 /// option in the Request() constructor of the Fetch API. Credentials must
148 /// be set on both sides (the Access-Control-Allow-Credentials header and in
149 /// the XHR or Fetch request) in order for the CORS request with credentials
150 /// to succeed.
151 (AccessControlAllowCredentials, ACCESS_CONTROL_ALLOW_CREDENTIALS, "Access-Control-Allow-Credentials");
152
153 /// Preflight response indicating permitted HTTP headers.
154 ///
155 /// The Access-Control-Allow-Headers response header is used in response to
156 /// a preflight request to indicate which HTTP headers will be available via
157 /// Access-Control-Expose-Headers when making the actual request.
158 ///
159 /// The simple headers, Accept, Accept-Language, Content-Language,
160 /// Content-Type (but only with a MIME type of its parsed value (ignoring
161 /// parameters) of either application/x-www-form-urlencoded,
162 /// multipart/form-data, or text/plain), are always available and don't need
163 /// to be listed by this header.
164 ///
165 /// This header is required if the request has an
166 /// Access-Control-Request-Headers header.
167 (AccessControlAllowHeaders, ACCESS_CONTROL_ALLOW_HEADERS, "Access-Control-Allow-Headers");
168
169 /// Preflight header response indicating permitted access methods.
170 ///
171 /// The Access-Control-Allow-Methods response header specifies the method or
172 /// methods allowed when accessing the resource in response to a preflight
173 /// request.
174 (AccessControlAllowMethods, ACCESS_CONTROL_ALLOW_METHODS, "Access-Control-Allow-Methods");
175
176 /// Indicates whether the response can be shared with resources with the
177 /// given origin.
178 (AccessControlAllowOrigin, ACCESS_CONTROL_ALLOW_ORIGIN, "Access-Control-Allow-Origin");
179
180 /// Indicates which headers can be exposed as part of the response by
181 /// listing their names.
182 (AccessControlExposeHeaders, ACCESS_CONTROL_EXPOSE_HEADERS, "Access-Control-Expose-Headers");
183
184 /// Indicates how long the results of a preflight request can be cached.
185 (AccessControlMaxAge, ACCESS_CONTROL_MAX_AGE, "Access-Control-Max-Age");
186
187 /// Informs the server which HTTP headers will be used when an actual
188 /// request is made.
189 (AccessControlRequestHeaders, ACCESS_CONTROL_REQUEST_HEADERS, "access-control-reqUest-Headers");
190
191 /// Informs the server know which HTTP method will be used when the actual
192 /// request is made.
193 (AccessControlRequestMethod, ACCESS_CONTROL_REQUEST_METHOD, "Access-Control-Request-Method");
194
195 /// Indicates the time in seconds the object has been in a proxy cache.
196 ///
197 /// The Age header is usually close to zero. If it is Age: 0, it was
198 /// probably just fetched from the origin server; otherwise It is usually
199 /// calculated as a difference between the proxy's current date and the Date
200 /// general header included in the HTTP response.
201 (Age, AGE, "Age");
202
203 /// Lists the set of methods support by a resource.
204 ///
205 /// This header must be sent if the server responds with a 405 Method Not
206 /// Allowed status code to indicate which request methods can be used. An
207 /// empty Allow header indicates that the resource allows no request
208 /// methods, which might occur temporarily for a given resource, for
209 /// example.
210 (Allow, ALLOW, "Allow");
211
212 /// Advertises the availability of alternate services to clients.
213 (AltSvc, ALT_SVC, "Alt-Svc");
214
215 /// Contains the credentials to authenticate a user agent with a server.
216 ///
217 /// Usually this header is included after the server has responded with a
218 /// 401 Unauthorized status and the WWW-Authenticate header.
219 (Authorization, AUTHORIZATION, "Authorization");
220
221 /// Specifies directives for caching mechanisms in both requests and
222 /// responses.
223 ///
224 /// Caching directives are unidirectional, meaning that a given directive in
225 /// a request is not implying that the same directive is to be given in the
226 /// response.
227 (CacheControl, CACHE_CONTROL, "Cache-Control");
228
229 /// Indicates how caches have handled a response and its corresponding request.
230 ///
231 /// See [RFC 9211](https://www.rfc-editor.org/rfc/rfc9211.html).
232 (CacheStatus, CACHE_STATUS, "Cache-Status");
233
234 /// Specifies directives that allow origin servers to control the behavior of CDN caches
235 /// interposed between them and clients separately from other caches that might handle the
236 /// response.
237 ///
238 /// See [RFC 9213](https://www.rfc-editor.org/rfc/rfc9213.html).
239 (CdnCacheControl, CDN_CACHE_CONTROL, "CDN-Cache-Control");
240
241 /// Controls whether or not the network connection stays open after the
242 /// current transaction finishes.
243 ///
244 /// If the value sent is keep-alive, the connection is persistent and not
245 /// closed, allowing for subsequent requests to the same server to be done.
246 ///
247 /// Except for the standard hop-by-hop headers (Keep-Alive,
248 /// Transfer-Encoding, TE, Connection, Trailer, Upgrade, Proxy-Authorization
249 /// and Proxy-Authenticate), any hop-by-hop headers used by the message must
250 /// be listed in the Connection header, so that the first proxy knows he has
251 /// to consume them and not to forward them further. Standard hop-by-hop
252 /// headers can be listed too (it is often the case of Keep-Alive, but this
253 /// is not mandatory.
254 (Connection, CONNECTION, "Connection");
255
256 /// Indicates if the content is expected to be displayed inline.
257 ///
258 /// In a regular HTTP response, the Content-Disposition response header is a
259 /// header indicating if the content is expected to be displayed inline in
260 /// the browser, that is, as a Web page or as part of a Web page, or as an
261 /// attachment, that is downloaded and saved locally.
262 ///
263 /// In a multipart/form-data body, the HTTP Content-Disposition general
264 /// header is a header that can be used on the subpart of a multipart body
265 /// to give information about the field it applies to. The subpart is
266 /// delimited by the boundary defined in the Content-Type header. Used on
267 /// the body itself, Content-Disposition has no effect.
268 ///
269 /// The Content-Disposition header is defined in the larger context of MIME
270 /// messages for e-mail, but only a subset of the possible parameters apply
271 /// to HTTP forms and POST requests. Only the value form-data, as well as
272 /// the optional directive name and filename, can be used in the HTTP
273 /// context.
274 (ContentDisposition, CONTENT_DISPOSITION, "Content-Disposition");
275
276 /// Used to compress the media-type.
277 ///
278 /// When present, its value indicates what additional content encoding has
279 /// been applied to the entity-body. It lets the client know, how to decode
280 /// in order to obtain the media-type referenced by the Content-Type header.
281 ///
282 /// It is recommended to compress data as much as possible and therefore to
283 /// use this field, but some types of resources, like jpeg images, are
284 /// already compressed. Sometimes using additional compression doesn't
285 /// reduce payload size and can even make the payload longer.
286 (ContentEncoding, CONTENT_ENCODING, "Content-Encoding");
287
288 /// Used to describe the languages intended for the audience.
289 ///
290 /// This header allows a user to differentiate according to the users' own
291 /// preferred language. For example, if "Content-Language: de-DE" is set, it
292 /// says that the document is intended for German language speakers
293 /// (however, it doesn't indicate the document is written in German. For
294 /// example, it might be written in English as part of a language course for
295 /// German speakers).
296 ///
297 /// If no Content-Language is specified, the default is that the content is
298 /// intended for all language audiences. Multiple language tags are also
299 /// possible, as well as applying the Content-Language header to various
300 /// media types and not only to textual documents.
301 (ContentLanguage, CONTENT_LANGUAGE, "Content-Language");
302
303 /// Indicates the size of the entity-body.
304 ///
305 /// The header value must be a decimal indicating the number of octets sent
306 /// to the recipient.
307 (ContentLength, CONTENT_LENGTH, "Content-Length");
308
309 /// Indicates an alternate location for the returned data.
310 ///
311 /// The principal use case is to indicate the URL of the resource
312 /// transmitted as the result of content negotiation.
313 ///
314 /// Location and Content-Location are different: Location indicates the
315 /// target of a redirection (or the URL of a newly created document), while
316 /// Content-Location indicates the direct URL to use to access the resource,
317 /// without the need of further content negotiation. Location is a header
318 /// associated with the response, while Content-Location is associated with
319 /// the entity returned.
320 (ContentLocation, CONTENT_LOCATION, "Content-Location");
321
322 /// Indicates where in a full body message a partial message belongs.
323 (ContentRange, CONTENT_RANGE, "Content-Range");
324
325 /// Allows controlling resources the user agent is allowed to load for a
326 /// given page.
327 ///
328 /// With a few exceptions, policies mostly involve specifying server origins
329 /// and script endpoints. This helps guard against cross-site scripting
330 /// attacks (XSS).
331 (ContentSecurityPolicy, CONTENT_SECURITY_POLICY, "Content-Security-Policy");
332
333 /// Allows experimenting with policies by monitoring their effects.
334 ///
335 /// The HTTP Content-Security-Policy-Report-Only response header allows web
336 /// developers to experiment with policies by monitoring (but not enforcing)
337 /// their effects. These violation reports consist of JSON documents sent
338 /// via an HTTP POST request to the specified URI.
339 (ContentSecurityPolicyReportOnly, CONTENT_SECURITY_POLICY_REPORT_ONLY, "Content-Security-Policy-Report-Only");
340
341 /// Used to indicate the media type of the resource.
342 ///
343 /// In responses, a Content-Type header tells the client what the content
344 /// type of the returned content actually is. Browsers will do MIME sniffing
345 /// in some cases and will not necessarily follow the value of this header;
346 /// to prevent this behavior, the header X-Content-Type-Options can be set
347 /// to nosniff.
348 ///
349 /// In requests, (such as POST or PUT), the client tells the server what
350 /// type of data is actually sent.
351 (ContentType, CONTENT_TYPE, "Content-Type");
352
353 /// Contains stored HTTP cookies previously sent by the server with the
354 /// Set-Cookie header.
355 ///
356 /// The Cookie header might be omitted entirely, if the privacy setting of
357 /// the browser are set to block them, for example.
358 (Cookie, COOKIE, "Cookie");
359
360 /// Indicates the client's tracking preference.
361 ///
362 /// This header lets users indicate whether they would prefer privacy rather
363 /// than personalized content.
364 (Dnt, DNT, "DNT");
365
366 /// Contains the date and time at which the message was originated.
367 (Date, DATE, "Date");
368
369 /// Identifier for a specific version of a resource.
370 ///
371 /// This header allows caches to be more efficient, and saves bandwidth, as
372 /// a web server does not need to send a full response if the content has
373 /// not changed. On the other side, if the content has changed, etags are
374 /// useful to help prevent simultaneous updates of a resource from
375 /// overwriting each other ("mid-air collisions").
376 ///
377 /// If the resource at a given URL changes, a new Etag value must be
378 /// generated. Etags are therefore similar to fingerprints and might also be
379 /// used for tracking purposes by some servers. A comparison of them allows
380 /// to quickly determine whether two representations of a resource are the
381 /// same, but they might also be set to persist indefinitely by a tracking
382 /// server.
383 (Etag, ETAG, "ETag");
384
385 /// Indicates expectations that need to be fulfilled by the server in order
386 /// to properly handle the request.
387 ///
388 /// The only expectation defined in the specification is Expect:
389 /// 100-continue, to which the server shall respond with:
390 ///
391 /// * 100 if the information contained in the header is sufficient to cause
392 /// an immediate success,
393 ///
394 /// * 417 (Expectation Failed) if it cannot meet the expectation; or any
395 /// other 4xx status otherwise.
396 ///
397 /// For example, the server may reject a request if its Content-Length is
398 /// too large.
399 ///
400 /// No common browsers send the Expect header, but some other clients such
401 /// as cURL do so by default.
402 (Expect, EXPECT, "Expect");
403
404 /// Contains the date/time after which the response is considered stale.
405 ///
406 /// Invalid dates, like the value 0, represent a date in the past and mean
407 /// that the resource is already expired.
408 ///
409 /// If there is a Cache-Control header with the "max-age" or "s-max-age"
410 /// directive in the response, the Expires header is ignored.
411 (Expires, EXPIRES, "Expires");
412
413 /// Contains information from the client-facing side of proxy servers that
414 /// is altered or lost when a proxy is involved in the path of the request.
415 ///
416 /// The alternative and de-facto standard versions of this header are the
417 /// X-Forwarded-For, X-Forwarded-Host and X-Forwarded-Proto headers.
418 ///
419 /// This header is used for debugging, statistics, and generating
420 /// location-dependent content and by design it exposes privacy sensitive
421 /// information, such as the IP address of the client. Therefore the user's
422 /// privacy must be kept in mind when deploying this header.
423 (Forwarded, FORWARDED, "Forwarded");
424
425 /// Contains an Internet email address for a human user who controls the
426 /// requesting user agent.
427 ///
428 /// If you are running a robotic user agent (e.g. a crawler), the From
429 /// header should be sent, so you can be contacted if problems occur on
430 /// servers, such as if the robot is sending excessive, unwanted, or invalid
431 /// requests.
432 (From, FROM, "From");
433
434 /// Specifies the domain name of the server and (optionally) the TCP port
435 /// number on which the server is listening.
436 ///
437 /// If no port is given, the default port for the service requested (e.g.,
438 /// "80" for an HTTP URL) is implied.
439 ///
440 /// A Host header field must be sent in all HTTP/1.1 request messages. A 400
441 /// (Bad Request) status code will be sent to any HTTP/1.1 request message
442 /// that lacks a Host header field or contains more than one.
443 (Host, HOST, "Host");
444
445 /// Makes a request conditional based on the E-Tag.
446 ///
447 /// For GET and HEAD methods, the server will send back the requested
448 /// resource only if it matches one of the listed ETags. For PUT and other
449 /// non-safe methods, it will only upload the resource in this case.
450 ///
451 /// The comparison with the stored ETag uses the strong comparison
452 /// algorithm, meaning two files are considered identical byte to byte only.
453 /// This is weakened when the W/ prefix is used in front of the ETag.
454 ///
455 /// There are two common use cases:
456 ///
457 /// * For GET and HEAD methods, used in combination with an Range header, it
458 /// can guarantee that the new ranges requested comes from the same resource
459 /// than the previous one. If it doesn't match, then a 416 (Range Not
460 /// Satisfiable) response is returned.
461 ///
462 /// * For other methods, and in particular for PUT, If-Match can be used to
463 /// prevent the lost update problem. It can check if the modification of a
464 /// resource that the user wants to upload will not override another change
465 /// that has been done since the original resource was fetched. If the
466 /// request cannot be fulfilled, the 412 (Precondition Failed) response is
467 /// returned.
468 (IfMatch, IF_MATCH, "If-Match");
469
470 /// Makes a request conditional based on the modification date.
471 ///
472 /// The If-Modified-Since request HTTP header makes the request conditional:
473 /// the server will send back the requested resource, with a 200 status,
474 /// only if it has been last modified after the given date. If the request
475 /// has not been modified since, the response will be a 304 without any
476 /// body; the Last-Modified header will contain the date of last
477 /// modification. Unlike If-Unmodified-Since, If-Modified-Since can only be
478 /// used with a GET or HEAD.
479 ///
480 /// When used in combination with If-None-Match, it is ignored, unless the
481 /// server doesn't support If-None-Match.
482 ///
483 /// The most common use case is to update a cached entity that has no
484 /// associated ETag.
485 (IfModifiedSince, IF_MODIFIED_SINCE, "If-Modified-Since");
486
487 /// Makes a request conditional based on the E-Tag.
488 ///
489 /// The If-None-Match HTTP request header makes the request conditional. For
490 /// GET and HEAD methods, the server will send back the requested resource,
491 /// with a 200 status, only if it doesn't have an ETag matching the given
492 /// ones. For other methods, the request will be processed only if the
493 /// eventually existing resource's ETag doesn't match any of the values
494 /// listed.
495 ///
496 /// When the condition fails for GET and HEAD methods, then the server must
497 /// return HTTP status code 304 (Not Modified). For methods that apply
498 /// server-side changes, the status code 412 (Precondition Failed) is used.
499 /// Note that the server generating a 304 response MUST generate any of the
500 /// following header fields that would have been sent in a 200 (OK) response
501 /// to the same request: Cache-Control, Content-Location, Date, ETag,
502 /// Expires, and Vary.
503 ///
504 /// The comparison with the stored ETag uses the weak comparison algorithm,
505 /// meaning two files are considered identical not only if they are
506 /// identical byte to byte, but if the content is equivalent. For example,
507 /// two pages that would differ only by the date of generation in the footer
508 /// would be considered as identical.
509 ///
510 /// When used in combination with If-Modified-Since, it has precedence (if
511 /// the server supports it).
512 ///
513 /// There are two common use cases:
514 ///
515 /// * For `GET` and `HEAD` methods, to update a cached entity that has an associated ETag.
516 /// * For other methods, and in particular for `PUT`, `If-None-Match` used with
517 /// the `*` value can be used to save a file not known to exist,
518 /// guaranteeing that another upload didn't happen before, losing the data
519 /// of the previous put; this problems is the variation of the lost update
520 /// problem.
521 (IfNoneMatch, IF_NONE_MATCH, "If-None-Match");
522
523 /// Makes a request conditional based on range.
524 ///
525 /// The If-Range HTTP request header makes a range request conditional: if
526 /// the condition is fulfilled, the range request will be issued and the
527 /// server sends back a 206 Partial Content answer with the appropriate
528 /// body. If the condition is not fulfilled, the full resource is sent back,
529 /// with a 200 OK status.
530 ///
531 /// This header can be used either with a Last-Modified validator, or with
532 /// an ETag, but not with both.
533 ///
534 /// The most common use case is to resume a download, to guarantee that the
535 /// stored resource has not been modified since the last fragment has been
536 /// received.
537 (IfRange, IF_RANGE, "If-Range");
538
539 /// Makes the request conditional based on the last modification date.
540 ///
541 /// The If-Unmodified-Since request HTTP header makes the request
542 /// conditional: the server will send back the requested resource, or accept
543 /// it in the case of a POST or another non-safe method, only if it has not
544 /// been last modified after the given date. If the request has been
545 /// modified after the given date, the response will be a 412 (Precondition
546 /// Failed) error.
547 ///
548 /// There are two common use cases:
549 ///
550 /// * In conjunction non-safe methods, like POST, it can be used to
551 /// implement an optimistic concurrency control, like done by some wikis:
552 /// editions are rejected if the stored document has been modified since the
553 /// original has been retrieved.
554 ///
555 /// * In conjunction with a range request with a If-Range header, it can be
556 /// used to ensure that the new fragment requested comes from an unmodified
557 /// document.
558 (IfUnmodifiedSince, IF_UNMODIFIED_SINCE, "If-Unmodified-Since");
559
560 /// The Last-Modified header contains the date and time when the origin believes
561 /// the resource was last modified.
562 ///
563 /// The value is a valid Date/Time string defined in [RFC9910](https://datatracker.ietf.org/doc/html/rfc9110#section-5.6.7)
564 (LastModified, LAST_MODIFIED, "Last-Modified");
565
566 /// Allows the server to point an interested client to another resource
567 /// containing metadata about the requested resource.
568 (Link, LINK, "Link");
569
570 /// Indicates the URL to redirect a page to.
571 ///
572 /// The Location response header indicates the URL to redirect a page to. It
573 /// only provides a meaning when served with a 3xx status response.
574 ///
575 /// The HTTP method used to make the new request to fetch the page pointed
576 /// to by Location depends of the original method and of the kind of
577 /// redirection:
578 ///
579 /// * If 303 (See Also) responses always lead to the use of a GET method,
580 /// 307 (Temporary Redirect) and 308 (Permanent Redirect) don't change the
581 /// method used in the original request;
582 ///
583 /// * 301 (Permanent Redirect) and 302 (Found) doesn't change the method
584 /// most of the time, though older user-agents may (so you basically don't
585 /// know).
586 ///
587 /// All responses with one of these status codes send a Location header.
588 ///
589 /// Beside redirect response, messages with 201 (Created) status also
590 /// include the Location header. It indicates the URL to the newly created
591 /// resource.
592 ///
593 /// Location and Content-Location are different: Location indicates the
594 /// target of a redirection (or the URL of a newly created resource), while
595 /// Content-Location indicates the direct URL to use to access the resource
596 /// when content negotiation happened, without the need of further content
597 /// negotiation. Location is a header associated with the response, while
598 /// Content-Location is associated with the entity returned.
599 (Location, LOCATION, "Location");
600
601 /// Indicates the max number of intermediaries the request should be sent
602 /// through.
603 (MaxForwards, MAX_FORWARDS, "Max-Forwards");
604
605 /// Indicates where a fetch originates from.
606 ///
607 /// It doesn't include any path information, but only the server name. It is
608 /// sent with CORS requests, as well as with POST requests. It is similar to
609 /// the Referer header, but, unlike this header, it doesn't disclose the
610 /// whole path.
611 (Origin, ORIGIN, "Origin");
612
613 /// HTTP/1.0 header usually used for backwards compatibility.
614 ///
615 /// The Pragma HTTP/1.0 general header is an implementation-specific header
616 /// that may have various effects along the request-response chain. It is
617 /// used for backwards compatibility with HTTP/1.0 caches where the
618 /// Cache-Control HTTP/1.1 header is not yet present.
619 (Pragma, PRAGMA, "Pragma");
620
621 /// Defines the authentication method that should be used to gain access to
622 /// a proxy.
623 ///
624 /// Unlike `www-authenticate`, the `proxy-authenticate` header field applies
625 /// only to the next outbound client on the response chain. This is because
626 /// only the client that chose a given proxy is likely to have the
627 /// credentials necessary for authentication. However, when multiple proxies
628 /// are used within the same administrative domain, such as office and
629 /// regional caching proxies within a large corporate network, it is common
630 /// for credentials to be generated by the user agent and passed through the
631 /// hierarchy until consumed. Hence, in such a configuration, it will appear
632 /// as if Proxy-Authenticate is being forwarded because each proxy will send
633 /// the same challenge set.
634 ///
635 /// The `proxy-authenticate` header is sent along with a `407 Proxy
636 /// Authentication Required`.
637 (ProxyAuthenticate, PROXY_AUTHENTICATE, "Proxy-Authenticate");
638
639 /// Contains the credentials to authenticate a user agent to a proxy server.
640 ///
641 /// This header is usually included after the server has responded with a
642 /// 407 Proxy Authentication Required status and the Proxy-Authenticate
643 /// header.
644 (ProxyAuthorization, PROXY_AUTHORIZATION, "Proxy-Authorization");
645
646 /// Associates a specific cryptographic public key with a certain server.
647 ///
648 /// This decreases the risk of MITM attacks with forged certificates. If one
649 /// or several keys are pinned and none of them are used by the server, the
650 /// browser will not accept the response as legitimate, and will not display
651 /// it.
652 (PublicKeyPins, PUBLIC_KEY_PINS, "Public-Key-Pins");
653
654 /// Sends reports of pinning violation to the report-uri specified in the
655 /// header.
656 ///
657 /// Unlike `Public-Key-Pins`, this header still allows browsers to connect
658 /// to the server if the pinning is violated.
659 (PublicKeyPinsReportOnly, PUBLIC_KEY_PINS_REPORT_ONLY, "Public-Key-Pins-Report-Only");
660
661 /// Indicates the part of a document that the server should return.
662 ///
663 /// Several parts can be requested with one Range header at once, and the
664 /// server may send back these ranges in a multipart document. If the server
665 /// sends back ranges, it uses the 206 Partial Content for the response. If
666 /// the ranges are invalid, the server returns the 416 Range Not Satisfiable
667 /// error. The server can also ignore the Range header and return the whole
668 /// document with a 200 status code.
669 (Range, RANGE, "Range");
670
671 /// Contains the address of the previous web page from which a link to the
672 /// currently requested page was followed.
673 ///
674 /// The Referer header allows servers to identify where people are visiting
675 /// them from and may use that data for analytics, logging, or optimized
676 /// caching, for example.
677 (Referer, REFERER, "Referer");
678
679 /// Governs which referrer information should be included with requests
680 /// made.
681 (ReferrerPolicy, REFERRER_POLICY, "Referrer-Policy");
682
683 /// Informs the web browser that the current page or frame should be
684 /// refreshed.
685 (Refresh, REFRESH, "Refresh");
686
687 /// The Retry-After response HTTP header indicates how long the user agent
688 /// should wait before making a follow-up request. There are two main cases
689 /// this header is used:
690 ///
691 /// * When sent with a 503 (Service Unavailable) response, it indicates how
692 /// long the service is expected to be unavailable.
693 ///
694 /// * When sent with a redirect response, such as 301 (Moved Permanently),
695 /// it indicates the minimum time that the user agent is asked to wait
696 /// before issuing the redirected request.
697 (RetryAfter, RETRY_AFTER, "Retry-After");
698
699 /// The |Sec-WebSocket-Accept| header field is used in the WebSocket
700 /// opening handshake. It is sent from the server to the client to
701 /// confirm that the server is willing to initiate the WebSocket
702 /// connection.
703 (SecWebSocketAccept, SEC_WEBSOCKET_ACCEPT, "Sec-Websocket-Accept");
704
705 /// The |Sec-WebSocket-Extensions| header field is used in the WebSocket
706 /// opening handshake. It is initially sent from the client to the
707 /// server, and then subsequently sent from the server to the client, to
708 /// agree on a set of protocol-level extensions to use for the duration
709 /// of the connection.
710 (SecWebSocketExtensions, SEC_WEBSOCKET_EXTENSIONS, "Sec-Websocket-Extensions");
711
712 /// The |Sec-WebSocket-Key| header field is used in the WebSocket opening
713 /// handshake. It is sent from the client to the server to provide part
714 /// of the information used by the server to prove that it received a
715 /// valid WebSocket opening handshake. This helps ensure that the server
716 /// does not accept connections from non-WebSocket clients (e.g., HTTP
717 /// clients) that are being abused to send data to unsuspecting WebSocket
718 /// servers.
719 (SecWebSocketKey, SEC_WEBSOCKET_KEY, "Sec-Websocket-Key");
720
721 /// The |Sec-WebSocket-Protocol| header field is used in the WebSocket
722 /// opening handshake. It is sent from the client to the server and back
723 /// from the server to the client to confirm the subprotocol of the
724 /// connection. This enables scripts to both select a subprotocol and be
725 /// sure that the server agreed to serve that subprotocol.
726 (SecWebSocketProtocol, SEC_WEBSOCKET_PROTOCOL, "Sec-Websocket-Protocol");
727
728 /// The |Sec-WebSocket-Version| header field is used in the WebSocket
729 /// opening handshake. It is sent from the client to the server to
730 /// indicate the protocol version of the connection. This enables
731 /// servers to correctly interpret the opening handshake and subsequent
732 /// data being sent from the data, and close the connection if the server
733 /// cannot interpret that data in a safe manner.
734 (SecWebSocketVersion, SEC_WEBSOCKET_VERSION, "Sec-Websocket-Version");
735
736 /// Contains information about the software used by the origin server to
737 /// handle the request.
738 ///
739 /// Overly long and detailed Server values should be avoided as they
740 /// potentially reveal internal implementation details that might make it
741 /// (slightly) easier for attackers to find and exploit known security
742 /// holes.
743 (Server, SERVER, "Server");
744
745 /// Used to send cookies from the server to the user agent.
746 (SetCookie, SET_COOKIE, "Set-Cookie");
747
748 /// Tells the client to communicate with HTTPS instead of using HTTP.
749 (StrictTransportSecurity, STRICT_TRANSPORT_SECURITY, "Strict-Transport-Security");
750
751 /// Informs the server of transfer encodings willing to be accepted as part
752 /// of the response.
753 ///
754 /// See also the Transfer-Encoding response header for more details on
755 /// transfer encodings. Note that chunked is always acceptable for HTTP/1.1
756 /// recipients and you that don't have to specify "chunked" using the TE
757 /// header. However, it is useful for setting if the client is accepting
758 /// trailer fields in a chunked transfer coding using the "trailers" value.
759 (Te, TE, "TE");
760
761 /// Allows the sender to include additional fields at the end of chunked
762 /// messages.
763 (Trailer, TRAILER, "Trailer");
764
765 /// Specifies the form of encoding used to safely transfer the entity to the
766 /// client.
767 ///
768 /// `transfer-encoding` is a hop-by-hop header, that is applying to a
769 /// message between two nodes, not to a resource itself. Each segment of a
770 /// multi-node connection can use different `transfer-encoding` values. If
771 /// you want to compress data over the whole connection, use the end-to-end
772 /// header `content-encoding` header instead.
773 ///
774 /// When present on a response to a `HEAD` request that has no body, it
775 /// indicates the value that would have applied to the corresponding `GET`
776 /// message.
777 (TransferEncoding, TRANSFER_ENCODING, "Transfer-Encoding");
778
779 /// Contains a string that allows identifying the requesting client's
780 /// software.
781 (UserAgent, USER_AGENT, "User-Agent");
782
783 /// Used as part of the exchange to upgrade the protocol.
784 (Upgrade, UPGRADE, "Upgrade");
785
786 /// Sends a signal to the server expressing the client’s preference for an
787 /// encrypted and authenticated response.
788 (UpgradeInsecureRequests, UPGRADE_INSECURE_REQUESTS, "Upgrade-Insecure-Requests");
789
790 /// Determines how to match future requests with cached responses.
791 ///
792 /// The `vary` HTTP response header determines how to match future request
793 /// headers to decide whether a cached response can be used rather than
794 /// requesting a fresh one from the origin server. It is used by the server
795 /// to indicate which headers it used when selecting a representation of a
796 /// resource in a content negotiation algorithm.
797 ///
798 /// The `vary` header should be set on a 304 Not Modified response exactly
799 /// like it would have been set on an equivalent 200 OK response.
800 (Vary, VARY, "Vary");
801
802 /// Added by proxies to track routing.
803 ///
804 /// The `via` general header is added by proxies, both forward and reverse
805 /// proxies, and can appear in the request headers and the response headers.
806 /// It is used for tracking message forwards, avoiding request loops, and
807 /// identifying the protocol capabilities of senders along the
808 /// request/response chain.
809 (Via, VIA, "Via");
810
811 /// General HTTP header contains information about possible problems with
812 /// the status of the message.
813 ///
814 /// More than one `warning` header may appear in a response. Warning header
815 /// fields can in general be applied to any message, however some warn-codes
816 /// are specific to caches and can only be applied to response messages.
817 (Warning, WARNING, "Warning");
818
819 /// Defines the authentication method that should be used to gain access to
820 /// a resource.
821 (WwwAuthenticate, WWW_AUTHENTICATE, "WWW-Authenticate");
822
823 /// Marker used by the server to indicate that the MIME types advertised in
824 /// the `content-type` headers should not be changed and be followed.
825 ///
826 /// This allows to opt-out of MIME type sniffing, or, in other words, it is
827 /// a way to say that the webmasters knew what they were doing.
828 ///
829 /// This header was introduced by Microsoft in IE 8 as a way for webmasters
830 /// to block content sniffing that was happening and could transform
831 /// non-executable MIME types into executable MIME types. Since then, other
832 /// browsers have introduced it, even if their MIME sniffing algorithms were
833 /// less aggressive.
834 ///
835 /// Site security testers usually expect this header to be set.
836 (XContentTypeOptions, X_CONTENT_TYPE_OPTIONS, "X-Content-Type-Options");
837
838 /// Controls DNS prefetching.
839 ///
840 /// The `x-dns-prefetch-control` HTTP response header controls DNS
841 /// prefetching, a feature by which browsers proactively perform domain name
842 /// resolution on both links that the user may choose to follow as well as
843 /// URLs for items referenced by the document, including images, CSS,
844 /// JavaScript, and so forth.
845 ///
846 /// This prefetching is performed in the background, so that the DNS is
847 /// likely to have been resolved by the time the referenced items are
848 /// needed. This reduces latency when the user clicks a link.
849 (XDnsPrefetchControl, X_DNS_PREFETCH_CONTROL, "X-DNS-Prefetch-Control");
850
851 /// Indicates whether or not a browser should be allowed to render a page in
852 /// a frame.
853 ///
854 /// Sites can use this to avoid clickjacking attacks, by ensuring that their
855 /// content is not embedded into other sites.
856 ///
857 /// The added security is only provided if the user accessing the document
858 /// is using a browser supporting `x-frame-options`.
859 (XFrameOptions, X_FRAME_OPTIONS, "X-Frame-Options");
860
861 /// Stop pages from loading when an XSS attack is detected.
862 ///
863 /// The HTTP X-XSS-Protection response header is a feature of Internet
864 /// Explorer, Chrome and Safari that stops pages from loading when they
865 /// detect reflected cross-site scripting (XSS) attacks. Although these
866 /// protections are largely unnecessary in modern browsers when sites
867 /// implement a strong Content-Security-Policy that disables the use of
868 /// inline JavaScript ('unsafe-inline'), they can still provide protections
869 /// for users of older web browsers that don't yet support CSP.
870 (XXssProtection, X_XSS_PROTECTION, "X-XSS-Protection");
871}