我使用cURL调用下面的URL
curl 'http://username:password@192.168.1.108/merlin/Login.cgi'
我得到了适当的回应
{ "Session" : "0xb3e01810", "result" : { "message" : "OK", "num" : 200 } }
我从浏览器(直接打开链接)、postman 甚至NodeJs得到了同样的回应,
但在java中使用okhttp将get\u请求发送到此url时,我得到了响应代码401
我的okhttp java代码是
Request request = new Request.Builder()
.url("http://username:password@192.168.1.108/merlin/Login.cgi")
.build();
try {
com.squareup.okhttp.Response response = client.newCall(request).execute();
System.out.println(response.code());
} catch (IOException e) {
e.printStackTrace();
}