2

I'm using loopj/android-async-http after having the same problem with the ignition project.

When I submit a GET, without the authorization header, things work fine:

AsyncHttpClient client = new AsyncHttpClient();
client.get(url, params, responseHandler);

I'm sending to a Jersey server and the logging filter shows the expected data:

INFO: 1 * Server in-bound request
1 > GET http://mydomain.com/myresource/
1 > host: mydomain.com
1 > accept-encoding: gzip
1 > user-agent: android-async-http/1.4.0 (http://loopj.com/android-async-http)
1 > connection: Keep-Alive

An authenticated GET works as well.

If I do the same thing with a POST request to the same URL:

AsyncHttpClient client = new AsyncHttpClient();
String auth = user + ":" + pass;
client.addHeader("Authorization", "Basic " + Base64.encodeToString(auth.getBytes(), Base64.DEFAULT));
client.post(context, url, entity, "application/json", responseHandler);

The server doesn't show multiple bits of information that I expect to see and I don't understand why:

INFO: 2 * Server in-bound request
2 > POST http://mydomain.com/myresource/
2 > host: mydomain.com
2 > accept-encoding: gzip
2 > authorization: Basic GFzasomethingvalidhereXN0
2 > connection: Keep-Alive
  1. Why don't I see the "Content-Type" header? This is the main problem I'm having because my Jersey resource is annotated to consume application/json data

  2. Why don't I see the "user-agent" header?

My Jersey resource:

@Service
@Path("/myresource/")
public class MyResource {

@POST
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public MyDTO myEndPointMethod(MyDTO myDTO) {
   //something cool here
}
morten.c
  • 3,414
  • 5
  • 40
  • 45
DaShaun
  • 3,722
  • 2
  • 27
  • 29

0 Answers0