【发布时间】:2015-10-11 02:03:31
【问题描述】:
如果我按如下所示创建我的 httpBuilder(假设设置了 proxyUsername,因此调用了 setCredentials),那么对正确传入的 httpAddress-es 的调用将通过代理进行路由。但是,应用程序有一些本地网络中的 http 调用。 http.nonProxyHosts 可以用来解决这个问题并绕过代理吗?如果是这样,怎么做?使用 System.setProperty?或者 HttpBuilder 上的东西?
HTTPBuilder httpBuilder = new HTTPBuilder(httpAddress)
httpBuilder.setProxy(webProxyHost, webProxyPort, webProxyProtocol)
if (proxyUsername) {
httpBuilder.client.getCredentialsProvider().setCredentials(
new AuthScope(webProxyHost, webProxyPort),
new UsernamePasswordCredentials(proxyUsername, proxyPassword))
}
}
在上面的代码中,所有各种命名元素(webProxyHost 等)都被声明为 String 并进行相应设置。
【问题讨论】:
-
您好,我也有类似的情况,请问您找到解决方法了吗?
标签: groovy httpclient httpbuilder