I am trying to send a POST request (HTTP/2) with a header called ":path" but looks like HttpClient in java 11 does not allow headers starting by colon.
This header should be fine using HTTP/2.
That is how my code looks like:
HttpClient httpClient = HttpClient.newHttpClient();
HttpRequest mainRequest = HttpRequest.newBuilder()
.uri(URI.create("xxxx"))
.setHeader(":method", "POST")
.setHeader(":path", "xxxxx")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> response = null;
try {
response = httpClient.send(mainRequest, HttpResponse.BodyHandlers.ofString());
} catch (Exception e) {
e.printStackTrace();
}
Am I doing something wrong?