add some useful header name constants

This commit is contained in:
Rob Ede 2023-01-01 21:02:10 +00:00
parent 06c3513bc0
commit 149b862297
No known key found for this signature in database
GPG Key ID: 97C636207D3EF933
2 changed files with 26 additions and 0 deletions

View File

@ -4,12 +4,20 @@
### Added ### Added
- Implement `MessageBody` for `&mut B` where `B: MessageBody + Unpin`. [#2868] - Implement `MessageBody` for `&mut B` where `B: MessageBody + Unpin`. [#2868]
- Implement `MessageBody` for `Pin<B>` where `B::Target: MessageBody`. [#2868] - Implement `MessageBody` for `Pin<B>` where `B::Target: MessageBody`. [#2868]
- New header name constants in `header` module. [#????]
- `CROSS_ORIGIN_EMBEDDER_POLICY`
- `CROSS_ORIGIN_OPENER_POLICY`
- `PERMISSIONS_POLICY`
- `X_FORWARDED_FOR`
- `X_FORWARDED_HOST`
- `X_FORWARDED_PROTO`
### Performance ### Performance
- Improve overall performance of operations on `Extensions`. [#2890] - Improve overall performance of operations on `Extensions`. [#2890]
[#2868]: https://github.com/actix/actix-web/pull/2868 [#2868]: https://github.com/actix/actix-web/pull/2868
[#2890]: https://github.com/actix/actix-web/pull/2890 [#2890]: https://github.com/actix/actix-web/pull/2890
[#????]: https://github.com/actix/actix-web/pull/????
## 3.2.2 - 2022-09-11 ## 3.2.2 - 2022-09-11

View File

@ -1,5 +1,8 @@
//! Pre-defined `HeaderName`s, traits for parsing and conversion, and other header utility methods. //! Pre-defined `HeaderName`s, traits for parsing and conversion, and other header utility methods.
// declaring new header consts will yield this error
#![allow(clippy::declare_interior_mutable_const)]
use percent_encoding::{AsciiSet, CONTROLS}; use percent_encoding::{AsciiSet, CONTROLS};
// re-export from http except header map related items // re-export from http except header map related items
@ -27,6 +30,21 @@ pub use http::header::{
X_XSS_PROTECTION, X_XSS_PROTECTION,
}; };
// other common headers not defined in `http`
pub const CROSS_ORIGIN_EMBEDDER_POLICY: HeaderName =
HeaderName::from_static("cross-origin-embedder-policy");
pub const CROSS_ORIGIN_OPENER_POLICY: HeaderName =
HeaderName::from_static("cross-origin-opener-policy");
pub const PERMISSIONS_POLICY: HeaderName = HeaderName::from_static("permissions-policy");
pub const X_FORWARDED_FOR: HeaderName = HeaderName::from_static("x-forwarded-for");
pub const X_FORWARDED_HOST: HeaderName = HeaderName::from_static("x-forwarded-host");
pub const X_FORWARDED_PROTO: HeaderName = HeaderName::from_static("x-forwarded-proto");
// end other common headers
use crate::{error::ParseError, HttpMessage}; use crate::{error::ParseError, HttpMessage};
mod as_name; mod as_name;