I am facing a strange behaviour using the Apachage HttpComponent to access a webservice.
I have access to the server log and when I am trying to connect to the server and execute the httpGet command I can see in the log at first a 401 status (http Unauthorized) and then a 200 (http OK).
The 2 attempts take place during the "httpClient.execute(httpGet)"
So I am searching how to avoid this behaviour. Any ideas ?
Here is the following code I am currently using :
HttpGet httpGet = new HttpGet(this.url + request);
HttpParams httpParameters = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(httpParameters,3000);
HttpConnectionParams.setSoTimeout(httpParameters,5000);
DefaultHttpClient httpClient = new DefaultHttpClient(httpParameters);
Credentials creds = new UsernamePasswordCredentials(login, password);
httpClient.getCredentialsProvider().setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT), creds);
HttpResponse response = httpClient.execute(httpGet);
int status = response.getStatusLine().getStatusCode();
Log.v(this, "Response code status: " + status); // code status = 200 (even if a 401 and then a 200 are visible in the server log).
For information, I am using this code for an Android application.