Skip to content
This repository has been archived by the owner on Sep 21, 2024. It is now read-only.

chore: Upgrade reqwest to 0.12, without macos-system-configuration. Fixes #686 #866

Merged
merged 1 commit into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 74 additions & 38 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ libipld-cbor = { version = "0.16" }
libipld-json = { version = "0.16" }
pathdiff = { version = "0.2.1" }
rand = { version = "0.8" }
reqwest = { version = "=0.11.20", default-features = false, features = ["json", "rustls-tls", "stream"] }
reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls", "stream"] }
sentry-tracing = { version = "0.31.8" }
serde = { version = "^1" }
serde_json = { version = "^1" }
Expand Down Expand Up @@ -88,7 +88,7 @@ void = { version = "1" }
wasm-bindgen = { version = "^0.2" }
wasm-bindgen-test = { version = "^0.3" }
wasm-bindgen-futures = { version = "^0.4" }
wasm-streams = { version = "0.3.0" }
wasm-streams = { version = "0.4" }
web-sys = { version = "0.3" }

[profile.release]
Expand Down
2 changes: 1 addition & 1 deletion rust/noosphere-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ observability = ["noosphere-gateway/observability"]
vergen = { workspace = true }

[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
reqwest = { version = "~0.11", default-features = false, features = ["json", "rustls-tls", "stream"] }
reqwest = { workspace = true, default-features = false, features = ["json", "rustls-tls", "stream"] }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
tempfile = { workspace = true }
Expand Down
36 changes: 7 additions & 29 deletions rust/noosphere-core/src/api/client.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
use std::str::FromStr;

use crate::{
api::{route::RouteUrl, v0alpha1, v0alpha2, StatusCode},
api::{route::RouteUrl, v0alpha1, v0alpha2},
authority::{generate_capability, Author, SphereAbility, SphereReference},
data::{Link, MemoIpld},
error::NoosphereError,
stream::{from_car_stream, memo_history_stream, put_block_stream, to_car_stream},
};
use anyhow::{anyhow, Result};
use async_stream::try_stream;
use bytes::Bytes;
use cid::Cid;
use http::StatusCode;
use iroh_car::CarReader;
use libipld_cbor::DagCborCodec;
use noosphere_common::{ConditionalSend, ConditionalSync, UnsharedStream};

use crate::{
authority::{generate_capability, Author, SphereAbility, SphereReference},
data::{Link, MemoIpld},
};
use noosphere_storage::{block_deserialize, block_serialize, BlockStore};
use noosphere_ucan::{
builder::UcanBuilder,
Expand All @@ -26,6 +22,7 @@ use noosphere_ucan::{
ucan::Ucan,
};
use reqwest::header::HeaderMap;
use std::str::FromStr;
use tokio_stream::{Stream, StreamExt};
use tokio_util::io::StreamReader;
use url::Url;
Expand Down Expand Up @@ -93,7 +90,7 @@ where
client.get(url).send().await?
};

match translate_status_code(did_response.status())? {
match did_response.status() {
StatusCode::OK => (),
_ => return Err(anyhow!("Unable to look up gateway identity")),
};
Expand Down Expand Up @@ -475,7 +472,7 @@ where
v0alpha2::PushError::BrokenUpstream
})?;

let status = translate_status_code(response.status())?;
let status = response.status();
trace!("Checking response ({})...", status);

if status == StatusCode::CONFLICT {
Expand Down Expand Up @@ -531,22 +528,3 @@ where
Ok(push_response)
}
}

/// Both `reqwest` and `axum` re-export `StatusCode` from the `http` crate.
///
/// We're stuck on [email protected] [1] that uses an older version
/// of `http::StatusCode`, whereas axum >= 0.7 uses the 1.0 release
/// of several HTTP libraries (`http`, `http-body`, `hyper`) [2], which
/// we'd like to use as our canonical representation.
///
/// This utility converts between the old `reqwest::StatusCode` to the
/// >=1.0 implementation. Notably, we do not pull in all of `axum`
/// into the `noosphere-core` crate, only the common underlying
/// crate `[email protected]` (or greater).
///
/// [1] https://github.com/subconsciousnetwork/noosphere/issues/686
/// [2] https://github.com/tokio-rs/axum/blob/5b6204168a676497d2f4188af603546d9ebfe20a/axum/CHANGELOG.md#070-27-november-2023
fn translate_status_code(reqwest_code: reqwest::StatusCode) -> Result<StatusCode> {
let code: u16 = reqwest_code.into();
Ok(code.try_into()?)
}
4 changes: 0 additions & 4 deletions rust/noosphere-core/src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,3 @@ pub mod v0alpha2;

pub use client::*;
pub use data::*;

// Re-export `http::StatusCode` here as our preferred `StatusCode` instance,
// disambiguating from other crate's implementations.
pub(crate) use http::StatusCode;
Loading
Loading