diff --git a/languagetool-server/src/main/java/org/languagetool/server/LanguageToolHttpHandler.java b/languagetool-server/src/main/java/org/languagetool/server/LanguageToolHttpHandler.java index d2ebe3588c50..b64abe0e8311 100644 --- a/languagetool-server/src/main/java/org/languagetool/server/LanguageToolHttpHandler.java +++ b/languagetool-server/src/main/java/org/languagetool/server/LanguageToolHttpHandler.java @@ -131,10 +131,18 @@ public void handle(HttpExchange httpExchange) throws IOException { ServerMetricsCollector.getInstance().logFailedHealthcheck(); return; } else { - String ok = "OK"; httpExchange.getResponseHeaders().set("Content-Type", "text/plain"); - httpExchange.sendResponseHeaders(HttpURLConnection.HTTP_OK, ok.getBytes(ENCODING).length); - httpExchange.getResponseBody().write(ok.getBytes(ENCODING)); + + String requestMethod = httpExchange.getRequestMethod(); + if ("HEAD".equalsIgnoreCase(requestMethod)) { + // Send HTTP 200 without content + httpExchange.sendResponseHeaders(HttpURLConnection.HTTP_OK, -1); + } else { + String ok = "OK"; + httpExchange.sendResponseHeaders(HttpURLConnection.HTTP_OK, ok.getBytes(ENCODING).length); + httpExchange.getResponseBody().write(ok.getBytes(ENCODING)); + } + ServerMetricsCollector.getInstance().logResponse(HttpURLConnection.HTTP_OK); return; }