mirror of
https://github.com/rust-lang/cargo
synced 2024-08-27 19:29:21 +00:00
feat(crates-io): expose headers for ResponseError::Api
In response to RFC 3231 [^1], our registry client need to return headers to caller, so that the caller (cargo binary) can continue parsing challenge headers. [^1]: https://rust-lang.github.io/rfcs/3231-cargo-asymmetric-tokens.html#the-authentication-process
This commit is contained in:
parent
1b15556767
commit
6805944715
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -585,7 +585,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "crates-io"
|
||||
version = "0.37.0"
|
||||
version = "0.38.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"curl",
|
||||
|
|
|
@ -27,7 +27,7 @@ cargo-util = { version = "0.2.5", path = "crates/cargo-util" }
|
|||
cargo_metadata = "0.14.0"
|
||||
clap = "4.2.0"
|
||||
core-foundation = { version = "0.9.0", features = ["mac_os_10_7_support"] }
|
||||
crates-io = { version = "0.37.0", path = "crates/crates-io" }
|
||||
crates-io = { version = "0.38.0", path = "crates/crates-io" }
|
||||
criterion = { version = "0.5.1", features = ["html_reports"] }
|
||||
curl = "0.4.44"
|
||||
curl-sys = "0.4.63"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "crates-io"
|
||||
version = "0.37.0"
|
||||
version = "0.38.0"
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
repository = "https://github.com/rust-lang/cargo"
|
||||
|
|
|
@ -130,6 +130,7 @@ pub enum ResponseError {
|
|||
Curl(curl::Error),
|
||||
Api {
|
||||
code: u32,
|
||||
headers: Vec<String>,
|
||||
errors: Vec<String>,
|
||||
},
|
||||
Code {
|
||||
|
@ -155,7 +156,7 @@ impl fmt::Display for ResponseError {
|
|||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
ResponseError::Curl(e) => write!(f, "{}", e),
|
||||
ResponseError::Api { code, errors } => {
|
||||
ResponseError::Api { code, errors, .. } => {
|
||||
f.write_str("the remote server responded with an error")?;
|
||||
if *code != 200 {
|
||||
write!(f, " (status {} {})", code, reason(*code))?;
|
||||
|
@ -447,7 +448,7 @@ impl Registry {
|
|||
|
||||
match (self.handle.response_code()?, errors) {
|
||||
(0, None) | (200, None) => Ok(body),
|
||||
(code, Some(errors)) => Err(ResponseError::Api { code, errors }),
|
||||
(code, Some(errors)) => Err(ResponseError::Api { code, headers, errors }),
|
||||
(code, None) => Err(ResponseError::Code {
|
||||
code,
|
||||
headers,
|
||||
|
|
Loading…
Reference in a new issue