From d65ed68180a4a7dd9425cb53caeb5f738606122b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Nov 2023 17:46:29 +0000 Subject: [PATCH 1/3] Update hyper requirement from 0.14 to 1.0 Updates the requirements on [hyper](https://github.com/hyperium/hyper) to permit the latest version. - [Release notes](https://github.com/hyperium/hyper/releases) - [Changelog](https://github.com/hyperium/hyper/blob/master/CHANGELOG.md) - [Commits](https://github.com/hyperium/hyper/commits/v1.0.1) --- updated-dependencies: - dependency-name: hyper dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- juniper_axum/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/juniper_axum/Cargo.toml b/juniper_axum/Cargo.toml index b7cd896e6..2662e983d 100644 --- a/juniper_axum/Cargo.toml +++ b/juniper_axum/Cargo.toml @@ -39,7 +39,7 @@ bytes = "1.2" [dev-dependencies] anyhow = "1.0" axum = { version = "0.6", features = ["macros"] } -hyper = "0.14" +hyper = "1.0" juniper = { version = "0.16.0-dev", path = "../juniper", features = ["expose-test-schema"] } tokio = { version = "1.20", features = ["macros", "rt-multi-thread", "time"] } tokio-stream = "0.1" From 06d44087a8e6350219f8a67f1a3173618d396c9a Mon Sep 17 00:00:00 2001 From: tyranron Date: Thu, 23 Nov 2023 18:03:44 +0100 Subject: [PATCH 2/3] Get rid of `hyper` in `juniper_axum` dev deps --- juniper_axum/Cargo.toml | 2 +- juniper_axum/tests/http_test_suite.rs | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/juniper_axum/Cargo.toml b/juniper_axum/Cargo.toml index 2662e983d..970708f1c 100644 --- a/juniper_axum/Cargo.toml +++ b/juniper_axum/Cargo.toml @@ -39,11 +39,11 @@ bytes = "1.2" [dev-dependencies] anyhow = "1.0" axum = { version = "0.6", features = ["macros"] } -hyper = "1.0" juniper = { version = "0.16.0-dev", path = "../juniper", features = ["expose-test-schema"] } tokio = { version = "1.20", features = ["macros", "rt-multi-thread", "time"] } tokio-stream = "0.1" tokio-tungstenite = "0.20" +tower-service = "0.3" tracing = "0.1" tracing-subscriber = "0.3" urlencoding = "2.1" diff --git a/juniper_axum/tests/http_test_suite.rs b/juniper_axum/tests/http_test_suite.rs index 2a93405c5..06571bcb1 100644 --- a/juniper_axum/tests/http_test_suite.rs +++ b/juniper_axum/tests/http_test_suite.rs @@ -1,18 +1,19 @@ use std::sync::Arc; use axum::{ + body::{Body, HttpBody as _}, http::Request, response::Response, routing::{get, post}, Extension, Router, }; -use hyper::{service::Service, Body}; use juniper::{ http::tests::{run_http_test_suite, HttpIntegration, TestResponse}, tests::fixtures::starwars::schema::{Database, Query}, EmptyMutation, EmptySubscription, RootNode, }; use juniper_axum::{extract::JuniperRequest, response::JuniperResponse}; +use tower_service::Service as _; type Schema = RootNode<'static, Query, EmptyMutation, EmptySubscription>; @@ -89,15 +90,19 @@ async fn into_test_response(resp: Response) -> TestResponse { .headers() .get("content-type") .map(|header| { - String::from_utf8(header.as_bytes().into()) + header + .to_str() .unwrap_or_else(|e| panic!("not UTF-8 header: {e}")) + .to_owned() }) .unwrap_or_default(); - let body = hyper::body::to_bytes(resp.into_body()) - .await - .unwrap_or_else(|e| panic!("failed to represent `Body` as `Bytes`: {e}")); - let body = String::from_utf8(body.into()).unwrap_or_else(|e| panic!("not UTF-8 body: {e}")); + let mut body = resp.into_body(); + let mut body_bytes = vec![]; + while let Some(bytes) = body.data().await { + body_bytes.extend(bytes.unwrap()); + } + let body = String::from_utf8(body_bytes).unwrap_or_else(|e| panic!("not UTF-8 body: {e}")); TestResponse { status_code, From 4cdebb86b8bc5cfe85c7aeb779c246fcdedc24d6 Mon Sep 17 00:00:00 2001 From: tyranron Date: Thu, 23 Nov 2023 18:17:05 +0100 Subject: [PATCH 3/3] Fix --- juniper_axum/src/extract.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/juniper_axum/src/extract.rs b/juniper_axum/src/extract.rs index ef42f3841..2ce807c8d 100644 --- a/juniper_axum/src/extract.rs +++ b/juniper_axum/src/extract.rs @@ -280,14 +280,17 @@ mod juniper_request_tests { } /// Converts the provided [`HttpBody`] into a [`String`]. - async fn display_body(body: B) -> String + async fn display_body(mut body: B) -> String where - B: HttpBody, + B: HttpBody + Unpin, B::Error: fmt::Display, { - let bytes = hyper::body::to_bytes(body) - .await - .unwrap_or_else(|e| panic!("failed to represent `Body` as `Bytes`: {e}")); - String::from_utf8(bytes.into()).unwrap_or_else(|e| panic!("not UTF-8 body: {e}")) + let mut body_bytes = vec![]; + while let Some(bytes) = body.data().await { + body_bytes.extend( + bytes.unwrap_or_else(|e| panic!("failed to represent `Body` as `Bytes`: {e}")), + ); + } + String::from_utf8(body_bytes).unwrap_or_else(|e| panic!("not UTF-8 body: {e}")) } }