From 892d9ae2cc13965aaf190c52fd81d99b88b3311d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 21 Nov 2023 19:13:54 +0000 Subject: [PATCH 1/3] Bump hyper from 0.14.27 to 1.0.1 Bumps [hyper](https://github.com/hyperium/hyper) from 0.14.27 to 1.0.1. - [Release notes](https://github.com/hyperium/hyper/releases) - [Changelog](https://github.com/hyperium/hyper/blob/master/CHANGELOG.md) - [Commits](https://github.com/hyperium/hyper/compare/v0.14.27...v1.0.1) --- updated-dependencies: - dependency-name: hyper dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- Cargo.lock | 71 +++++++++++++++++++++++++++++++++++++++++------------- Cargo.toml | 2 +- 2 files changed, 55 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b33b3cc..2b34a99 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -81,9 +81,9 @@ dependencies = [ "bitflags 1.3.2", "bytes", "futures-util", - "http", - "http-body", - "hyper", + "http 0.2.9", + "http-body 0.4.5", + "hyper 0.14.27", "itoa", "matchit", "memchr", @@ -111,8 +111,8 @@ dependencies = [ "async-trait", "bytes", "futures-util", - "http", - "http-body", + "http 0.2.9", + "http-body 0.4.5", "mime", "rustversion", "tower-layer", @@ -404,6 +404,17 @@ dependencies = [ "itoa", ] +[[package]] +name = "http" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b32afd38673a8016f7c9ae69e5af41a58f81b1d31689040f2f1959594ce194ea" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + [[package]] name = "http-body" version = "0.4.5" @@ -411,10 +422,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" dependencies = [ "bytes", - "http", + "http 0.2.9", "pin-project-lite", ] +[[package]] +name = "http-body" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" +dependencies = [ + "bytes", + "http 1.0.0", +] + [[package]] name = "http-range-header" version = "0.3.1" @@ -449,8 +470,8 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "http", - "http-body", + "http 0.2.9", + "http-body 0.4.5", "httparse", "httpdate", "itoa", @@ -462,6 +483,22 @@ dependencies = [ "want", ] +[[package]] +name = "hyper" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "403f9214f3e703236b221f1a9cd88ec8b4adfa5296de01ab96216361f4692f56" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http 1.0.0", + "http-body 1.0.0", + "pin-project-lite", + "tokio", + "want", +] + [[package]] name = "hyper-rustls" version = "0.24.1" @@ -469,8 +506,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d78e1e73ec14cf7375674f74d7dde185c8206fd9dea6fb6295e8a98098aaa97" dependencies = [ "futures-util", - "http", - "hyper", + "http 0.2.9", + "hyper 0.14.27", "log", "rustls", "rustls-native-certs", @@ -484,7 +521,7 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" dependencies = [ - "hyper", + "hyper 0.14.27", "pin-project-lite", "tokio", "tokio-io-timeout", @@ -703,9 +740,9 @@ dependencies = [ "either", "futures", "futures-util", - "http", - "http-body", - "hyper", + "http 0.2.9", + "http-body 0.4.5", + "hyper 0.14.27", "hyper-rustls", "hyper-timeout", "jsonwebtoken", @@ -816,7 +853,7 @@ dependencies = [ "axum", "env_logger", "futures", - "hyper", + "hyper 1.0.1", "libc", "log", "octocrab", @@ -1423,8 +1460,8 @@ dependencies = [ "bytes", "futures-core", "futures-util", - "http", - "http-body", + "http 0.2.9", + "http-body 0.4.5", "http-range-header", "iri-string", "pin-project-lite", diff --git a/Cargo.toml b/Cargo.toml index ac29b54..8658fce 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,6 +23,6 @@ url = { version = "2.4", "features" = ["serde"] } [dev-dependencies] anyhow = "1.0" -hyper = { version = "0.14", features = ["client"] } +hyper = { version = "1.0", features = ["client"] } env_logger = "0.10" portpicker = "0.1" From 637596d879690905be87fc1eafc0ee8b1ed4db5e Mon Sep 17 00:00:00 2001 From: Matthias Wahl Date: Sun, 26 Nov 2023 10:42:13 +0100 Subject: [PATCH 2/3] Update rust toolchain to 1.74 --- rust-toolchain.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 7eb23c4..71326c3 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.72.1" +channel = "1.74" From 4fcfd73f85b498dece0dc27242130623fc076c9b Mon Sep 17 00:00:00 2001 From: Matthias Wahl Date: Sun, 26 Nov 2023 11:09:47 +0100 Subject: [PATCH 3/3] Exchange hyper for reqwest it was just a test-dependency anyways and reqwest is much more convenient to use. --- Cargo.lock | 203 +++++++++++++++++++++++++++++++++++++++++++-------- Cargo.toml | 8 +- tests/api.rs | 64 +++++++--------- 3 files changed, 205 insertions(+), 70 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2b34a99..e29fe8a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -83,7 +83,7 @@ dependencies = [ "futures-util", "http 0.2.9", "http-body 0.4.5", - "hyper 0.14.27", + "hyper", "itoa", "matchit", "memchr", @@ -226,6 +226,15 @@ version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +[[package]] +name = "encoding_rs" +version = "0.8.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" +dependencies = [ + "cfg-if", +] + [[package]] name = "env_logger" version = "0.10.1" @@ -239,6 +248,12 @@ dependencies = [ "termcolor", ] +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + [[package]] name = "errno" version = "0.3.3" @@ -268,9 +283,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "form_urlencoded" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" dependencies = [ "percent-encoding", ] @@ -381,6 +396,31 @@ version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" +[[package]] +name = "h2" +version = "0.3.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d6250322ef6e60f93f9a2162799302cd6f68f79f6e5d85c8c16f14d1d958178" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http 0.2.9", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" + [[package]] name = "heck" version = "0.4.1" @@ -436,6 +476,19 @@ dependencies = [ "http 1.0.0", ] +[[package]] +name = "http-body-util" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41cb79eb393015dadd30fc252023adb0b2400a0caee0fa2a077e6e21a551e840" +dependencies = [ + "bytes", + "futures-util", + "http 1.0.0", + "http-body 1.0.0", + "pin-project-lite", +] + [[package]] name = "http-range-header" version = "0.3.1" @@ -470,6 +523,7 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", + "h2", "http 0.2.9", "http-body 0.4.5", "httparse", @@ -483,22 +537,6 @@ dependencies = [ "want", ] -[[package]] -name = "hyper" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "403f9214f3e703236b221f1a9cd88ec8b4adfa5296de01ab96216361f4692f56" -dependencies = [ - "bytes", - "futures-channel", - "futures-util", - "http 1.0.0", - "http-body 1.0.0", - "pin-project-lite", - "tokio", - "want", -] - [[package]] name = "hyper-rustls" version = "0.24.1" @@ -507,7 +545,7 @@ checksum = "8d78e1e73ec14cf7375674f74d7dde185c8206fd9dea6fb6295e8a98098aaa97" dependencies = [ "futures-util", "http 0.2.9", - "hyper 0.14.27", + "hyper", "log", "rustls", "rustls-native-certs", @@ -521,7 +559,7 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" dependencies = [ - "hyper 0.14.27", + "hyper", "pin-project-lite", "tokio", "tokio-io-timeout", @@ -552,14 +590,30 @@ dependencies = [ [[package]] name = "idna" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ "unicode-bidi", "unicode-normalization", ] +[[package]] +name = "indexmap" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "ipnet" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" + [[package]] name = "iri-string" version = "0.7.0" @@ -742,7 +796,7 @@ dependencies = [ "futures-util", "http 0.2.9", "http-body 0.4.5", - "hyper 0.14.27", + "hyper", "hyper-rustls", "hyper-timeout", "jsonwebtoken", @@ -809,9 +863,9 @@ dependencies = [ [[package]] name = "percent-encoding" -version = "2.3.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pin-project" @@ -853,11 +907,12 @@ dependencies = [ "axum", "env_logger", "futures", - "hyper 1.0.1", + "http-body-util", "libc", "log", "octocrab", "portpicker", + "reqwest", "serde", "serde_json", "tokio", @@ -966,6 +1021,46 @@ version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" +[[package]] +name = "reqwest" +version = "0.11.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "046cd98826c46c2ac8ddecae268eb5c2e58628688a5fc7a2643704a73faba95b" +dependencies = [ + "base64", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http 0.2.9", + "http-body 0.4.5", + "hyper", + "hyper-rustls", + "ipnet", + "js-sys", + "log", + "mime", + "once_cell", + "percent-encoding", + "pin-project-lite", + "rustls", + "rustls-pemfile", + "serde", + "serde_json", + "serde_urlencoded", + "system-configuration", + "tokio", + "tokio-rustls", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "webpki-roots", + "winreg", +] + [[package]] name = "ring" version = "0.16.20" @@ -1298,6 +1393,27 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +[[package]] +name = "system-configuration" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "termcolor" version = "1.2.0" @@ -1431,6 +1547,7 @@ dependencies = [ "futures-sink", "pin-project-lite", "tokio", + "tracing", ] [[package]] @@ -1557,9 +1674,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" dependencies = [ "form_urlencoded", "idna", @@ -1616,6 +1733,18 @@ dependencies = [ "wasm-bindgen-shared", ] +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "wasm-bindgen-macro" version = "0.2.87" @@ -1655,6 +1784,12 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "webpki-roots" +version = "0.25.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1778a42e8b3b90bff8d0f5032bf22250792889a5cdc752aa0020c84abe3aaf10" + [[package]] name = "winapi" version = "0.3.9" @@ -1761,6 +1896,16 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +[[package]] +name = "winreg" +version = "0.50.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" +dependencies = [ + "cfg-if", + "windows-sys", +] + [[package]] name = "zeroize" version = "1.6.0" diff --git a/Cargo.toml b/Cargo.toml index 8658fce..27321be 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,10 +19,14 @@ serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" tokio = { version = "1.34", features = ["full"] } wait-timeout = "0.2" -url = { version = "2.4", "features" = ["serde"] } +url = { version = "2.5", "features" = ["serde"] } [dev-dependencies] anyhow = "1.0" -hyper = { version = "1.0", features = ["client"] } +reqwest = { version = "0.11", default_features = false, features = [ + "rustls-tls", + "json", +] } +http-body-util = "0.1" env_logger = "0.10" portpicker = "0.1" diff --git a/tests/api.rs b/tests/api.rs index 808bf2a..b006b1c 100644 --- a/tests/api.rs +++ b/tests/api.rs @@ -1,8 +1,7 @@ use anyhow::Result; -use hyper::body::Buf; -use hyper::{Body, Client, Method, Request, StatusCode}; use pony_playground::api::serve; use pony_playground::init_github_client; +use reqwest::{Client, StatusCode}; use serde::{Deserialize, Serialize}; use std::net::SocketAddr; use std::time::Duration; @@ -25,18 +24,14 @@ async fn evaluate() -> Result<()> { code: "actor Main\n new create(env: Env) => env.out.print(U32(42).string())".to_string(), branch: None, }; - let req = Request::builder() - .method(Method::POST) - .uri(format!("http://127.0.0.1:{port}/evaluate.json")) + let req = client + .post(format!("http://127.0.0.1:{port}/evaluate.json")) .header("content-type", "application/json") - .body(Body::from(serde_json::to_vec(&req_data)?))?; - let res = client.request(req).await?; - let (parts, body) = res.into_parts(); - assert_eq!(StatusCode::OK, parts.status); - let body = hyper::body::aggregate(body).await?; + .body(serde_json::to_vec(&req_data)?); + let res = req.send().await?; + assert_eq!(StatusCode::OK, res.status()); - // try to parse as json with serde_json - let payload: EvaluateOutput = serde_json::from_reader(body.reader())?; + let payload = res.json::().await?; assert!(payload.success); assert!(payload.compiler.contains("Compiled with: LLVM")); assert_eq!("42\n", payload.stdout); @@ -79,17 +74,14 @@ async fn compile() -> Result<()> { code: "actor Main\n new create(env: Env) => None".to_string(), branch: None, }; - let req = Request::builder() - .method(Method::POST) - .uri(format!("http://127.0.0.1:{port}/compile.json")) + let req = client + .post(format!("http://127.0.0.1:{port}/compile.json")) .header("content-type", "application/json") - .body(Body::from(serde_json::to_vec(&req_data)?))?; - let res = client.request(req).await?; - let (parts, body) = res.into_parts(); - assert_eq!(StatusCode::OK, parts.status); - let body = hyper::body::aggregate(body).await?; + .body(serde_json::to_vec(&req_data)?); + let res = req.send().await?; + assert_eq!(StatusCode::OK, res.status()); - let payload: CompileOutput = serde_json::from_reader(body.reader())?; + let payload: CompileOutput = res.json().await?; assert!(payload.error.is_none()); assert!(payload .result @@ -102,17 +94,14 @@ async fn compile() -> Result<()> { code: "actor Main\n new create(env: Env) => None".to_string(), branch: None, }; - let req = Request::builder() - .method(Method::POST) - .uri(format!("http://127.0.0.1:{port}/compile.json")) + let req = client + .post(format!("http://127.0.0.1:{port}/compile.json")) .header("content-type", "application/json") - .body(Body::from(serde_json::to_vec(&req_data)?))?; - let res = client.request(req).await?; - let (parts, body) = res.into_parts(); - assert_eq!(StatusCode::OK, parts.status); - let body = hyper::body::aggregate(body).await?; + .body(serde_json::to_vec(&req_data)?); + let res = req.send().await?; + assert_eq!(StatusCode::OK, res.status()); - let payload: CompileOutput = serde_json::from_reader(body.reader())?; + let payload: CompileOutput = res.json().await?; assert!(payload.error.is_none()); assert!(payload .result @@ -125,17 +114,14 @@ async fn compile() -> Result<()> { code: "actor Maine\n new create(env: Env) => None".to_string(), branch: None, }; - let req = Request::builder() - .method(Method::POST) - .uri(format!("http://127.0.0.1:{port}/compile.json")) + let req = client + .post(format!("http://127.0.0.1:{port}/compile.json")) .header("content-type", "application/json") - .body(Body::from(serde_json::to_vec(&req_data)?))?; - let res = client.request(req).await?; - let (parts, body) = res.into_parts(); - assert_eq!(StatusCode::OK, parts.status); - let body = hyper::body::aggregate(body).await?; + .body(serde_json::to_vec(&req_data)?); + let res = req.send().await?; + assert_eq!(StatusCode::OK, res.status()); - let payload: CompileOutput = serde_json::from_reader(body.reader())?; + let payload: CompileOutput = res.json().await?; assert!(payload.result.is_none()); assert!(payload .error