File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change
1
+ /// An HTTP `Cache-Control` directive.
2
+ #[ derive( Debug ) ]
3
+ pub enum CacheDirective {
4
+ Immutable ,
5
+ MaxAge ( Duration ) ,
6
+ MaxStale ( Option < Duration > ) ,
7
+ MinFresh ( Duration ) ,
8
+ MustRevalidate ,
9
+ NoCache ,
10
+ NoStore ,
11
+ NoTransform ,
12
+ OnlyIfCached ,
13
+ Private ,
14
+ ProxyRevalidate ,
15
+ Public ,
16
+ SMaxAge ( Duration ) ,
17
+ StaleIfError ( Duration ) ,
18
+ StaleWhileRevalidate ( Duration ) ,
19
+ }
20
+
21
+ impl CacheDirective {
22
+ /// Check whether this directive is valid in an HTTP request.
23
+ pub fn is_req ( & self ) -> bool {
24
+ use Self :: * ;
25
+ match self {
26
+ MaxAge ( _) | MaxStale ( _) | MinFresh ( _) | NoCache | NoStore | NoTransform
27
+ | OnlyIfCached => true ,
28
+ _ => false ,
29
+ }
30
+ }
31
+
32
+ /// Check whether this directive is valid in an HTTP response.
33
+ pub fn is_res ( & self ) -> bool {
34
+ use Self :: * ;
35
+ match self {
36
+ MustRevalidate | NoCache | NoStore | NoTransform | Public | Private
37
+ | ProxyRevalidate | MaxAge ( _) | SMaxAge ( _) => true ,
38
+ _ => false ,
39
+ }
40
+ }
41
+ }
Original file line number Diff line number Diff line change
1
+ mod cache_control;
You can’t perform that action at this time.
0 commit comments