From 41c47241cd81e5140a04a970adfcb1bffae29473 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Sat, 16 Sep 2017 17:20:31 -0700 Subject: [PATCH] fix(client): return Version errors if unsupported If a `Request`'s version is `Http09`, `H2`, or `H2c`, `client.request` will return a `hyper::Error::Version`, and a message is logged at `error!` level. Closes #1283 --- src/client/mod.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/client/mod.rs b/src/client/mod.rs index 8759478519..6f6e26805b 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -24,6 +24,7 @@ use http::request; use method::Method; use self::pool::{Pool, Pooled}; use uri::{self, Uri}; +use version::HttpVersion; pub use http::response::Response; pub use http::request::Request; @@ -139,6 +140,15 @@ where C: Connect, type Future = FutureResponse; fn call(&self, req: Self::Request) -> Self::Future { + match req.version() { + HttpVersion::Http10 | + HttpVersion::Http11 => (), + other => { + error!("Request has unsupported version \"{}\"", other); + return FutureResponse(Box::new(future::err(::Error::Version))); + } + } + let url = req.uri().clone(); let domain = match uri::scheme_and_authority(&url) { Some(uri) => uri,