I want to retreive the HTTP version information, so that I can use it programmatically for tracing information (OpenTelemetry).
Due to the unexpected None I have to assume 1.1, but I wish that tide could return the current and correct version information, so that in a potential future with multiple version support the data is present and reliable.
I tried to go down the rabbit hole but got lost, so I hope the community and maintainers have more luck.
cargo run --release
Finished release [optimized] target(s) in 1.73s
Running `target/release/tidetest`
{"level":30,"time":1596213036227,"msg":"Logger started","level":Info}
{"level":30,"time":1596213036227,"msg":"Server listening on http://127.0.0.1:8080"}
{"level":30,"time":1596213058722,"msg":"<-- Request received","method":GET,"path":/}
thread 'main' panicked at 'assertion failed: `(left == right)`
left: `None`,
right: `Some(Http1_1)`', src/main.rs:8:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
triggered via calling the server:
curl http://localhost:8080/ -i
curl: (52) Empty reply from server
Replicating the code snippet from the documentation:
use tide::Request;
#[async_std::main]
async fn main() -> Result<(), std::io::Error> {
tide::log::start();
let mut app = tide::new();
app.at("/").get(|req: Request<()>| async move {
assert_eq!(req.version(), Some(http_types::Version::Http1_1));
Ok("")
});
app.listen("127.0.0.1:8080").await?;
Ok(())
}
# ...
[dependencies]
async-std = {version = "1.6", features = ["attributes"]}
femme = "2.1"
tide = "0.12"
http-types = "2.2.1" # using the exact version of tide 0.12, but also fails with latest
req.version() shall return Some(http_types::Version::Http1_1) as the documentation suggests and users would expect.
_No idea._ 🤷🏻♂️
Published async-h1 v2.1.2 which includes @jbr's fix. Running cargo update on your repo should fix this issue!
[patch.crates-io]
async-h1 = { git = "https://github.com/http-rs/async-h1" }
This works.
Crate version doesn't seem to be published to crates.io yet. Can you publish it there as well? Thank you! 🙇🏻♂️
Also thank you for the very quick fix and turnaround. You're all awesome! 💙
@asaaki oops; you're right. It should work now!
Can confirm, all good now! ✨