From 6e2f3a1f6a80a1e24bcfc434f82a9e0e5180f855 Mon Sep 17 00:00:00 2001 From: Andreas Huber <43344129+okaerin@users.noreply.github.com> Date: Tue, 18 Feb 2025 23:05:23 +0100 Subject: [PATCH 1/5] fix query to form encoded payload --- src/lib/server.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/server.rs b/src/lib/server.rs index 8c38b1b..09803f1 100644 --- a/src/lib/server.rs +++ b/src/lib/server.rs @@ -372,7 +372,7 @@ impl ServerClient { match self .client .post(format!("{0}/check", self.api)) - .query(request) + .form(request) .send() .await { From 460f10fc711bee4f654a36330107ecd458722d48 Mon Sep 17 00:00:00 2001 From: Andreas Huber <43344129+okaerin@users.noreply.github.com> Date: Thu, 20 Feb 2025 22:34:46 +0100 Subject: [PATCH 2/5] change all requests to form encoded --- src/lib/server.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/server.rs b/src/lib/server.rs index 09803f1..9ceaf64 100644 --- a/src/lib/server.rs +++ b/src/lib/server.rs @@ -485,7 +485,7 @@ impl ServerClient { match self .client .get(format!("{}/words", self.api)) - .query(request) + .form(request) .send() .await { @@ -508,7 +508,7 @@ impl ServerClient { match self .client .post(format!("{}/words/add", self.api)) - .query(request) + .form(request) .send() .await { @@ -531,7 +531,7 @@ impl ServerClient { match self .client .post(format!("{}/words/delete", self.api)) - .query(request) + .form(request) .send() .await { From 72d0deb4b2336d68d6f551f971e1ca8d455a5e01 Mon Sep 17 00:00:00 2001 From: Andreas Huber <43344129+okaerin@users.noreply.github.com> Date: Thu, 20 Feb 2025 22:41:57 +0100 Subject: [PATCH 3/5] add accept header "application/json" --- src/lib/server.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib/server.rs b/src/lib/server.rs index 9ceaf64..bf9cfab 100644 --- a/src/lib/server.rs +++ b/src/lib/server.rs @@ -11,7 +11,7 @@ use crate::{ }; #[cfg(feature = "cli")] use clap::Args; -use reqwest::Client; +use reqwest::{header::{HeaderValue, ACCEPT}, Client}; use serde::{Deserialize, Serialize}; use serde_json::Value; use std::{io, path::PathBuf, time::Instant}; @@ -372,6 +372,7 @@ impl ServerClient { match self .client .post(format!("{0}/check", self.api)) + .header(ACCEPT, HeaderValue::from_static("application/json")) .form(request) .send() .await @@ -485,6 +486,7 @@ impl ServerClient { match self .client .get(format!("{}/words", self.api)) + .header(ACCEPT, HeaderValue::from_static("application/json")) .form(request) .send() .await @@ -508,6 +510,7 @@ impl ServerClient { match self .client .post(format!("{}/words/add", self.api)) + .header(ACCEPT, HeaderValue::from_static("application/json")) .form(request) .send() .await @@ -531,6 +534,7 @@ impl ServerClient { match self .client .post(format!("{}/words/delete", self.api)) + .header(ACCEPT, HeaderValue::from_static("application/json")) .form(request) .send() .await From 2492fc851e47ae02ee50fa7efbba091a75484434 Mon Sep 17 00:00:00 2001 From: Andreas Huber <43344129+okaerin@users.noreply.github.com> Date: Fri, 21 Feb 2025 12:10:38 +0100 Subject: [PATCH 4/5] revert /words to query encoded --- src/lib/server.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/server.rs b/src/lib/server.rs index bf9cfab..bb37987 100644 --- a/src/lib/server.rs +++ b/src/lib/server.rs @@ -487,7 +487,7 @@ impl ServerClient { .client .get(format!("{}/words", self.api)) .header(ACCEPT, HeaderValue::from_static("application/json")) - .form(request) + .query(request) .send() .await { From 0ba84e18731c81e48d95475e455f3f77e900ba35 Mon Sep 17 00:00:00 2001 From: Andreas Huber <43344129+okaerin@users.noreply.github.com> Date: Fri, 21 Feb 2025 12:18:53 +0100 Subject: [PATCH 5/5] update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e0482b..6d769b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Derive `Hash` on requests types. [#114](https://github.com/jeertmans/languagetool-rust/pull/114) - Use Codspeed and `check-changelog` actions. [#121](https://github.com/jeertmans/languagetool-rust/pull/121) +### Fixed + +- Fixed api calls to language tool server to adhere to spec. Pass POST calls as `application/x-www-form-urlencoded`. [#129](https://github.com/jeertmans/languagetool-rust/pull/129) + ## [2.1.4](https://github.com/jeertmans/languagetool-rust/compare/v2.1.3...v2.1.4) ### Fixed