Skip to content

Add the x-request-id header #411

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions benches/header_map/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -591,5 +591,6 @@ const STD: &'static [HeaderName] = &[
X_CONTENT_TYPE_OPTIONS,
X_DNS_PREFETCH_CONTROL,
X_FRAME_OPTIONS,
X_REQUEST_ID,
X_XSS_PROTECTION,
];
1 change: 1 addition & 0 deletions src/header/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ pub use self::name::{
X_CONTENT_TYPE_OPTIONS,
X_DNS_PREFETCH_CONTROL,
X_FRAME_OPTIONS,
X_REQUEST_ID,
X_XSS_PROTECTION,
};

Expand Down
6 changes: 6 additions & 0 deletions src/header/name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,9 @@ standard_headers! {
/// is using a browser supporting `x-frame-options`.
(XFrameOptions, X_FRAME_OPTIONS, "x-frame-options");

/// Correlates HTTP requests between a client and server.
(XRequestId, X_REQUEST_ID, "x-request-id");

/// Stop pages from loading when an XSS attack is detected.
///
/// The HTTP X-XSS-Protection response header is a feature of Internet
Expand Down Expand Up @@ -1269,6 +1272,8 @@ fn parse_hdr<'a>(
Ok(ContentType.into())
} else if eq!(b == b'm' b'a' b'x' b'-' b'f' b'o' b'r' b'w' b'a' b'r' b'd' b's') {
Ok(MaxForwards.into())
} else if eq!(b == b'x' b'-' b'r' b'e' b'q' b'u' b'e' b's' b't' b'-' b'i' b'd') {
Ok(XRequestId.into())
} else {
validate(b, len)
}
Expand Down Expand Up @@ -1591,6 +1596,7 @@ fn parse_hdr<'a>(
b"retry-after" => Ok(RetryAfter.into()),
b"content-type" => Ok(ContentType.into()),
b"max-forwards" => Ok(MaxForwards.into()),
b"x-request-id" => Ok(XRequestId.into()),
b"accept-ranges" => Ok(AcceptRanges.into()),
b"authorization" => Ok(Authorization.into()),
b"cache-control" => Ok(CacheControl.into()),
Expand Down
1 change: 1 addition & 0 deletions tests/header_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ const STD: &'static [HeaderName] = &[
X_CONTENT_TYPE_OPTIONS,
X_DNS_PREFETCH_CONTROL,
X_FRAME_OPTIONS,
X_REQUEST_ID,
X_XSS_PROTECTION,
];

Expand Down
1 change: 1 addition & 0 deletions tests/header_map_fuzz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ fn gen_header_name(g: &mut StdRng) -> HeaderName {
header::X_CONTENT_TYPE_OPTIONS,
header::X_DNS_PREFETCH_CONTROL,
header::X_FRAME_OPTIONS,
header::X_REQUEST_ID,
header::X_XSS_PROTECTION,
];

Expand Down
5 changes: 5 additions & 0 deletions util/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,11 @@ standard_headers! {
"#,
"x-frame-options";

r#"
/// Correlates HTTP requests between a client and server.
"#,
"x-request-id";

r#"
/// Stop pages from loading when an XSS attack is detected.
///
Expand Down