Relaxed AP POST headers and response type
ci/woodpecker/push/ociImagePush Pipeline was successful
Details
ci/woodpecker/push/ociImagePush Pipeline was successful
Details
This commit is contained in:
parent
e53afb3313
commit
369df105c9
|
@ -1,6 +1,7 @@
|
||||||
use std::{fmt::Display, sync::Arc};
|
use std::{borrow::Cow, fmt::Display, string::FromUtf8Error, sync::Arc};
|
||||||
|
|
||||||
use chrono::Utc;
|
use chrono::Utc;
|
||||||
|
use futures::{FutureExt, TryFutureExt};
|
||||||
use http::{HeaderMap, HeaderName, HeaderValue, Method};
|
use http::{HeaderMap, HeaderName, HeaderValue, Method};
|
||||||
use indexmap::IndexSet;
|
use indexmap::IndexSet;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
@ -74,6 +75,8 @@ pub enum ApClientError {
|
||||||
SerializerError(#[from] serde_json::Error),
|
SerializerError(#[from] serde_json::Error),
|
||||||
#[error("Invalid header value: {0}")]
|
#[error("Invalid header value: {0}")]
|
||||||
InvalidHeaderValue(#[from] http::header::InvalidHeaderValue),
|
InvalidHeaderValue(#[from] http::header::InvalidHeaderValue),
|
||||||
|
#[error("UTF-8 parse error: {0}")]
|
||||||
|
Utf8ParseError(#[from] FromUtf8Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
trait CreateField {
|
trait CreateField {
|
||||||
|
@ -342,7 +345,7 @@ impl ApClientService for ApClientServiceDefaultProvider {
|
||||||
expires: Option<chrono::DateTime<Utc>>,
|
expires: Option<chrono::DateTime<Utc>>,
|
||||||
url: &str,
|
url: &str,
|
||||||
body: &Value,
|
body: &Value,
|
||||||
) -> Result<Value, Self::Error> {
|
) -> Result<String, Self::Error> {
|
||||||
let url = url.parse()?;
|
let url = url.parse()?;
|
||||||
let body_bytes = serde_json::to_vec(body)?;
|
let body_bytes = serde_json::to_vec(body)?;
|
||||||
let mut sha = sha2::Sha256::new();
|
let mut sha = sha2::Sha256::new();
|
||||||
|
@ -407,12 +410,13 @@ impl ApClientService for ApClientServiceDefaultProvider {
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.builder(Method::POST, url)
|
.builder(Method::POST, url)
|
||||||
.accept(ContentActivityStreams)
|
|
||||||
.content_type(ContentActivityStreams)
|
.content_type(ContentActivityStreams)
|
||||||
.headers(headers)
|
.headers(headers)
|
||||||
.body(body_bytes)
|
.body(body_bytes)
|
||||||
.json()
|
.send()
|
||||||
.await?)
|
.map_ok(String::from_utf8)
|
||||||
|
.await??
|
||||||
|
.to_string())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -172,5 +172,5 @@ pub trait ApClientService: Send + Sync {
|
||||||
expires: Option<chrono::DateTime<Utc>>,
|
expires: Option<chrono::DateTime<Utc>>,
|
||||||
url: &str,
|
url: &str,
|
||||||
body: &Value,
|
body: &Value,
|
||||||
) -> Result<Value, Self::Error>;
|
) -> Result<String, Self::Error>;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue