perf(providers): get response as bytes
@@ -72,19 +72,24 @@ impl JsonRpcClient for Provider {
let payload = Request::new(next_id, method, params);
let res = self.client.post(self.url.as_ref()).json(&payload).send().await?;
- let text = res.text().await?;
+ let body = res.bytes().await?;
- let raw = match serde_json::from_str(&text) {
+ let raw = match serde_json::from_slice(&body) {
Ok(Response::Success { result, .. }) => result.to_owned(),
Ok(Response::Error { error, .. }) => return Err(error.into()),
Ok(_) => {
let err = ClientError::SerdeJson {
err: serde::de::Error::custom("unexpected notification over HTTP transport"),
- text,
+ text: String::from_utf8_lossy(&body).to_string(),
};
return Err(err)
}
- Err(err) => return Err(ClientError::SerdeJson { err, text }),
+ Err(err) => {
+ return Err(ClientError::SerdeJson {
+ err,
+ text: String::from_utf8_lossy(&body).to_string(),
+ })
+ }
};
let res = serde_json::from_str(raw.get())
