Skip to content

Commit 41c4724

Browse files
committed
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
1 parent 0a23420 commit 41c4724

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/client/mod.rs

+10
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use http::request;
2424
use method::Method;
2525
use self::pool::{Pool, Pooled};
2626
use uri::{self, Uri};
27+
use version::HttpVersion;
2728

2829
pub use http::response::Response;
2930
pub use http::request::Request;
@@ -139,6 +140,15 @@ where C: Connect,
139140
type Future = FutureResponse;
140141

141142
fn call(&self, req: Self::Request) -> Self::Future {
143+
match req.version() {
144+
HttpVersion::Http10 |
145+
HttpVersion::Http11 => (),
146+
other => {
147+
error!("Request has unsupported version \"{}\"", other);
148+
return FutureResponse(Box::new(future::err(::Error::Version)));
149+
}
150+
}
151+
142152
let url = req.uri().clone();
143153
let domain = match uri::scheme_and_authority(&url) {
144154
Some(uri) => uri,

0 commit comments

Comments
 (0)