Merge pull request #328 from erickt/hyper-014
Switch to hyper 0.14.x
diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml
index 776dad0..926204e 100644
--- a/.github/workflows/rust.yml
+++ b/.github/workflows/rust.yml
@@ -39,9 +39,16 @@
uses: actions-rs/cargo@v1
with:
command: test
+ args: ${{ matrix.features }}
+
+ - name: Run Tests with Hyper 0.13
+ uses: actions-rs/cargo@v1
+ with:
+ command: test
+ args: "--manifest-path tuf/Cargo.toml --no-default-features --features hyper_013/default"
- name: Generate Docs
uses: actions-rs/cargo@v1
with:
command: doc
- args: --all-features --no-deps
+ args: --no-deps
diff --git a/tuf/Cargo.toml b/tuf/Cargo.toml
index 8c98c4f..2313bbb 100644
--- a/tuf/Cargo.toml
+++ b/tuf/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "tuf"
edition = "2018"
-version = "0.3.0-beta2"
+version = "0.3.0-beta3"
authors = [ "heartsucker <heartsucker@autistici.org>", "Erick Tryzelaar <etryzelaar@google.com>" ]
description = "Library for The Update Framework (TUF)"
homepage = "https://github.com/heartsucker/rust-tuf"
@@ -23,7 +23,8 @@
futures-io = "0.3.1"
futures-util = { version = "0.3.1", features = [ "io" ] }
http = "0.2.0"
-hyper = { version = "0.13.2", default-features = false, features = [ "stream" ] }
+hyper_013 = { package = "hyper", version = "0.13.2", default-features = false, features = [ "stream" ], optional = true }
+hyper_014 = { package = "hyper", version = "0.14.15", default-features = false, features = [ "stream", "client", "http1" ], optional = true }
itoa = "0.4"
log = "0.4"
parking_lot = "0.11"
@@ -45,4 +46,4 @@
pretty_assertions = "1"
[features]
-default = ["hyper/default"]
+default = ["hyper_014/tcp"]
diff --git a/tuf/src/client.rs b/tuf/src/client.rs
index 07aea08..2198e64 100644
--- a/tuf/src/client.rs
+++ b/tuf/src/client.rs
@@ -4,6 +4,10 @@
//!
//! ```no_run
//! # use futures_executor::block_on;
+//! # #[cfg(feature = "hyper_013")]
+//! # use hyper_013 as hyper;
+//! # #[cfg(feature = "hyper_014")]
+//! # use hyper_014 as hyper;
//! # use hyper::client::Client as HttpClient;
//! # use std::path::PathBuf;
//! # use std::str::FromStr;
diff --git a/tuf/src/error.rs b/tuf/src/error.rs
index b9dea4e..6a74590 100644
--- a/tuf/src/error.rs
+++ b/tuf/src/error.rs
@@ -4,6 +4,10 @@
use std::io;
use std::path::Path;
use thiserror::Error;
+#[cfg(feature = "hyper_013")]
+use hyper_013 as hyper;
+#[cfg(feature = "hyper_014")]
+use hyper_014 as hyper;
use crate::metadata::Role;
@@ -42,6 +46,7 @@
},
/// Errors that can occur parsing HTTP streams.
+ #[cfg(any(feature = "hyper_013", feature = "hyper_014"))]
#[error("hyper: {0}")]
Hyper(#[from] hyper::Error),
diff --git a/tuf/src/repository.rs b/tuf/src/repository.rs
index fe1c3fc..ff1e325 100644
--- a/tuf/src/repository.rs
+++ b/tuf/src/repository.rs
@@ -17,7 +17,10 @@
mod file_system;
pub use self::file_system::{FileSystemRepository, FileSystemRepositoryBuilder};
+#[cfg(any(feature = "hyper_013", feature = "hyper_014"))]
mod http;
+
+#[cfg(any(feature = "hyper_013", feature = "hyper_014"))]
pub use self::http::{HttpRepository, HttpRepositoryBuilder};
mod ephemeral;
diff --git a/tuf/src/repository/http.rs b/tuf/src/repository/http.rs
index 93d70a4..d51ed87 100644
--- a/tuf/src/repository/http.rs
+++ b/tuf/src/repository/http.rs
@@ -4,6 +4,10 @@
use futures_util::future::{BoxFuture, FutureExt};
use futures_util::stream::TryStreamExt;
use http::{Response, StatusCode, Uri};
+#[cfg(feature = "hyper_013")]
+use hyper_013 as hyper;
+#[cfg(feature = "hyper_014")]
+use hyper_014 as hyper;
use hyper::body::Body;
use hyper::client::connect::Connect;
use hyper::Client;