如何从httpclient获取身份验证方案?
我使用apache httpclient连接到url。每当我收到401错误时,我想知道服务器的身份验证方案?如何从httpclient获取身份验证方案?,httpclient,Httpclient,我使用apache httpclient连接到url。每当我收到401错误时,我想知道服务器的身份验证方案? 相似的响应代码得到相似的响应。getStatusLine().getStatusCode()类似地,如何获得哪种身份验证方案?HttpClient教程是您的朋友 HttpClient httpclient = new DefaultHttpClient(); HttpContext localContext = new BasicHttpContext(); HttpGet http
相似的响应代码得到相似的响应。getStatusLine().getStatusCode()类似地,如何获得哪种身份验证方案?HttpClient教程是您的朋友
HttpClient httpclient = new DefaultHttpClient();
HttpContext localContext = new BasicHttpContext();
HttpGet httpget = new HttpGet("http://localhost:8080/");
HttpResponse response = httpclient.execute(httpget, localContext);
AuthState targetAuthState = (AuthState) localContext.getAttribute(ClientContext.TARGET_AUTH_STATE);
System.out.println("Target auth scope: " + targetAuthState.getAuthScope());
System.out.println("Target auth scheme: " + targetAuthState.getAuthScheme());