本文整理了Java中org.apache.commons.httpclient.URI.getPort()
方法的一些代码示例,展示了URI.getPort()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。URI.getPort()
方法的具体详情如下:
包路径:org.apache.commons.httpclient.URI
类名称:URI
方法名:getPort
[英]Get the port. In order to get the specfic default port, the specific protocol-supported class extended from the URI class should be used. It has the server-based naming authority.
[中]去港口。为了获得特定的默认端口,应该使用从URI类扩展而来的特定协议支持的类。它具有基于服务器的命名权限。
代码示例来源:origin: commons-httpclient/commons-httpclient
/**
* URI constructor for HttpHost.
*
* @param uri the URI.
*/
public HttpHost(final URI uri) throws URIException {
this(uri.getHost(), uri.getPort(), Protocol.getProtocol(uri.getScheme()));
}
代码示例来源:origin: commons-httpclient/commons-httpclient
/**
* Sets the protocol, host and port from the given URI.
* @param uri the URI.
*/
public synchronized void setHost(final URI uri) {
try {
setHost(uri.getHost(), uri.getPort(), uri.getScheme());
} catch (URIException e) {
throw new IllegalArgumentException(e.toString());
}
}
代码示例来源:origin: apache/incubator-pinot
getMethod = completionService.take().get();
URI uri = getMethod.getURI();
String instance = endpointsToServers.get(uri.getHost() + ":" + uri.getPort());
if (getMethod.getStatusCode() >= 300) {
LOGGER.error("Server: {} returned error: {}", instance, getMethod.getStatusCode());
代码示例来源:origin: org.zaproxy/zap
private static String createBaseUri(org.apache.commons.httpclient.URI uri) throws URIException {
StringBuilder baseUriBuilder = new StringBuilder();
baseUriBuilder.append(uri.getScheme()).append("://").append(uri.getHost());
if (uri.getPort() != -1) {
baseUriBuilder.append(':').append(uri.getPort());
}
return baseUriBuilder.toString();
}
代码示例来源:origin: org.zaproxy/zap
public static String getHostName(URI uri) throws URIException {
StringBuilder host = new StringBuilder();
String scheme = uri.getScheme().toLowerCase();
host.append(scheme).append("://").append(uri.getHost());
int port = uri.getPort();
if (port != -1 &&
((port == 80 && !"http".equals(scheme)) ||
(port == 443 && !"https".equals(scheme) ||
(port != 80 && port != 443)))) {
host.append(":").append(port);
}
return host.toString();
}
代码示例来源:origin: org.zaproxy/zap
private String getHostName(URI uri) throws URIException {
StringBuilder host = new StringBuilder();
String scheme = uri.getScheme();
if (scheme == null) {
scheme = "http";
} else {
scheme = scheme.toLowerCase();
}
host.append(scheme).append("://").append(uri.getHost());
int port = uri.getPort();
if (port != -1 &&
((port == 80 && !"http".equals(scheme)) ||
(port == 443 && !"https".equals(scheme) ||
(port != 80 && port != 443)))) {
host.append(":").append(port);
}
return host.toString();
}
代码示例来源:origin: org.apache.commons/com.springsource.org.apache.commons.httpclient
/**
* Sets the protocol, host and port from the given URI.
* @param uri the URI.
*/
public synchronized void setHost(final URI uri) {
try {
setHost(uri.getHost(), uri.getPort(), uri.getScheme());
} catch (URIException e) {
throw new IllegalArgumentException(e.toString());
}
}
代码示例来源:origin: org.apache.commons/com.springsource.org.apache.commons.httpclient
/**
* URI constructor for HttpHost.
*
* @param uri the URI.
*/
public HttpHost(final URI uri) throws URIException {
this(uri.getHost(), uri.getPort(), Protocol.getProtocol(uri.getScheme()));
}
代码示例来源:origin: org.alfresco/alfresco-core
@SuppressWarnings("unused")
public synchronized void setHost(URI uri)
{
try {
setHost(uri.getHost(), uri.getPort(), uri.getScheme());
} catch(URIException e) {
throw new IllegalArgumentException(e.toString());
}
}
}
代码示例来源:origin: org.wso2.commons-httpclient/commons-httpclient
/**
* Sets the protocol, host and port from the given URI.
* @param uri the URI.
*/
public synchronized void setHost(final URI uri) {
try {
setHost(uri.getHost(), uri.getPort(), uri.getScheme());
} catch (URIException e) {
throw new IllegalArgumentException(e.toString());
}
}
代码示例来源:origin: org.apache.commons/httpclient
/**
* URI constructor for HttpHost.
*
* @param uri the URI.
*/
public HttpHost(final URI uri) throws URIException {
this(uri.getHost(), uri.getPort(), Protocol.getProtocol(uri.getScheme()));
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-httpclient
/**
* URI constructor for HttpHost.
*
* @param uri the URI.
*/
public HttpHost(final URI uri) throws URIException {
this(uri.getHost(), uri.getPort(), Protocol.getProtocol(uri.getScheme()));
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-httpclient
/**
* Sets the protocol, host and port from the given URI.
* @param uri the URI.
*/
public synchronized void setHost(final URI uri) {
try {
setHost(uri.getHost(), uri.getPort(), uri.getScheme());
} catch (URIException e) {
throw new IllegalArgumentException(e.toString());
}
}
代码示例来源:origin: org.wso2.commons-httpclient/commons-httpclient
/**
* URI constructor for HttpHost.
*
* @param uri the URI.
*/
public HttpHost(final URI uri) throws URIException {
this(uri.getHost(), uri.getPort(), Protocol.getProtocol(uri.getScheme()));
}
代码示例来源:origin: org.apache.commons/httpclient
/**
* Sets the protocol, host and port from the given URI.
* @param uri the URI.
*/
public synchronized void setHost(final URI uri) {
try {
setHost(uri.getHost(), uri.getPort(), uri.getScheme());
} catch (URIException e) {
throw new IllegalArgumentException(e.toString());
}
}
代码示例来源:origin: deas/alfresco
@SuppressWarnings("unused")
public synchronized void setHost(URI uri)
{
try {
setHost(uri.getHost(), uri.getPort(), uri.getScheme());
} catch(URIException e) {
throw new IllegalArgumentException(e.toString());
}
}
}
代码示例来源:origin: org.zaproxy/zap
/**
* Adds a file seed, with the given file name, at the root of the base URI.
* <p>
* For example, with base URI as {@code http://example.com/some/path/file.html} and file name as {@code sitemap.xml} it's
* added the seed {@code http://example.com/sitemap.xml}.
*
* @param baseUri the base URI.
* @param fileName the file name.
*/
private void addRootFileSeed(URI baseUri, String fileName) {
String seed = buildUri(baseUri.getScheme(), baseUri.getRawHost(), baseUri.getPort(), "/" + fileName);
try {
this.seedList.add(new URI(seed, true));
} catch (Exception e) {
log.warn("Error while creating [" + fileName + "] seed: " + seed, e);
}
}
代码示例来源:origin: org.zaproxy/zap
@Override
public synchronized void setHost(URI uri) {
try {
setHost(new HttpHost(uri.getHost(), uri.getPort(), getProtocol()));
} catch (URIException e) {
throw new IllegalArgumentException(e.toString());
}
};
};
代码示例来源:origin: org.zaproxy/zap
/**
* Sets the URI of this request header.
*
* @param uri the new request URI
* @throws URIException if an error occurred while setting the request URI
*/
public void setURI(URI uri) throws URIException {
if (uri.getScheme() == null || uri.getScheme().equals("")) {
mUri = new URI(HTTP + "://" + getHeader(HOST) + "/" + mUri.toString(), true);
} else {
mUri = uri;
}
if (uri.getScheme().equalsIgnoreCase(HTTPS)) {
mIsSecure = true;
} else {
mIsSecure = false;
}
setHostPort(mUri.getPort());
}
代码示例来源:origin: mguessan/davmail
protected void fixClientHost(HttpMethod method) {
try {
// update client host, workaround for Exchange 2003 mailbox with an Exchange 2007 frontend
URI currentUri = method.getURI();
if (currentUri != null && currentUri.getHost() != null && currentUri.getScheme() != null) {
httpClient.getHostConfiguration().setHost(currentUri.getHost(), currentUri.getPort(), currentUri.getScheme());
}
} catch (URIException e) {
LOGGER.warn("Unable to update http client host:" + e.getMessage(), e);
}
}
内容来源于网络,如有侵权,请联系作者删除!