本文整理了Java中org.apache.commons.httpclient.HostConfiguration.setLocalAddress()
方法的一些代码示例,展示了HostConfiguration.setLocalAddress()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HostConfiguration.setLocalAddress()
方法的具体详情如下:
包路径:org.apache.commons.httpclient.HostConfiguration
类名称:HostConfiguration
方法名:setLocalAddress
[英]Set the local address to be used when creating connections. If this is unset, the default address will be used. This is useful for specifying the interface to use on multi-homed or clustered systems.
[中]设置创建连接时要使用的本地地址。如果未设置,将使用默认地址。这对于指定在多宿或群集系统上使用的接口非常有用。
代码示例来源:origin: commons-httpclient/commons-httpclient
/**
* Gets the host configuration for a connection.
* @param conn the connection to get the configuration of
* @return a new HostConfiguration
*/
private HostConfiguration configurationForConnection(HttpConnection conn) {
HostConfiguration connectionConfiguration = new HostConfiguration();
connectionConfiguration.setHost(
conn.getHost(),
conn.getPort(),
conn.getProtocol()
);
if (conn.getLocalAddress() != null) {
connectionConfiguration.setLocalAddress(conn.getLocalAddress());
}
if (conn.getProxyHost() != null) {
connectionConfiguration.setProxy(conn.getProxyHost(), conn.getProxyPort());
}
return connectionConfiguration;
}
代码示例来源:origin: stackoverflow.com
import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.*;
import org.apache.commons.httpclient.protocol.Protocol;
public class HC3Test {
public static void main(String[] args) throws Exception {
String url = args[0];
java.net.URL uri = new java.net.URL(url);
HostConfiguration hc = new HostConfiguration();
hc.setHost(uri.getHost(), uri.getPort(), Protocol.getProtocol(uri.getProtocol()));
hc.setLocalAddress(java.net.InetAddress.getByName(args[1]));//for pseudo 'ip spoofing'
HttpClient client = new HttpClient(new SimpleHttpConnectionManager());
client.setHostConfiguration(hc);
GetMethod method = new GetMethod(url);
client.executeMethod(method);
method.releaseConnection();
}
}
代码示例来源:origin: io.gatling/async-http-client
client.getHostConfiguration().setLocalAddress(request.getLocalAddress());
代码示例来源:origin: org.sonatype.nexus/nexus-proxy
/**
* Gets the host configuration for a connection.
* @param conn the connection to get the configuration of
* @return a new HostConfiguration
*/
private HostConfiguration configurationForConnection(HttpConnection conn) {
HostConfiguration connectionConfiguration = new HostConfiguration();
connectionConfiguration.setHost(
conn.getHost(),
conn.getPort(),
conn.getProtocol()
);
if (conn.getLocalAddress() != null) {
connectionConfiguration.setLocalAddress(conn.getLocalAddress());
}
if (conn.getProxyHost() != null) {
connectionConfiguration.setProxy(conn.getProxyHost(), conn.getProxyPort());
}
return connectionConfiguration;
}
代码示例来源:origin: org.apache.commons/com.springsource.org.apache.commons.httpclient
/**
* Gets the host configuration for a connection.
* @param conn the connection to get the configuration of
* @return a new HostConfiguration
*/
private HostConfiguration configurationForConnection(HttpConnection conn) {
HostConfiguration connectionConfiguration = new HostConfiguration();
connectionConfiguration.setHost(
conn.getHost(),
conn.getPort(),
conn.getProtocol()
);
if (conn.getLocalAddress() != null) {
connectionConfiguration.setLocalAddress(conn.getLocalAddress());
}
if (conn.getProxyHost() != null) {
connectionConfiguration.setProxy(conn.getProxyHost(), conn.getProxyPort());
}
return connectionConfiguration;
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-httpclient
/**
* Gets the host configuration for a connection.
* @param conn the connection to get the configuration of
* @return a new HostConfiguration
*/
private HostConfiguration configurationForConnection(HttpConnection conn) {
HostConfiguration connectionConfiguration = new HostConfiguration();
connectionConfiguration.setHost(
conn.getHost(),
conn.getPort(),
conn.getProtocol()
);
if (conn.getLocalAddress() != null) {
connectionConfiguration.setLocalAddress(conn.getLocalAddress());
}
if (conn.getProxyHost() != null) {
connectionConfiguration.setProxy(conn.getProxyHost(), conn.getProxyPort());
}
return connectionConfiguration;
}
代码示例来源:origin: org.apache.commons/httpclient
/**
* Gets the host configuration for a connection.
* @param conn the connection to get the configuration of
* @return a new HostConfiguration
*/
private HostConfiguration configurationForConnection(HttpConnection conn) {
HostConfiguration connectionConfiguration = new HostConfiguration();
connectionConfiguration.setHost(
conn.getHost(),
conn.getPort(),
conn.getProtocol()
);
if (conn.getLocalAddress() != null) {
connectionConfiguration.setLocalAddress(conn.getLocalAddress());
}
if (conn.getProxyHost() != null) {
connectionConfiguration.setProxy(conn.getProxyHost(), conn.getProxyPort());
}
return connectionConfiguration;
}
代码示例来源:origin: org.wso2.commons-httpclient/commons-httpclient
/**
* Gets the host configuration for a connection.
* @param conn the connection to get the configuration of
* @return a new HostConfiguration
*/
private HostConfiguration configurationForConnection(HttpConnection conn) {
HostConfiguration connectionConfiguration = new HostConfiguration();
connectionConfiguration.setHost(
conn.getHost(),
conn.getPort(),
conn.getProtocol()
);
if (conn.getLocalAddress() != null) {
connectionConfiguration.setLocalAddress(conn.getLocalAddress());
}
if (conn.getProxyHost() != null) {
connectionConfiguration.setProxy(conn.getProxyHost(), conn.getProxyPort());
}
return connectionConfiguration;
}
代码示例来源:origin: apache/flex-blazeds
hostConfig.setLocalAddress(addr);
代码示例来源:origin: com.adobe.flex/com.springsource.flex.messaging.services.http
hostConfig.setLocalAddress(addr);
内容来源于网络,如有侵权,请联系作者删除!