本文介绍了使用Fluent API请求进行代理身份验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我当前正在使用带有代理信息的获取请求":
I am currently using a Get Request with proxy information:
String result1 = Request.Get("_somehost/") .version(HttpVersion.HTTP_1_1) .connectTimeout(1000) .socketTimeout(1000) .viaProxy(new HttpHost("myproxy", 8080)) .execute().returnContent().asString();结果是需要代理身份验证"错误.我认为发出请求的服务器需要用户名和密码吗?如果是这样,我如何添加该细节?我以前从未使用过Fluent API.
The result is a "Proxy Authentication Required" error. I believe a username and password is required from the server making the request? If so, how do I add that detail? I have never used the Fluent API before.
推荐答案以下是使用Fluent API的示例.可执行程序可用于指定代理的凭据.
Here is an example using the Fluent API. The executor can be used to specify credentials for the proxy.
HttpHost proxyHost = new HttpHost("myproxy", 8080); Executor executor = Executor.newInstance() .auth(proxyHost, "username", "password"); String result1 = executor.execute(Request.Get("_somehost/") .viaProxy(proxyHost)) .returnContent() .asString();更多推荐
使用Fluent API请求进行代理身份验证?
发布评论