@@ -123,7 +123,13 @@ impl CacheControl {
123
123
pub fn immutable ( & self ) -> bool {
124
124
self . flags . contains ( Flags :: IMMUTABLE )
125
125
}
126
- /// Check if the `must_understand` directive is set.
126
+
127
+ /// Check if the `must-revalidate` directive is set.
128
+ pub fn must_revalidate ( & self ) -> bool {
129
+ self . flags . contains ( Flags :: MUST_REVALIDATE )
130
+ }
131
+
132
+ /// Check if the `must-understand` directive is set.
127
133
pub fn must_understand ( & self ) -> bool {
128
134
self . flags . contains ( Flags :: MUST_UNDERSTAND )
129
135
}
@@ -192,11 +198,18 @@ impl CacheControl {
192
198
self
193
199
}
194
200
195
- /// Set the `must_understand` directive.
201
+ /// Set the `must-revalidate` directive.
202
+ pub fn with_must_revalidate ( mut self ) -> Self {
203
+ self . flags . insert ( Flags :: MUST_REVALIDATE ) ;
204
+ self
205
+ }
206
+
207
+ /// Set the `must-understand` directive.
196
208
pub fn with_must_understand ( mut self ) -> Self {
197
209
self . flags . insert ( Flags :: MUST_UNDERSTAND ) ;
198
210
self
199
211
}
212
+
200
213
/// Set the `max-age` directive.
201
214
pub fn with_max_age ( mut self , duration : Duration ) -> Self {
202
215
self . max_age = Some ( duration. into ( ) ) ;
@@ -490,6 +503,18 @@ mod tests {
490
503
assert ! ( cc. immutable( ) ) ;
491
504
}
492
505
506
+ #[ test]
507
+ fn test_must_revalidate ( ) {
508
+ let cc = CacheControl :: new ( ) . with_must_revalidate ( ) ;
509
+ let headers = test_encode ( cc. clone ( ) ) ;
510
+ assert_eq ! ( headers[ "cache-control" ] , "must-revalidate" ) ;
511
+ assert_eq ! (
512
+ test_decode:: <CacheControl >( & [ "must-revalidate" ] ) . unwrap( ) ,
513
+ cc
514
+ ) ;
515
+ assert ! ( cc. must_revalidate( ) ) ;
516
+ }
517
+
493
518
#[ test]
494
519
fn test_must_understand ( ) {
495
520
let cc = CacheControl :: new ( ) . with_must_understand ( ) ;
0 commit comments