@@ -74,16 +74,6 @@ impl Vary {
7474 Ok ( Some ( Self { entries, wildcard } ) )
7575 }
7676
77- /// Sets the `If-Match` header.
78- pub fn apply ( & self , mut headers : impl AsMut < Headers > ) {
79- headers. as_mut ( ) . insert ( VARY , self . header_value ( ) ) ;
80- }
81-
82- /// Get the `HeaderName`.
83- pub fn name ( & self ) -> HeaderName {
84- VARY
85- }
86-
8777 /// Returns `true` if a wildcard directive was set.
8878 pub fn wildcard ( & self ) -> bool {
8979 self . wildcard
@@ -94,31 +84,6 @@ impl Vary {
9484 self . wildcard = wildcard
9585 }
9686
97- /// Get the `HeaderValue`.
98- pub fn value ( & self ) -> HeaderValue {
99- let mut output = String :: new ( ) ;
100- for ( n, name) in self . entries . iter ( ) . enumerate ( ) {
101- let directive: HeaderValue = name
102- . as_str ( )
103- . parse ( )
104- . expect ( "Could not convert a HeaderName into a HeaderValue" ) ;
105- match n {
106- 0 => write ! ( output, "{}" , directive) . unwrap ( ) ,
107- _ => write ! ( output, ", {}" , directive) . unwrap ( ) ,
108- } ;
109- }
110-
111- if self . wildcard {
112- match output. len ( ) {
113- 0 => write ! ( output, "*" ) . unwrap ( ) ,
114- _ => write ! ( output, ", *" ) . unwrap ( ) ,
115- } ;
116- }
117-
118- // SAFETY: the internal string is validated to be ASCII.
119- unsafe { HeaderValue :: from_bytes_unchecked ( output. into ( ) ) }
120- }
121-
12287 /// Push a directive into the list of entries.
12388 pub fn push ( & mut self , directive : impl Into < HeaderName > ) -> crate :: Result < ( ) > {
12489 self . entries . push ( directive. into ( ) ) ;
@@ -144,8 +109,29 @@ impl Header for Vary {
144109 fn header_name ( & self ) -> HeaderName {
145110 VARY
146111 }
112+
147113 fn header_value ( & self ) -> HeaderValue {
148- self . header_value ( )
114+ let mut output = String :: new ( ) ;
115+ for ( n, name) in self . entries . iter ( ) . enumerate ( ) {
116+ let directive: HeaderValue = name
117+ . as_str ( )
118+ . parse ( )
119+ . expect ( "Could not convert a HeaderName into a HeaderValue" ) ;
120+ match n {
121+ 0 => write ! ( output, "{}" , directive) . unwrap ( ) ,
122+ _ => write ! ( output, ", {}" , directive) . unwrap ( ) ,
123+ } ;
124+ }
125+
126+ if self . wildcard {
127+ match output. len ( ) {
128+ 0 => write ! ( output, "*" ) . unwrap ( ) ,
129+ _ => write ! ( output, ", *" ) . unwrap ( ) ,
130+ } ;
131+ }
132+
133+ // SAFETY: the internal string is validated to be ASCII.
134+ unsafe { HeaderValue :: from_bytes_unchecked ( output. into ( ) ) }
149135 }
150136}
151137
0 commit comments