mirror of
https://github.com/kristoferssolo/transmission-rpc.git
synced 2025-10-21 20:10:37 +00:00
made get sessionId silent
This commit is contained in:
parent
1305b88d03
commit
8d98d1f4bc
25
src/lib.rs
25
src/lib.rs
@ -56,20 +56,21 @@ impl TransClient {
|
|||||||
///
|
///
|
||||||
/// # Errors
|
/// # Errors
|
||||||
///
|
///
|
||||||
/// Panics if any IO error happens
|
/// If response is impossible to unwrap then it will return an empty session_id
|
||||||
async fn get_session_id(&self) -> String {
|
async fn get_session_id(&self) -> String {
|
||||||
info!("Requesting session id info");
|
info!("Requesting session id info");
|
||||||
let response: reqwest::Response = self.rpc_request()
|
let response: reqwest::Result<reqwest::Response> = self.rpc_request()
|
||||||
.json(&RpcRequest::session_get())
|
.json(&RpcRequest::session_get())
|
||||||
.send()
|
.send()
|
||||||
.await
|
.await;
|
||||||
.unwrap();
|
let session_id = match response {
|
||||||
let session_id = response.headers()
|
Ok(ref resp) => resp.headers()
|
||||||
.get("x-transmission-session-id")
|
.get("x-transmission-session-id")
|
||||||
.expect("Unable to get session id")
|
.expect("Unable to get session id")
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap()
|
.unwrap(),
|
||||||
.to_owned();
|
_ => ""
|
||||||
|
}.to_owned();
|
||||||
info!("Received session id: {}", session_id);
|
info!("Received session id: {}", session_id);
|
||||||
session_id
|
session_id
|
||||||
}
|
}
|
||||||
@ -288,7 +289,9 @@ impl TransClient {
|
|||||||
let rq: reqwest::RequestBuilder = self.rpc_request()
|
let rq: reqwest::RequestBuilder = self.rpc_request()
|
||||||
.header("X-Transmission-Session-Id", self.get_session_id().await)
|
.header("X-Transmission-Session-Id", self.get_session_id().await)
|
||||||
.json(&request);
|
.json(&request);
|
||||||
info!("Request body: {:?}", rq.try_clone().unwrap().body_string()?);
|
info!("Request body: {:?}", rq.try_clone()
|
||||||
|
.expect("Unable to get the request body")
|
||||||
|
.body_string()?);
|
||||||
let resp: reqwest::Response = rq.send().await?;
|
let resp: reqwest::Response = rq.send().await?;
|
||||||
let rpc_response: RpcResponse<RS> = resp.json().await?;
|
let rpc_response: RpcResponse<RS> = resp.json().await?;
|
||||||
info!("Response body: {:#?}", rpc_response);
|
info!("Response body: {:#?}", rpc_response);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user