From 2362ca4e7ac99b7669b7e6b9232348866285a1c0 Mon Sep 17 00:00:00 2001 From: psykose Date: Sat, 16 Nov 2024 12:28:37 +0100 Subject: [PATCH] log http requests that go via send --- src/subsonic.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/subsonic.rs b/src/subsonic.rs index 57d2300..6aa37ee 100644 --- a/src/subsonic.rs +++ b/src/subsonic.rs @@ -111,16 +111,18 @@ impl Client { async fn send( &self, - request: reqwest::RequestBuilder, + request: reqwest::Request, ) -> Result { // FIXME: is an entire channel per request overkill? maybe pool them? let (sender, receiver) = async_channel::bounded(1); + event!(target: "http_request", Level::DEBUG, method = request.method().as_str(), url = request.url().as_str()); + // let tokio take care of the request + further json parsing // this is because reqwest doesn't like the glib main loop // note that this is why those silly bounds on T are needed, because we're // sending back the result of the query from another thread - let future = request.send(); + let future = self.client.execute(request); runtime().spawn(async move { // wrap this logic in a fn so we can use ? async fn perform( @@ -165,7 +167,8 @@ impl Client { path: &[&str], query: &[(&str, &str)], ) -> Result { - self.send(self.client.get(self.url(path, query))).await + self.send(self.client.get(self.url(path, query)).build()?) + .await } pub async fn ping(&self) -> Result<(), Error> {