I tried to make an http request with the code:
String username = "test\\v100"; String host = "1.2.3.4"; String password = "pass"; HttpClient client = new DefaultHttpClient(); AuthScope as = new AuthScope(host, 90); UsernamePasswordCredentials upc = new UsernamePasswordCredentials(username, password); ((AbstractHttpClient) client).getCredentialsProvider().setCredentials(as, upc); BasicHttpContext localContext = new BasicHttpContext(); BasicScheme basicAuth = new BasicScheme(); localContext.setAttribute("preemptive-auth", basicAuth); HttpHost targetHost = new HttpHost(host, 90, "http"); HttpGet httpget = new HttpGet("/"); HttpResponse response = client.execute(targetHost, httpget, localContext);
But get the exception "java.net.SocketException: Permission denied" with the last line.
Android 2.2 with the Eclipse IDE.
Curl request in host system
curl -u test\v100:pass "http://1.2.3.4:90"
works great.
How can I make an HTTP request in the correct way?
Thanks!
source share