From fb1ef83ed75b0c5af640ff2546c0cbf10900892d Mon Sep 17 00:00:00 2001 From: Sergey Grigoriev Date: Tue, 16 Jul 2024 09:22:21 +0200 Subject: [PATCH] fix: set Content-Type for POST request --- .../maven/plugins/markdown2html/github/GitHubHttpClient.java | 3 ++- .../plugins/markdown2html/github/GitHubHttpClientTest.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/ch/sbb/maven/plugins/markdown2html/github/GitHubHttpClient.java b/src/main/java/ch/sbb/maven/plugins/markdown2html/github/GitHubHttpClient.java index 96bf08e..2a36632 100644 --- a/src/main/java/ch/sbb/maven/plugins/markdown2html/github/GitHubHttpClient.java +++ b/src/main/java/ch/sbb/maven/plugins/markdown2html/github/GitHubHttpClient.java @@ -5,6 +5,7 @@ import org.apache.hc.client5.http.classic.methods.HttpPost; import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; import org.apache.hc.client5.http.impl.classic.HttpClients; +import org.apache.hc.core5.http.ContentType; import org.apache.hc.core5.http.HttpHeaders; import org.apache.hc.core5.http.HttpStatus; import org.apache.hc.core5.http.io.HttpClientResponseHandler; @@ -35,7 +36,7 @@ public String convertMarkdownToHtml(String markdown) throws IOException { } MarkdownRequest markdownRequest = new MarkdownRequest(GFM, markdown); - httpPost.setEntity(new StringEntity(markdownRequest.toJSON())); + httpPost.setEntity(new StringEntity(markdownRequest.toJSON(), ContentType.APPLICATION_JSON)); return executeRequest(httpClient, httpPost); } diff --git a/src/test/java/ch/sbb/maven/plugins/markdown2html/github/GitHubHttpClientTest.java b/src/test/java/ch/sbb/maven/plugins/markdown2html/github/GitHubHttpClientTest.java index 82e7820..821c51f 100644 --- a/src/test/java/ch/sbb/maven/plugins/markdown2html/github/GitHubHttpClientTest.java +++ b/src/test/java/ch/sbb/maven/plugins/markdown2html/github/GitHubHttpClientTest.java @@ -13,7 +13,8 @@ class GitHubHttpClientTest { public static Stream convertMarkdownToHtml_validMarkdown_returnsHtml_parameters() { return Stream.of( Arguments.of("", ""), - Arguments.of("Hello, **world**!", "

Hello, world!

") + Arguments.of("Hello, **world**!", "

Hello, world!

"), + Arguments.of("# Façade", "

Façade

") ); }