Skip to content

Commit

Permalink
fix(client): return Version errors if unsupported
Browse files Browse the repository at this point in the history
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
  • Loading branch information
seanmonstar committed Sep 17, 2017
1 parent 0a23420 commit 41c4724
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 41c4724

Please sign in to comment.