Transform a [`ResponseCookie`] before it is sent to the client.
(&self, mut cookie: ResponseCookie<'c>)
| 76 | impl Processor { |
| 77 | /// Transform a [`ResponseCookie`] before it is sent to the client. |
| 78 | pub fn process_outgoing<'c>(&self, mut cookie: ResponseCookie<'c>) -> ResponseCookie<'c> { |
| 79 | if self.percent_encode { |
| 80 | let name = encode(&cookie.name).to_string(); |
| 81 | cookie.name = name.into(); |
| 82 | } |
| 83 | if let Some(rule) = self.rules.get(cookie.name.as_ref()) { |
| 84 | let value = rule.primary.process_outgoing(&cookie.name, &cookie.value); |
| 85 | cookie.value = value.into(); |
| 86 | } else { |
| 87 | // We don't need to percent-encode the value if we're encrypting or signing it. |
| 88 | // The signing/encryption process is guaranteed to return a value that is safe to use |
| 89 | // in a cookie. |
| 90 | if self.percent_encode { |
| 91 | let value = encode(&cookie.value).to_string(); |
| 92 | cookie.value = value.into(); |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | cookie |
| 97 | } |
| 98 | |
| 99 | /// Returns `true` if a cookie with the given name will be encrypted before |
| 100 | /// being sent back to the client in the response. |