10
使用HttpClient在Java中进行Http基本身份验证?
我试图模仿Java中此curl命令的功能: curl --basic --user username:password -d "" http://ipaddress/test/login 我使用Commons HttpClient 3.0编写了以下内容,但最终还是500 Internal Server Error从服务器上获取了一个。有人可以告诉我我做错了什么吗? public class HttpBasicAuth { private static final String ENCODING = "UTF-8"; /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub try { HttpClient client = new HttpClient(); client.getState().setCredentials( new …
156
java
http
apache-commons