diff --git a/CHANGELOG.md b/CHANGELOG.md index 6cd704d5e..3ade58ab9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Fixed +## [7.0.0-rc.2] - 2025-06-10 +### Changed +- Replace `mime_multipart` with fork for hyper 1.x + ## [7.0.0-rc1] - 2024-05-09 ### Changed - Remove dependency and re-export of `hyper-old-types` which is no longer maintained. @@ -225,7 +229,8 @@ No changes. We now think we've got enough to declare this crate stable. ## [0.5.0] - 2017-09-18 - Start of changelog. -[Unreleased]: https://github.com/Metaswitch/swagger-rs/compare/7.0.0-rc1...HEAD +[Unreleased]: https://github.com/Metaswitch/swagger-rs/compare/7.0.0-rc2...HEAD +[7.0.0-rc2]: https://github.com/Metaswitch/swagger-rs/compare/7.0.0-rc1...7.0.0-rc2 [7.0.0-rc1]: https://github.com/Metaswitch/swagger-rs/compare/6.5.0...7.0.0-rc1 [6.5.0]: https://github.com/Metaswitch/swagger-rs/compare/6.4.1...6.5.0 [6.4.1]: https://github.com/Metaswitch/swagger-rs/compare/6.4.0...6.4.1 diff --git a/Cargo.toml b/Cargo.toml index 017ac30e5..ccc036c56 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "swagger" -version = "7.0.0-rc1" +version = "7.0.0-rc2" authors = ["Metaswitch Networks Ltd"] license = "Apache-2.0" description = "A set of common utilities for Rust code generated by OpenAPI Generator" @@ -13,7 +13,7 @@ edition = "2021" [features] default = ["serdejson"] multipart_form = ["mime"] -multipart_related = ["mime_multipart"] +multipart_related = ["mime_multipart", "mime"] serdejson = ["serde", "serde_json"] serdevalid = ["serdejson", "serde_valid", "regex", "paste"] server = ["hyper/server"] @@ -32,6 +32,11 @@ conversion = [ [dependencies] base64 = "0.22" +futures = "0.3" +headers = "0.4.0" +http = "1" +bytes = "1.8.0" +hyper = "1" # Conversion frunk = { version = "0.4", optional = true } @@ -39,9 +44,6 @@ frunk-enum-core = { version = "0.3", optional = true } frunk-enum-derive = { version = "0.3", optional = true } frunk_core = { version = "0.4", optional = true } frunk_derives = { version = "0.4", optional = true } -futures = "0.3" -headers = "0.4.0" -hyper = { version = "1" } # Client hyper-util = { version = "0.1.8", features = [ @@ -53,7 +55,9 @@ hyper-util = { version = "0.1.8", features = [ mime = { version = "0.3", optional = true } # multipart/related -mime_multipart = { version = "0.6", optional = true } +mime_multipart = { version = "0.10", package = "mime-multipart-hyper1", optional = true } + +# serde paste = { version = "1", optional = true } regex = { version = "1", optional = true } serde = { version = "1.0.119", optional = true, features = ["derive"] } @@ -77,13 +81,10 @@ hyper-tls = { version = "0.6", optional = true } native-tls = { version = "0.2", optional = true } [dev-dependencies] -bytes = "1.8.0" -http-body-util = "0.1.2" hyper-util = { version = "0.1.8", features = ["full"] } -hyper_10 = { package = "hyper", version = "0.10" } -mime_026 = { package = "mime", version = "0.2.6" } tokio = { version = "1.0", features = ["macros", "rt"] } tokio-test = "0.4.4" +http-body-util = "0.1.2" [package.metadata.docs.rs] # Enable all features, pending https://github.com/rust-lang/rust/issues/43781 being resolved. diff --git a/src/add_context.rs b/src/add_context.rs index b2ee50044..b6bc73b98 100644 --- a/src/add_context.rs +++ b/src/add_context.rs @@ -3,11 +3,11 @@ use crate::{Push, XSpanIdString}; use futures::FutureExt; -use hyper::Request; +use http::Request; use std::marker::PhantomData; /// Middleware wrapper service, that should be used as the outermost layer in a -/// stack of hyper services. Adds a context to a plain `hyper::Request` that can be +/// stack of hyper services. Adds a context to a plain `http::Request` that can be /// used by subsequent layers in the stack. #[derive(Debug)] pub struct AddContextMakeService @@ -55,7 +55,7 @@ where } /// Middleware wrapper service, that should be used as the outermost layer in a -/// stack of hyper services. Adds a context to a plain `hyper::Request` that can be +/// stack of hyper services. Adds a context to a plain `http::Request` that can be /// used by subsequent layers in the stack. The `AddContextService` struct should /// not usually be used directly - when constructing a hyper stack use /// `AddContextMakeService`, which will create `AddContextService` instances as needed. diff --git a/src/auth.rs b/src/auth.rs index 7899600ed..4b0ad2b1b 100644 --- a/src/auth.rs +++ b/src/auth.rs @@ -4,9 +4,9 @@ use crate::context::Push; use futures::future::FutureExt; use headers::authorization::{Basic, Bearer, Credentials}; use headers::Authorization as Header; -use hyper::header::AUTHORIZATION; +use http::header::AUTHORIZATION; +use http::{HeaderMap, Request}; use hyper::service::Service; -use hyper::{HeaderMap, Request}; use std::collections::BTreeSet; use std::marker::PhantomData; use std::string::ToString; @@ -248,10 +248,10 @@ mod tests { use super::*; use crate::context::{ContextBuilder, Has}; use crate::EmptyContext; + use bytes::Bytes; + use http::Response; use http_body_util::Full; - use hyper::body::Bytes; use hyper::service::Service; - use hyper::Response; struct MakeTestService; diff --git a/src/body.rs b/src/body.rs index 73fdb5c37..7ea3511d0 100644 --- a/src/body.rs +++ b/src/body.rs @@ -1,8 +1,8 @@ -/// Helper methods to act on hyper::Body +/// Helper methods for processing body +use bytes::Bytes; use futures::stream::{Stream, StreamExt}; -use hyper::body::Bytes; -/// Additional function for hyper::Body +/// Additional function for converting body stream into Vec pub trait BodyExt { /// Raw body type type Raw; diff --git a/src/composites.rs b/src/composites.rs index cea3bc2b2..101311c43 100644 --- a/src/composites.rs +++ b/src/composites.rs @@ -3,8 +3,8 @@ //! Use by passing `hyper::server::MakeService` instances to a `CompositeMakeService` //! together with the base path for requests that should be handled by that service. use futures::future::{BoxFuture, FutureExt, TryFutureExt}; +use http::{Request, Response, StatusCode}; use hyper::service::Service; -use hyper::{Request, Response, StatusCode}; use std::fmt; use std::future::Future; use std::net::SocketAddr; diff --git a/src/context.rs b/src/context.rs index 7355106b5..1cfd99445 100644 --- a/src/context.rs +++ b/src/context.rs @@ -19,7 +19,7 @@ use crate::XSpanIdString; /// # use std::marker::PhantomData; /// # use std::pin::Pin; /// # use swagger::context::*; -/// # use hyper::body::Bytes; +/// # use bytes::Bytes; /// # use http_body_util::Empty; /// # /// # struct MyItem; @@ -29,17 +29,17 @@ use crate::XSpanIdString; /// marker: PhantomData, /// } /// -/// impl hyper::service::Service<(hyper::Request, C)> for MyService +/// impl hyper::service::Service<(http::Request, C)> for MyService /// where C: Has + Send + 'static /// { -/// type Response = hyper::Response>; +/// type Response = http::Response>; /// type Error = std::io::Error; /// type Future = Pin>>>; /// -/// fn call(&self, req : (hyper::Request, C)) -> Self::Future { +/// fn call(&self, req : (http::Request, C)) -> Self::Future { /// let (_, context) = req; /// do_something_with_my_item(Has::::get(&context)); -/// Box::pin(ok(hyper::Response::new(Empty::::new()))) +/// Box::pin(ok(http::Response::new(Empty::::new()))) /// } /// } /// ``` @@ -70,19 +70,19 @@ pub trait Has { /// marker: PhantomData, /// } /// -/// impl hyper::service::Service<(hyper::Request, C)> for MiddlewareService +/// impl hyper::service::Service<(http::Request, C)> for MiddlewareService /// where /// C: Pop + Send + 'static, /// D: Pop, /// E: Pop, /// E::Result: Send + 'static, -/// T: hyper::service::Service<(hyper::Request, E::Result)> +/// T: hyper::service::Service<(http::Request, E::Result)> /// { /// type Response = T::Response; /// type Error = T::Error; /// type Future = T::Future; /// -/// fn call(&self, req : (hyper::Request, C)) -> Self::Future { +/// fn call(&self, req : (http::Request, C)) -> Self::Future { /// let (request, context) = req; /// /// // type annotations optional, included for illustrative purposes @@ -118,19 +118,19 @@ pub trait Pop { /// marker: PhantomData, /// } /// -/// impl hyper::service::Service<(hyper::Request, C)> for MiddlewareService +/// impl hyper::service::Service<(http::Request, C)> for MiddlewareService /// where /// C: Push + Send + 'static, /// D: Push, /// E: Push, /// E::Result: Send + 'static, -/// T: hyper::service::Service<(hyper::Request, E::Result)> +/// T: hyper::service::Service<(http::Request, E::Result)> /// { /// type Response = T::Response; /// type Error = T::Error; /// type Future = T::Future; /// -/// fn call(&self, req : (hyper::Request, C)) -> Self::Future { +/// fn call(&self, req : (http::Request, C)) -> Self::Future { /// let (request, context) = req; /// let context = context /// .push(MyItem1{}) diff --git a/src/drop_context.rs b/src/drop_context.rs index 94adb4f88..c05d2f40b 100644 --- a/src/drop_context.rs +++ b/src/drop_context.rs @@ -1,23 +1,23 @@ //! Hyper service that drops a context to an incoming request and passes it on //! to a wrapped service. -use hyper::Request; +use http::Request; use std::marker::PhantomData; use futures::future::FutureExt as _; /// Middleware wrapper service that drops the context from the incoming request -/// and passes the plain `hyper::Request` to the wrapped service. +/// and passes the plain `http::Request` to the wrapped service. /// -/// This service can be used to to include services that take a plain `hyper::Request` +/// This service can be used to to include services that take a plain `http::Request` /// in a `CompositeService` wrapped in an `AddContextService`. /// /// Example Usage /// ============= /// /// In the following example `SwaggerService` implements `hyper::service::MakeService` -/// with `Request = (hyper::Request, SomeContext)`, and `PlainService` implements it -/// with `Request = hyper::Request` +/// with `Request = (http::Request, SomeContext)`, and `PlainService` implements it +/// with `Request = http::Request` /// /// ```ignore /// let swagger_service_one = SwaggerService::new(); @@ -85,10 +85,10 @@ where /// # use hyper_util::rt::TokioExecutor; /// # use hyper_util::service::TowerToHyperService; /// # use http_body_util::Empty; -/// # use hyper::body::Bytes; +/// # use bytes::Bytes; /// let client = Client::builder(TokioExecutor::new()).build_http(); /// let client = DropContextService::new(TowerToHyperService::new(client)); -/// let request = (hyper::Request::get("http://www.google.com").body(Empty::::new()).unwrap()); +/// let request = (http::Request::get("http://www.google.com").body(Empty::::new()).unwrap()); /// let context = "Some Context".to_string(); /// /// let response = client.call((request, context)); diff --git a/src/header.rs b/src/header.rs index 89a6ceb28..a935dde1c 100644 --- a/src/header.rs +++ b/src/header.rs @@ -11,7 +11,7 @@ pub struct XSpanIdString(pub String); impl XSpanIdString { /// Extract an X-Span-ID from a request header if present, and if not /// generate a new one. - pub fn get_or_generate(req: &hyper::Request) -> Self { + pub fn get_or_generate(req: &http::Request) -> Self { let x_span_id = req.headers().get(X_SPAN_ID); x_span_id diff --git a/src/multipart/form.rs b/src/multipart/form.rs index 5b239fc08..cd62b8c78 100644 --- a/src/multipart/form.rs +++ b/src/multipart/form.rs @@ -1,5 +1,5 @@ //! Helper functions for multipart/form-data support -use hyper::header::{HeaderMap, CONTENT_TYPE}; +use http::header::{HeaderMap, CONTENT_TYPE}; /// Utility function to get the multipart boundary marker (if any) from the Headers. pub fn boundary(headers: &HeaderMap) -> Option { diff --git a/src/multipart/related.rs b/src/multipart/related.rs index afe62dcd7..746948c0d 100644 --- a/src/multipart/related.rs +++ b/src/multipart/related.rs @@ -1,7 +1,7 @@ //! Helper functions for multipart/related support -use hyper::header::{HeaderValue, CONTENT_TYPE}; -use hyper::HeaderMap; +use http::header::{HeaderValue, CONTENT_TYPE}; +use http::HeaderMap; use mime::Mime; /// Construct the Body for a multipart/related request. The mime 0.2.6 library @@ -42,7 +42,6 @@ pub fn create_multipart_headers(content_type: Option<&HeaderValue>) -> Result { - let res: mime_026::Mime = h.content_type().unwrap(); - let mime: mime_026::Mime = "text/plain".parse().unwrap(); - assert_eq!(res, mime); + assert_eq!( + h.headers.get(CONTENT_TYPE).unwrap(), + &HeaderValue::from_static("text/plain") + ); } _ => panic!("Expected Node::Multipart"), } diff --git a/src/request_parser.rs b/src/request_parser.rs index e851ad800..aa50e1860 100644 --- a/src/request_parser.rs +++ b/src/request_parser.rs @@ -1,5 +1,5 @@ //! Methods for retrieving swagger-related information from an HTTP request. -use hyper::Request; +use http::Request; /// A macro for joining together two or more RequestParsers to create a struct that implements /// RequestParser with a function parse_operation_id that matches hyper requests against the different @@ -53,9 +53,9 @@ pub trait RequestParser { #[cfg(test)] mod context_tests { use super::*; + use bytes::Bytes; + use http::Uri; use http_body_util::Full; - use hyper::body::Bytes; - use hyper::Uri; use std::str::FromStr; struct TestParser1;