Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- nightly
# When updating this value, don't forget to also adjust the
# `rust-version` field in the `Cargo.toml` file.
- 1.46.0
- 1.49.0
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems kinda strange that the MSRV was bumped without any notice in the PR description or in the release notes, no? Makes it somewhat hard to handle updates in downstream projects.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This project follows the msrv of tokio https://github.com/tokio-rs/tokio/#supported-rust-versions but we should add it to the changelog. Good catch.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't seem like it? tokio supports previous versions with point releases, allowing users with an older rustc to keep using tokio with bugfixes provided even if they have to ignore new versions. It looks like this crate is updated in point releases to have a new MSRV. In this case I wasn't able to use a down-down-downstream crate because it no longer built using system rustc on popular distros.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is mainly due to a few reasons, tokio is already 1.0 and thus at the time of 1.0 we try to support everyone. While this crate is below 1.0 so the guarantees are different. I assume it should be possible to pin the version of http though for your crate?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, understood, and I can pin for now, I was just noting that you said "this project follow the msrv of tokio" which isn't really accurate, given tokio has great support for broadly-available/deployed versions of rustc but I don't believe such support exists here (ie you miss bugfixes if you don't use rustup).


include:
- rust: nightly
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ keywords = ["http"]
categories = ["web-programming"]
edition = "2018"
# When updating this value, don't forget to also adjust the GitHub Actions config.
rust-version = "1.46.0"
rust-version = "1.49.0"

[dependencies]
bytes = "1"
Expand Down
139 changes: 139 additions & 0 deletions benches/header_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,128 @@ fn make_all_known_headers() -> Vec<Vec<u8>> {
]
}

static ALL_KNOWN_HEADERS: &[&str] = &[
// Standard request headers
"a-im",
"accept",
"accept-charset",
"accept-datetime",
"accept-encoding",
"accept-language",
"access-control-request-method",
"authorization",
"cache-control",
"connection",
"permanent",
"content-length",
"content-md5",
"content-type",
"cookie",
"date",
"expect",
"forwarded",
"from",
"host",
"permanent",
"http2-settings",
"if-match",
"if-modified-since",
"if-none-match",
"if-range",
"if-unmodified-since",
"max-forwards",
"origin",
"pragma",
"proxy-authorization",
"range",
"referer",
"te",
"user-agent",
"upgrade",
"via",
"warning",
// common_non_standard
"upgrade-insecure-requests",
"upgrade-insecure-requests",
"x-requested-with",
"dnt",
"x-forwarded-for",
"x-forwarded-host",
"x-forwarded-proto",
"front-end-https",
"x-http-method-override",
"x-att-deviceid",
"x-wap-profile",
"proxy-connection",
"x-uidh",
"x-csrf-token",
"x-request-id",
"x-correlation-id",
"save-data",
// standard_response_headers
"accept-patch",
"accept-ranges",
"access-control-allow-credentials",
"access-control-allow-headers",
"access-control-allow-methods",
"access-control-allow-origin",
"access-control-expose-headers",
"access-control-max-age",
"age",
"allow",
"alt-svc",
"cache-control",
"connection",
"content-disposition",
"content-encoding",
"content-language",
"content-length",
"content-location",
"content-md5",
"content-range",
"content-type",
"date",
"delta-base",
"etag",
"expires",
"im",
"last-modified",
"link",
"location",
"p3p",
"permanent",
"pragma",
"proxy-authenticate",
"public-key-pins",
"retry-after",
"server",
"set-cookie",
"strict-transport-security",
"tk",
"trailer",
"transfer-encoding",
"upgrade",
"vary",
"via",
"warning",
"www-authenticate",
"x-frame-options",
// common_non_standard_response
"content-security-policy",
"refresh",
"status",
"timing-allow-origin",
"x-content-duration",
"x-content-security-policy",
"x-content-type-options",
"x-correlation-id",
"x-powered-by",
"x-request-id",
"x-ua-compatible",
"x-webkit-csp",
"x-xss-protection",
];

#[bench]
fn header_name_easy(b: &mut Bencher) {
let name = b"Content-type";
Expand All @@ -138,6 +260,14 @@ fn header_name_easy(b: &mut Bencher) {
});
}

#[bench]
fn header_name_custom(b: &mut Bencher) {
let name = b"Foo-Bar-Baz-Blah";
b.iter(|| {
HeaderName::from_bytes(&name[..]).unwrap();
});
}

#[bench]
fn header_name_bad(b: &mut Bencher) {
let name = b"bad header name";
Expand All @@ -155,3 +285,12 @@ fn header_name_various(b: &mut Bencher) {
}
});
}

#[bench]
fn header_name_from_static(b: &mut Bencher) {
b.iter(|| {
for name in ALL_KNOWN_HEADERS {
HeaderName::from_static(name);
}
});
}
2 changes: 1 addition & 1 deletion src/byte_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl ByteStr {
}

#[inline]
pub fn from_static(val: &'static str) -> ByteStr {
pub const fn from_static(val: &'static str) -> ByteStr {
ByteStr {
// Invariant: val is a str so contains vaid UTF-8.
bytes: Bytes::from_static(val.as_bytes()),
Expand Down
Loading