本文整理汇总了Java中org.apache.http.impl.client.ProxyClient类的典型用法代码示例。如果您正苦于以下问题:Java ProxyClient类的具体用法?Java ProxyClient怎么用?Java ProxyClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProxyClient类属于org.apache.http.impl.client包,在下文中一共展示了ProxyClient类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: main
import org.apache.http.impl.client.ProxyClient; //导入依赖的package包/类
public final static void main(String[] args) throws Exception {
ProxyClient proxyClient = new ProxyClient();
HttpHost target = new HttpHost("www.yahoo.com", 80);
HttpHost proxy = new HttpHost("localhost", 8888);
UsernamePasswordCredentials credentials = new UsernamePasswordCredentials("user", "pwd");
Socket socket = proxyClient.tunnel(proxy, target, credentials);
try {
Writer out = new OutputStreamWriter(socket.getOutputStream(), HTTP.DEF_CONTENT_CHARSET);
out.write("GET / HTTP/1.1\r\n");
out.write("Host: " + target.toHostString() + "\r\n");
out.write("Agent: whatever\r\n");
out.write("Connection: close\r\n");
out.write("\r\n");
out.flush();
BufferedReader in = new BufferedReader(
new InputStreamReader(socket.getInputStream(), HTTP.DEF_CONTENT_CHARSET));
String line = null;
while ((line = in.readLine()) != null) {
System.out.println(line);
}
} finally {
socket.close();
}
}
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:26,代码来源:ProxyTunnelDemo.java
示例2: createClient
import org.apache.http.impl.client.ProxyClient; //导入依赖的package包/类
private static ProxyClient createClient() {
ProxyClient client = new ProxyClient();
HttpConnectionParams.setConnectionTimeout(client.getParams(), 3000);
HttpConnectionParams.setSoTimeout(client.getParams(), 3000);
return client;
}
开发者ID:DarkStorm652,项目名称:DarkBot,代码行数:9,代码来源:Connection.java
示例3: buildProxyClient
import org.apache.http.impl.client.ProxyClient; //导入依赖的package包/类
private ProxyClient buildProxyClient() {
RequestConfig requestConfig = RequestConfig.custom().setProxyPreferredAuthSchemes(singleton(NTLM)).build();
ProxyClient proxyClient = new ProxyClient(requestConfig);
proxyClient.getAuthSchemeRegistry().register(NTLM, new NTLMSchemeProvider());
return proxyClient;
}
开发者ID:wdekker,项目名称:jntlm,代码行数:7,代码来源:HttpForwardingHandler.java
注:本文中的org.apache.http.impl.client.ProxyClient类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论