org.apache.commons.httpclient.URI.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(7.0k)|赞(0)|评价(0)|浏览(106)

本文整理了Java中org.apache.commons.httpclient.URI.<init>()方法的一些代码示例,展示了URI.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。URI.<init>()方法的具体详情如下:
包路径:org.apache.commons.httpclient.URI
类名称:URI
方法名:<init>

URI.<init>介绍

[英]Create an instance as an internal use
[中]创建一个实例作为内部使用

代码示例

代码示例来源:origin: commons-httpclient/commons-httpclient

/**
 * Construct a general URI with the given relative URI string.
 *
 * @param base the base URI
 * @param relative the relative URI string
 * @throws URIException If the new URI cannot be created.
 * 
 * @deprecated Use #URI(URI, String, boolean)
 */
public URI(URI base, String relative) throws URIException {
  this(base, new URI(relative));
}

代码示例来源:origin: commons-httpclient/commons-httpclient

/**
 * Construct a general URI with the given relative URI string.
 *
 * @param base the base URI
 * @param relative the relative URI string
 * @param escaped <tt>true</tt> if URI character sequence is in escaped form. 
 *                <tt>false</tt> otherwise.
 *  
 * @throws URIException If the new URI cannot be created.
 * 
 * @since 3.0
 */
public URI(URI base, String relative, boolean escaped) throws URIException {
  this(base, new URI(relative, escaped));
}

代码示例来源:origin: commons-httpclient/commons-httpclient

public URI getURI() throws URIException {
  String charset = getParams().getUriCharset();
  return new URI(getPath(), true, charset);
}

代码示例来源: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

/**
 * Constructor specifying a URI.
 * It is responsibility of the caller to ensure that URI elements
 * (path & query parameters) are properly encoded (URL safe).
 *
 * @param uri either an absolute or relative URI. The URI is expected
 *            to be URL-encoded
 * 
 * @throws IllegalArgumentException when URI is invalid
 * @throws IllegalStateException when protocol of the absolute URI is not recognised
 */
public HttpMethodBase(String uri) 
  throws IllegalArgumentException, IllegalStateException {
  try {
    // create a URI and allow for null/empty uri values
    if (uri == null || uri.equals("")) {
      uri = "/";
    }
    String charset = getParams().getUriCharset();
    setURI(new URI(uri, true, charset));
  } catch (URIException e) {
    throw new IllegalArgumentException("Invalid uri '" 
      + uri + "': " + e.getMessage() 
    );
  }
}

代码示例来源:origin: apache/incubator-pinot

return new URI(SCHEME + segmentFileURI.toString(), /* boolean escaped */ false).toString();
} catch (InvalidControllerConfigException e) {
 LOGGER.error("Invalid controller config exception from instance {} for segment {}", instanceId, segmentName, e);

代码示例来源:origin: commons-httpclient/commons-httpclient

currentUri = new URI(
  this.conn.getProtocol().getScheme(),
  null,
redirectUri = new URI(location, true, charset);
    redirectUri = new URI(currentUri, redirectUri);

代码示例来源:origin: elastic/elasticsearch-hadoop

throw new EsHadoopInvalidRequest("URI has query portion on it: [" + uri + "]");
http.setURI(new URI(escapeUri(uri.toString(), sslEnabled), false));

代码示例来源:origin: elastic/elasticsearch-hadoop

hostConfig.setHost(new URI(escapeUri(host, sslEnabled), false));
} catch (IOException ex) {
  throw new EsHadoopTransportException("Invalid target URI " + host, ex);

代码示例来源:origin: apache/cloudstack

throw new CloudRuntimeException("Call failed: Bad redirect from UCS Manager");
post.setURI(new URI(redirectLocation));
result = client.executeMethod(post);

代码示例来源:origin: foxinmy/weixin4j

org.apache.commons.httpclient.HttpMethod httpMethod = null;
try {
  URI uri = new URI(request.getURI().toString(), false,
      Consts.UTF_8.name());
  if (method == HttpMethod.GET) {

代码示例来源:origin: org.apache.commons/com.springsource.org.apache.commons.httpclient

/**
 * Construct a general URI with the given relative URI string.
 *
 * @param base the base URI
 * @param relative the relative URI string
 * @throws URIException If the new URI cannot be created.
 * 
 * @deprecated Use #URI(URI, String, boolean)
 */
public URI(URI base, String relative) throws URIException {
  this(base, new URI(relative));
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-httpclient

/**
 * Construct a general URI with the given relative URI string.
 *
 * @param base the base URI
 * @param relative the relative URI string
 * @throws URIException If the new URI cannot be created.
 * 
 * @deprecated Use #URI(URI, String, boolean)
 */
public URI(URI base, String relative) throws URIException {
  this(base, new URI(relative));
}

代码示例来源:origin: org.wso2.commons-httpclient/commons-httpclient

/**
 * Construct a general URI with the given relative URI string.
 *
 * @param base the base URI
 * @param relative the relative URI string
 * @throws URIException If the new URI cannot be created.
 * 
 * @deprecated Use #URI(URI, String, boolean)
 */
public URI(URI base, String relative) throws URIException {
  this(base, new URI(relative));
}

代码示例来源:origin: org.zaproxy/zap

private URI createURI(URI base, String dir, String file) throws URIException {
  if (!dir.startsWith("/")) {
    dir = "/" + dir;
  }
  
  if (!file.startsWith("/") && !dir.endsWith("/")) {
    file = "/" + file;
  }
      
  String path = dir + file;
  URI uri = new URI(base, path, true);
  return uri;
}

代码示例来源:origin: org.zaproxy/zap

public URI getCheatSheetKeyURI() throws URIException, NullPointerException {
  return new URI(API.getInstance().getBaseURL(
      API.Format.OTHER, PREFIX, API.RequestType.other, OTHER_CHEETSHEET_KEY_ORDER, false), 
      true);
}

代码示例来源:origin: org.zaproxy/zap

public URI getCheatSheetActionURI() throws URIException, NullPointerException {
  return new URI(API.getInstance().getBaseURL(
      API.Format.OTHER, PREFIX, API.RequestType.other, OTHER_CHEETSHEET_ACTION_ORDER, false), 
      true);
}

代码示例来源:origin: mguessan/davmail

protected String encodeAndFixUrl(String url) throws URIException {
  String originalUrl = URIUtil.encodePath(url);
  if (restoreHostName && originalUrl.startsWith("http")) {
    String targetPath = new URI(originalUrl, true).getEscapedPath();
    originalUrl = getEscapedUrlFromPath(targetPath);
  }
  return originalUrl;
}

代码示例来源:origin: mguessan/davmail

protected String getEscapedUrlFromPath(String escapedPath) throws URIException {
  URI uri = new URI(httpClient.getHostConfiguration().getHostURL(), true);
  uri.setEscapedPath(escapedPath);
  return uri.getEscapedURI();
}

代码示例来源:origin: com.atlassian.jira.plugins/jira-dvcs-connector-api

@Override
public void addAuthentication(HttpMethod forMethod, HttpClient forClient) {
  try {
    forMethod.addRequestHeader("Authorization", "token " + accessToken);
    String url = forMethod.getURI().toString();
    String separator = url.contains("?") ? "&" : "?";
    url += separator + "access_token=" + getAccessToken();
    forMethod.setURI(new URI(url, true));
  } catch (URIException e) {
    throw new SourceControlException("Failed to decode/encode given URI. " + e.getMessage(), e);
  }
}

相关文章