Java Http - Post Header Content-Length

Solution 1:

I tried to send the Content-Length with http-request which built on apache http client. It works fine. Example:

private static final HttpRequest<?> HTTP_REQUEST =
      HttpRequestBuilder.createGet(YOUR_URI)
        .addDefaultHeader(HttpHeaders.CONTENT_LENGTH, "0")
        .build();

public void test(){
  System.out.println(HTTP_REQUEST.execute().getStatisCode()); // is 200
}