Implement native AIS inventory reconciliation (#63)
This commit is contained in:
@@ -699,6 +699,31 @@ impl HttpCapsClient {
|
||||
.await
|
||||
}
|
||||
|
||||
/// Sends a capability request whose verb or headers are not covered by the
|
||||
/// fixed public compatibility overloads (`AISv3` uses `COPY` and
|
||||
/// `Destination`). The request still passes through all normal limits,
|
||||
/// cancellation, rate limiting, and injected-handler recording.
|
||||
pub(crate) async fn send_custom(
|
||||
&self,
|
||||
method: &str,
|
||||
uri: Uri,
|
||||
headers: std::collections::BTreeMap<String, String>,
|
||||
content_type: Option<String>,
|
||||
payload: Vec<u8>,
|
||||
cancellation_token: CancellationToken,
|
||||
) -> Result<(HttpResponse, Vec<u8>), Error> {
|
||||
self.send_with_headers(
|
||||
method,
|
||||
uri,
|
||||
headers,
|
||||
content_type,
|
||||
payload,
|
||||
cancellation_token,
|
||||
None,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn get_request(
|
||||
&self,
|
||||
uri: Uri,
|
||||
@@ -1026,6 +1051,28 @@ impl HttpCapsClient {
|
||||
payload: Vec<u8>,
|
||||
cancellation_token: CancellationToken,
|
||||
progress: Option<Box<dyn IProgress<HttpCapsClientProgressReport>>>,
|
||||
) -> Result<(HttpResponse, Vec<u8>), Error> {
|
||||
self.send_with_headers(
|
||||
method,
|
||||
uri,
|
||||
std::collections::BTreeMap::new(),
|
||||
content_type,
|
||||
payload,
|
||||
cancellation_token,
|
||||
progress,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn send_with_headers(
|
||||
&self,
|
||||
method: &str,
|
||||
uri: Uri,
|
||||
headers: std::collections::BTreeMap<String, String>,
|
||||
content_type: Option<String>,
|
||||
payload: Vec<u8>,
|
||||
cancellation_token: CancellationToken,
|
||||
progress: Option<Box<dyn IProgress<HttpCapsClientProgressReport>>>,
|
||||
) -> Result<(HttpResponse, Vec<u8>), Error> {
|
||||
if self.0.disposed.load(Ordering::Acquire) {
|
||||
return Err(Error::InvalidOperation);
|
||||
@@ -1057,6 +1104,7 @@ impl HttpCapsClient {
|
||||
handler,
|
||||
method,
|
||||
uri,
|
||||
headers,
|
||||
content_type,
|
||||
payload,
|
||||
cancellation_token,
|
||||
@@ -1069,6 +1117,7 @@ impl HttpCapsClient {
|
||||
client,
|
||||
method,
|
||||
parsed,
|
||||
headers,
|
||||
content_type,
|
||||
payload,
|
||||
cancellation_token,
|
||||
@@ -1086,6 +1135,7 @@ impl HttpCapsClient {
|
||||
handler: &HttpMessageHandler,
|
||||
method: &str,
|
||||
uri: Uri,
|
||||
headers: std::collections::BTreeMap<String, String>,
|
||||
content_type: Option<String>,
|
||||
payload: Vec<u8>,
|
||||
cancellation_token: CancellationToken,
|
||||
@@ -1095,7 +1145,7 @@ impl HttpCapsClient {
|
||||
let request = HttpRequest {
|
||||
method: method.to_owned(),
|
||||
uri,
|
||||
headers: std::collections::BTreeMap::new(),
|
||||
headers,
|
||||
content_type,
|
||||
body: payload,
|
||||
};
|
||||
@@ -1112,6 +1162,7 @@ impl HttpCapsClient {
|
||||
client: &reqwest::Client,
|
||||
method: &str,
|
||||
uri: reqwest::Url,
|
||||
headers: std::collections::BTreeMap<String, String>,
|
||||
content_type: Option<String>,
|
||||
payload: Vec<u8>,
|
||||
cancellation_token: CancellationToken,
|
||||
@@ -1119,6 +1170,9 @@ impl HttpCapsClient {
|
||||
) -> Result<(HttpResponse, Vec<u8>), Error> {
|
||||
let method = reqwest::Method::from_bytes(method.as_bytes()).map_err(|_| Error::Argument)?;
|
||||
let mut request = client.request(method, uri);
|
||||
for (name, value) in headers {
|
||||
request = request.header(name, value);
|
||||
}
|
||||
if let Some(content_type) = content_type {
|
||||
request = request.header(reqwest::header::CONTENT_TYPE, content_type);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user