本文整理了Java中org.apache.commons.httpclient.protocol.Protocol.getDefaultPort()
方法的一些代码示例,展示了Protocol.getDefaultPort()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Protocol.getDefaultPort()
方法的具体详情如下:
包路径:org.apache.commons.httpclient.protocol.Protocol
类名称:Protocol
方法名:getDefaultPort
[英]Returns the defaultPort.
[中]返回defaultPort。
代码示例来源:origin: commons-httpclient/commons-httpclient
/**
* Resolves the correct port for this protocol. Returns the given port if
* valid or the default port otherwise.
*
* @param port the port to be resolved
*
* @return the given port or the defaultPort
*/
public int resolvePort(int port) {
return port <= 0 ? getDefaultPort() : port;
}
代码示例来源:origin: commons-httpclient/commons-httpclient
/**
* Constructor for HttpHost.
*
* @param hostname the hostname (IP or DNS name). Can be <code>null</code>.
* @param port the port. Value <code>-1</code> can be used to set default protocol port
* @param protocol the protocol. Value <code>null</code> can be used to set default protocol
*/
public HttpHost(final String hostname, int port, final Protocol protocol) {
super();
if (hostname == null) {
throw new IllegalArgumentException("Host name may not be null");
}
if (protocol == null) {
throw new IllegalArgumentException("Protocol may not be null");
}
this.hostname = hostname;
this.protocol = protocol;
if (port >= 0) {
this.port = port;
} else {
this.port = this.protocol.getDefaultPort();
}
}
代码示例来源:origin: commons-httpclient/commons-httpclient
/**
* Return the host uri.
*
* @return The host uri.
*/
public String toURI() {
StringBuffer buffer = new StringBuffer(50);
buffer.append(this.protocol.getScheme());
buffer.append("://");
buffer.append(this.hostname);
if (this.port != this.protocol.getDefaultPort()) {
buffer.append(':');
buffer.append(this.port);
}
return buffer.toString();
}
代码示例来源:origin: commons-httpclient/commons-httpclient
public String getPath() {
if (this.targethost != null) {
StringBuffer buffer = new StringBuffer();
buffer.append(this.targethost.getHost());
int port = this.targethost.getPort();
if (port == -1) {
port = this.targethost.getProtocol().getDefaultPort();
}
buffer.append(':');
buffer.append(port);
return buffer.toString();
} else {
return "/";
}
}
代码示例来源:origin: commons-httpclient/commons-httpclient
/**
* Set the given host. Uses the default protocol("http") and its port.
*
* @param host The host(IP or DNS name).
*/
public synchronized void setHost(final String host) {
Protocol defaultProtocol = Protocol.getProtocol("http");
setHost(host, defaultProtocol.getDefaultPort(), defaultProtocol);
}
代码示例来源:origin: commons-httpclient/commons-httpclient
/**
* Return true if the specified object equals this object.
* @param obj The object to compare against.
* @return true if the objects are equal.
*/
public boolean equals(Object obj) {
if (obj instanceof Protocol) {
Protocol p = (Protocol) obj;
return (
defaultPort == p.getDefaultPort()
&& scheme.equalsIgnoreCase(p.getScheme())
&& secure == p.isSecure()
&& socketFactory.equals(p.getSocketFactory()));
} else {
return false;
}
}
代码示例来源:origin: commons-httpclient/commons-httpclient
/**
* Returns the URI of the HTTP method
*
* @return The URI
*
* @throws URIException If the URI cannot be created.
*
* @see org.apache.commons.httpclient.HttpMethod#getURI()
*/
public URI getURI() throws URIException {
StringBuffer buffer = new StringBuffer();
if (this.httphost != null) {
buffer.append(this.httphost.getProtocol().getScheme());
buffer.append("://");
buffer.append(this.httphost.getHostName());
int port = this.httphost.getPort();
if (port != -1 && port != this.httphost.getProtocol().getDefaultPort()) {
buffer.append(":");
buffer.append(port);
}
}
buffer.append(this.path);
if (this.queryString != null) {
buffer.append('?');
buffer.append(this.queryString);
}
String charset = getParams().getUriCharset();
return new URI(buffer.toString(), true, charset);
}
代码示例来源:origin: commons-httpclient/commons-httpclient
buf.append(connection.getHost());
if ((connection.getPort() != -1)
&& (connection.getPort() != protocol.getDefaultPort())
) {
buf.append(":");
代码示例来源:origin: commons-httpclient/commons-httpclient
if (conn.getProtocol().getDefaultPort() != port) {
host += (":" + port);
代码示例来源:origin: commons-httpclient/commons-httpclient
int port = conn.getPort();
if (port == -1) {
port = conn.getProtocol().getDefaultPort();
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-httpclient
/**
* Resolves the correct port for this protocol. Returns the given port if
* valid or the default port otherwise.
*
* @param port the port to be resolved
*
* @return the given port or the defaultPort
*/
public int resolvePort(int port) {
return port <= 0 ? getDefaultPort() : port;
}
代码示例来源:origin: org.apache.commons/httpclient
/**
* Resolves the correct port for this protocol. Returns the given port if
* valid or the default port otherwise.
*
* @param port the port to be resolved
*
* @return the given port or the defaultPort
*/
public int resolvePort(int port) {
return port <= 0 ? getDefaultPort() : port;
}
代码示例来源:origin: org.apache.commons/com.springsource.org.apache.commons.httpclient
/**
* Resolves the correct port for this protocol. Returns the given port if
* valid or the default port otherwise.
*
* @param port the port to be resolved
*
* @return the given port or the defaultPort
*/
public int resolvePort(int port) {
return port <= 0 ? getDefaultPort() : port;
}
代码示例来源:origin: org.wso2.commons-httpclient/commons-httpclient
/**
* Resolves the correct port for this protocol. Returns the given port if
* valid or the default port otherwise.
*
* @param port the port to be resolved
*
* @return the given port or the defaultPort
*/
public int resolvePort(int port) {
return port <= 0 ? getDefaultPort() : port;
}
代码示例来源:origin: stackoverflow.com
String scheme = "https";
Protocol baseHttps = Protocol.getProtocol(scheme);
int defaultPort = baseHttps.getDefaultPort();
ProtocolSocketFactory baseFactory = baseHttps.getSocketFactory();
ProtocolSocketFactory customFactory = new CustomHttpsSocketFactory(baseFactory);
Protocol customHttps = new Protocol(scheme, customFactory, defaultPort);
Protocol.registerProtocol(scheme, customHttps);
代码示例来源:origin: org.apache.commons/com.springsource.org.apache.commons.httpclient
/**
* Set the given host. Uses the default protocol("http") and its port.
*
* @param host The host(IP or DNS name).
*/
public synchronized void setHost(final String host) {
Protocol defaultProtocol = Protocol.getProtocol("http");
setHost(host, defaultProtocol.getDefaultPort(), defaultProtocol);
}
代码示例来源:origin: org.wso2.commons-httpclient/commons-httpclient
/**
* Set the given host. Uses the default protocol("http") and its port.
*
* @param host The host(IP or DNS name).
*/
public synchronized void setHost(final String host) {
Protocol defaultProtocol = Protocol.getProtocol("http");
setHost(host, defaultProtocol.getDefaultPort(), defaultProtocol);
}
代码示例来源:origin: org.apache.commons/httpclient
/**
* Set the given host. Uses the default protocol("http") and its port.
*
* @param host The host(IP or DNS name).
*/
public synchronized void setHost(final String host) {
Protocol defaultProtocol = Protocol.getProtocol("http");
setHost(host, defaultProtocol.getDefaultPort(), defaultProtocol);
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-httpclient
/**
* Set the given host. Uses the default protocol("http") and its port.
*
* @param host The host(IP or DNS name).
*/
public synchronized void setHost(final String host) {
Protocol defaultProtocol = Protocol.getProtocol("http");
setHost(host, defaultProtocol.getDefaultPort(), defaultProtocol);
}
代码示例来源:origin: org.mule.transports/mule-transport-http
private Protocol cloneProtocolKeepingSocketFactory(Protocol protocol)
{
Protocol original = getProtocol();
if (protocol.getScheme().equals(original.getScheme()))
{
// the protocol is the same, create a copy of it but keep the original socket factory
return new Protocol(protocol.getScheme(), original.getSocketFactory(),
protocol.getDefaultPort());
}
return protocol;
}
内容来源于网络,如有侵权,请联系作者删除!