Skip to content

Commit c837995

Browse files
committed
feat(header): make HeaderValue::set_sensitive const
Some applications like OAuth clients for GitHub or Forgejo are forced to embed a client password into the application, even if the client is considered public. Make `HeaderValue::set_sensitive` available in const contexts to allow applications to mark embedded headers as sensitive. Warn developers in `set_sensitive`'s documentation that embedded secrets are trivial to dump and should not be considered secure. Closes: #807
1 parent bc71780 commit c837995

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/header/value.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,11 @@ impl HeaderValue {
298298

299299
/// Mark that the header value represents sensitive information.
300300
///
301+
/// This method is `const` to allow marking constants created with
302+
/// [`HeaderValue::from_static`] as sensitive. Note that sensitive values
303+
/// that are embedded into an application are trivial to dump and cannot be
304+
/// considered secure.
305+
///
301306
/// # Examples
302307
///
303308
/// ```
@@ -311,7 +316,7 @@ impl HeaderValue {
311316
/// assert!(!val.is_sensitive());
312317
/// ```
313318
#[inline]
314-
pub fn set_sensitive(&mut self, val: bool) {
319+
pub const fn set_sensitive(&mut self, val: bool) {
315320
self.is_sensitive = val;
316321
}
317322

0 commit comments

Comments
 (0)