mirror of
https://github.com/Start9Labs/rpc-toolkit.git
synced 2026-03-26 02:11:56 +00:00
fix sync/async mismatch
This commit is contained in:
@@ -5,6 +5,7 @@ use std::time::Duration;
|
||||
|
||||
use clap::{CommandFactory, FromArgMatches};
|
||||
use imbl_value::Value;
|
||||
use reqwest::header::{ACCEPT, CONTENT_LENGTH, CONTENT_TYPE};
|
||||
use reqwest::{Client, Method};
|
||||
use serde::de::DeserializeOwned;
|
||||
use serde::Serialize;
|
||||
@@ -101,25 +102,25 @@ pub async fn call_remote_http(
|
||||
let body;
|
||||
#[cfg(feature = "cbor")]
|
||||
{
|
||||
req = req.header("content-type", "application/cbor");
|
||||
req = req.header("accept", "application/cbor, application/json");
|
||||
req = req.header(CONTENT_TYPE, "application/cbor");
|
||||
req = req.header(ACCEPT, "application/cbor, application/json");
|
||||
body = serde_cbor::to_vec(&rpc_req)?;
|
||||
}
|
||||
#[cfg(not(feature = "cbor"))]
|
||||
{
|
||||
req = req.header("content-type", "application/json");
|
||||
req = req.header("accept", "application/json");
|
||||
req = req.header(CONTENT_TYPE, "application/json");
|
||||
req = req.header(ACCEPT, "application/json");
|
||||
body = serde_json::to_vec(&rpc_req)?;
|
||||
}
|
||||
let res = req
|
||||
.header("content-length", body.len())
|
||||
.header(CONTENT_LENGTH, body.len())
|
||||
.body(body)
|
||||
.send()
|
||||
.await?;
|
||||
|
||||
match res
|
||||
.headers()
|
||||
.get("content-type")
|
||||
.get(CONTENT_TYPE)
|
||||
.and_then(|v| v.to_str().ok())
|
||||
{
|
||||
Some("application/json") => {
|
||||
|
||||
@@ -650,7 +650,8 @@ where
|
||||
raw_params,
|
||||
}: HandlerArgsFor<Self::Context, Self>,
|
||||
) -> Result<Self::Ok, Self::Err> {
|
||||
self.handler.handle_sync(HandlerArgs {
|
||||
self.handler
|
||||
.handle_async(HandlerArgs {
|
||||
context,
|
||||
parent_method,
|
||||
method,
|
||||
@@ -658,6 +659,7 @@ where
|
||||
inherited_params: (self.inherit)(inherited_params.0, inherited_params.1),
|
||||
raw_params,
|
||||
})
|
||||
.await
|
||||
}
|
||||
fn metadata(
|
||||
&self,
|
||||
|
||||
Reference in New Issue
Block a user