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:
parent
53ddc549c1
commit
6225d26333
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "livebox"
|
name = "livebox"
|
||||||
version = "0.9.2"
|
version = "0.9.3"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
description = "A library to gather data from Livebox 4 & 5."
|
description = "A library to gather data from Livebox 4 & 5."
|
||||||
license = "GPL-3.0"
|
license = "GPL-3.0"
|
||||||
|
@ -186,13 +186,19 @@ impl Client {
|
|||||||
/// Logout from the router.
|
/// Logout from the router.
|
||||||
pub async fn logout(&mut self) {
|
pub async fn logout(&mut self) {
|
||||||
trace!("Logging out.");
|
trace!("Logging out.");
|
||||||
|
let post_data = json!({
|
||||||
|
"service":"sah.Device.Information",
|
||||||
|
"method":"releaseContext",
|
||||||
|
"parameters":{"applicationName":"so_sdkut"}}
|
||||||
|
);
|
||||||
let req = Request::builder()
|
let req = Request::builder()
|
||||||
.method(Method::POST)
|
.method(Method::POST)
|
||||||
.uri(format!("http://{}/ws", self.ip))
|
.uri(format!("http://{}/ws", self.ip))
|
||||||
|
.header(AUTHORIZATION,
|
||||||
|
format!("X-Sah-Logout {}", self.context_id.clone().unwrap()))
|
||||||
.header(COOKIE, self.cookies.join("; "))
|
.header(COOKIE, self.cookies.join("; "))
|
||||||
.body(Body::empty())
|
.body(Body::from(post_data.to_string()))
|
||||||
.expect("Could not build request.");
|
.expect("Could not build request.");
|
||||||
|
|
||||||
self.client.request(req).await
|
self.client.request(req).await
|
||||||
.expect("There was an issue contacting the router.");
|
.expect("There was an issue contacting the router.");
|
||||||
debug!("Logged out.");
|
debug!("Logged out.");
|
||||||
|
Loading…
Reference in New Issue
Block a user