From 526ce994a3218ab54962171a70caf979d4ebf56a Mon Sep 17 00:00:00 2001 From: Marko Lalic Date: Fri, 26 Jun 2015 14:37:11 +0200 Subject: [PATCH 1/2] refactor(http2): move to solicit v0.4 Only minor details in the internals of the `h2` module needed tweaking for migrating onto the latest version -- `HttpConnect` implementations are now required to return an error type that implements an `HttpConnectError` trait. --- Cargo.toml | 2 +- src/http/h2.rs | 29 +++++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3805b53d..834e3211 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,7 +33,7 @@ version = "0.6" optional = true [dependencies.solicit] -version = "0.3" +version = "0.4" default-features = false [dev-dependencies] diff --git a/src/http/h2.rs b/src/http/h2.rs index cb3a5fe8..7d6d9f68 100644 --- a/src/http/h2.rs +++ b/src/http/h2.rs @@ -24,7 +24,7 @@ use solicit::http::Header as Http2Header; use solicit::http::HttpScheme; use solicit::http::HttpError as Http2Error; use solicit::http::transport::TransportStream; -use solicit::http::client::{ClientStream, HttpConnect, write_preface}; +use solicit::http::client::{ClientStream, HttpConnect, HttpConnectError, write_preface}; use solicit::client::SimpleClient; use httparse; @@ -75,13 +75,38 @@ struct Http2Connector where S: CloneableStream { host: String, } +#[derive(Debug)] +struct Http2ConnectError(io::Error); + +impl ::std::fmt::Display for Http2ConnectError { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + write!(fmt, "HTTP/2 connect error: {}", (self as &::std::error::Error).description()) + } +} + +impl ::std::error::Error for Http2ConnectError { + fn description(&self) -> &str { + self.0.description() + } + + fn cause(&self) -> Option<&::std::error::Error> { + self.0.cause() + } +} + +impl HttpConnectError for Http2ConnectError {} + +impl From for Http2ConnectError { + fn from(e: io::Error) -> Http2ConnectError { Http2ConnectError(e) } +} + impl HttpConnect for Http2Connector where S: CloneableStream { /// The type of the underlying transport stream that the `HttpConnection`s /// produced by this `HttpConnect` implementation will be based on. type Stream = Http2Stream; /// The type of the error that can be produced by trying to establish the /// connection (i.e. calling the `connect` method). - type Err = ::Error; + type Err = Http2ConnectError; /// Establishes a network connection that can be used by HTTP/2 connections. fn connect(mut self) -> Result, Self::Err> { From 37e55944cf201ac52fa8c9d542af006bb5d8d4fa Mon Sep 17 00:00:00 2001 From: Marko Lalic Date: Fri, 26 Jun 2015 14:45:17 +0200 Subject: [PATCH 2/2] test(hyper): assert that `error::Error` is Send + Sync This is a regression test for #580. --- src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index abc60f7a..f9573dda 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -202,9 +202,11 @@ fn _assert_send() { _assert_send::(); _assert_send::>(); _assert_send::(); + _assert_send::(); } #[allow(unconditional_recursion)] fn _assert_sync() { _assert_sync::(); + _assert_sync::(); }