@@ -613,7 +613,7 @@ def check(self, text: str) -> List[Match]:
613613 """
614614 url = urllib .parse .urljoin (self ._url , "check" )
615615 logger .debug ("Sending text to LanguageTool server at %s" , url )
616- response = self ._query_server (url , self ._create_params (text ))
616+ response = self ._query_server (url , self ._create_params (text ), method = "post" )
617617 matches = response ["matches" ]
618618 return [Match (match , text ) for match in matches ]
619619
@@ -865,6 +865,7 @@ def _query_server(
865865 url : str ,
866866 params : Optional [Dict [str , str ]] = None ,
867867 num_tries : int = 2 ,
868+ method : Literal ["get" , "post" ] = "get" ,
868869 ) -> Any :
869870 """
870871 Query the server with the given URL and parameters.
@@ -875,19 +876,30 @@ def _query_server(
875876 :type params: Optional[Dict[str, str]], optional
876877 :param num_tries: The number of times to retry the query in case of failure, defaults to 2.
877878 :type num_tries: int, optional
879+ :param method: HTTP method to use for the request. ``post`` sends params in the request body.
880+ :type method: Literal["get", "post"]
878881 :return: The JSON response from the server.
879882 :rtype: Any
880883 :raises LanguageToolError: If the server returns an invalid JSON response or if the query fails after the specified number of retries.
881884 """
882885 logger .debug ("_query_server url: %s" , url )
883886 for n in range (num_tries ):
884887 try :
885- with requests .get (
886- url ,
887- params = params ,
888- timeout = self ._TIMEOUT ,
889- proxies = self ._proxies ,
890- ) as response :
888+ if method == "post" :
889+ response_context = requests .post (
890+ url ,
891+ data = params ,
892+ timeout = self ._TIMEOUT ,
893+ proxies = self ._proxies ,
894+ )
895+ else :
896+ response_context = requests .get (
897+ url ,
898+ params = params ,
899+ timeout = self ._TIMEOUT ,
900+ proxies = self ._proxies ,
901+ )
902+ with response_context as response :
891903 try :
892904 return response .json ()
893905 except json .decoder .JSONDecodeError as e :
0 commit comments