fix: Fixed the logout method that got a 504 from API due to wrong usage

Signed-off-by: Louis Vallat <louis@louis-vallat.xyz>
This commit is contained in:
Louis Vallat 2022-07-01 00:19:00 +02:00
parent 53ddc549c1
commit 6225d26333
No known key found for this signature in database
GPG Key ID: 0C87282F76E61283
2 changed files with 9 additions and 3 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "livebox"
version = "0.9.2"
version = "0.9.3"
edition = "2021"
description = "A library to gather data from Livebox 4 & 5."
license = "GPL-3.0"

View File

@ -186,13 +186,19 @@ impl Client {
/// Logout from the router.
pub async fn logout(&mut self) {
trace!("Logging out.");
let post_data = json!({
"service":"sah.Device.Information",
"method":"releaseContext",
"parameters":{"applicationName":"so_sdkut"}}
);
let req = Request::builder()
.method(Method::POST)
.uri(format!("http://{}/ws", self.ip))
.header(AUTHORIZATION,
format!("X-Sah-Logout {}", self.context_id.clone().unwrap()))
.header(COOKIE, self.cookies.join("; "))
.body(Body::empty())
.body(Body::from(post_data.to_string()))
.expect("Could not build request.");
self.client.request(req).await
.expect("There was an issue contacting the router.");
debug!("Logged out.");