1

I use AsyncHttpClient to create an http POST request:

      AsyncHttpClient.BoundRequestBuilder reqBuilder;
      reqBuilder = httpClient.preparePost(url);
      reqBuilder.setBody(data);

It sometimes doesn't send content-type header and sometimes sends it as

      Content-Type: text/html; charset=ISO-8859-1

which causes our request to fail at [REST API] server side.

I am at a loss to understand why it is inconsistent.

Client is created as below:

      import com.ning.http.client.*;
       AsyncHttpClient httpClient = new AsyncHttpClient(
         new AsyncHttpClientConfig.Builder().build());
Stephane Landelle
  • 6,990
  • 2
  • 23
  • 29
Fakrudeen
  • 5,778
  • 7
  • 44
  • 70

1 Answers1

2

You can set headers by your self

reqBuilder.setHeader(String name, String value);

or add

reqBuilder.addHeader(String name, String value);
msfk
  • 137
  • 1
  • 15