Skip to main content

ntex_files/header/
common.rs

1use super::{EntityTag, HttpDate};
2use crate::{header, standard_header};
3
4header! {
5    /// `If-Unmodified-Since` header, defined in
6    /// [RFC7232](http://tools.ietf.org/html/rfc7232#section-3.4)
7    ///
8    /// The `If-Unmodified-Since` header field makes the request method
9    /// conditional on the selected representation's last modification date
10    /// being earlier than or equal to the date provided in the field-value.
11    /// This field accomplishes the same purpose as If-Match for cases where
12    /// the user agent does not have an entity-tag for the representation.
13    ///
14    /// # ABNF
15    ///
16    /// ```text
17    /// If-Unmodified-Since = HTTP-date
18    /// ```
19    ///
20    /// # Example values
21    ///
22    /// * `Sat, 29 Oct 1994 19:43:31 GMT`
23    ///
24    (IfUnmodifiedSince, "If-Unmodified-Since") => [HttpDate]
25}
26
27standard_header!(IfUnmodifiedSince, IF_UNMODIFIED_SINCE);
28
29header! {
30    /// `If-Modified-Since` header, defined in
31    /// [RFC7232](http://tools.ietf.org/html/rfc7232#section-3.3)
32    ///
33    /// The `If-Modified-Since` header field makes a GET or HEAD request
34    /// method conditional on the selected representation's modification date
35    /// being more recent than the date provided in the field-value.
36    /// Transfer of the selected representation's data is avoided if that
37    /// data has not changed.
38    ///
39    /// # ABNF
40    ///
41    /// ```text
42    /// If-Unmodified-Since = HTTP-date
43    /// ```
44    ///
45    /// # Example values
46    /// * `Sat, 29 Oct 1994 19:43:31 GMT`
47    ///
48    (IfModifiedSince, "If-Modified-Since") => [HttpDate]
49
50}
51
52standard_header!(IfModifiedSince, IF_MODIFIED_SINCE);
53
54header! {
55    /// `Last-Modified` header, defined in
56    /// [RFC7232](http://tools.ietf.org/html/rfc7232#section-2.2)
57    ///
58    /// The `Last-Modified` header field in a response provides a timestamp
59    /// indicating the date and time at which the origin server believes the
60    /// selected representation was last modified, as determined at the
61    /// conclusion of handling the request.
62    ///
63    /// # ABNF
64    ///
65    /// ```text
66    /// Expires = HTTP-date
67    /// ```
68    ///
69    /// # Example values
70    ///
71    /// * `Sat, 29 Oct 1994 19:43:31 GMT`
72    ///
73    (LastModified, "Last-Modified") => [HttpDate]
74
75}
76
77standard_header!(LastModified, LAST_MODIFIED);
78
79header! {
80    /// `ETag` header, defined in [RFC7232](http://tools.ietf.org/html/rfc7232#section-2.3)
81    ///
82    /// The `ETag` header field in a response provides the current entity-tag
83    /// for the selected representation, as determined at the conclusion of
84    /// handling the request.  An entity-tag is an opaque validator for
85    /// differentiating between multiple representations of the same
86    /// resource, regardless of whether those multiple representations are
87    /// due to resource state changes over time, content negotiation
88    /// resulting in multiple representations being valid at the same time,
89    /// or both.  An entity-tag consists of an opaque quoted string, possibly
90    /// prefixed by a weakness indicator.
91    ///
92    /// # ABNF
93    ///
94    /// ```text
95    /// ETag       = entity-tag
96    /// ```
97    ///
98    /// # Example values
99    ///
100    /// * `"xyzzy"`
101    /// * `W/"xyzzy"`
102    /// * `""`
103    ///
104    (ETag, "ETag") => [EntityTag]
105}
106
107standard_header!(ETag, ETAG);
108
109header! {
110    /// `If-None-Match` header, defined in
111    /// [RFC7232](https://tools.ietf.org/html/rfc7232#section-3.2)
112    ///
113    /// The `If-None-Match` header field makes the request method conditional
114    /// on a recipient cache or origin server either not having any current
115    /// representation of the target resource, when the field-value is "*",
116    /// or having a selected representation with an entity-tag that does not
117    /// match any of those listed in the field-value.
118    ///
119    /// A recipient MUST use the weak comparison function when comparing
120    /// entity-tags for If-None-Match (Section 2.3.2), since weak entity-tags
121    /// can be used for cache validation even if there have been changes to
122    /// the representation data.
123    ///
124    /// # ABNF
125    ///
126    /// ```text
127    /// If-None-Match = "*" / 1#entity-tag
128    /// ```
129    ///
130    /// # Example values
131    ///
132    /// * `"xyzzy"`
133    /// * `W/"xyzzy"`
134    /// * `"xyzzy", "r2d2xxxx", "c3piozzzz"`
135    /// * `W/"xyzzy", W/"r2d2xxxx", W/"c3piozzzz"`
136    /// * `*`
137    ///
138    (IfNoneMatch, "If-None-Match") => {Any / (EntityTag)+}
139}
140
141standard_header!(IfNoneMatch, IF_NONE_MATCH);
142
143header! {
144    /// `If-Match` header, defined in
145    /// [RFC7232](https://tools.ietf.org/html/rfc7232#section-3.1)
146    ///
147    /// The `If-Match` header field makes the request method conditional on
148    /// the recipient origin server either having at least one current
149    /// representation of the target resource, when the field-value is "*",
150    /// or having a current representation of the target resource that has an
151    /// entity-tag matching a member of the list of entity-tags provided in
152    /// the field-value.
153    ///
154    /// An origin server MUST use the strong comparison function when
155    /// comparing entity-tags for `If-Match`, since the client
156    /// intends this precondition to prevent the method from being applied if
157    /// there have been any changes to the representation data.
158    ///
159    /// # ABNF
160    ///
161    /// ```text
162    /// If-Match = "*" / 1#entity-tag
163    /// ```
164    ///
165    /// # Example values
166    ///
167    /// * `"xyzzy"`
168    /// * "xyzzy", "r2d2xxxx", "c3piozzzz"
169    ///
170    (IfMatch, "If-Match") => {Any / (EntityTag)+}
171
172}
173
174standard_header!(IfMatch, IF_MATCH);