使用Fluent API请求进行代理身份验证?

编程入门 行业动态 更新时间:2024-10-25 02:26:10
本文介绍了使用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请求进行代理身份验证?

本文发布于:2023-10-10 01:27:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1477315.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:身份验证   Fluent   API

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!