org.apache.commons.httpclient.HttpURL类的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(10.7k)|赞(0)|评价(0)|浏览(127)

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

HttpURL介绍

[英]The HTTP URL.
[中]HTTP URL。

代码示例

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

/**
 * Construct a HTTP URL with a given relative URL string.
 *
 * @param base the base HttpURL
 * @param relative the relative HTTP URL string
 * @throws URIException If {@link #checkValid()} fails
 */
public HttpURL(HttpURL base, String relative) throws URIException {
  this(base, new HttpURL(relative));
}

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

/**
 * Construct a HTTP URL from a given string.
 *
 * @param original the HTTP URL string
 * @throws URIException If {@link #checkValid()} fails
 * @see #getDefaultProtocolCharset
 */
public HttpURL(String original) throws URIException {
  parseUriReference(original, false);
  checkValid();
}

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

/**
 * Get the user.
 *
 * @return the user name
 * @throws URIException If {@link #decode} fails
 */
public String getUser() throws URIException {
  char[] user = getRawUser();
  return (user == null) ? null : decode(user, getProtocolCharset());
}

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

/**
 * Set the password string.
 *
 * @param password the password string; could be null
 * @throws URIException encoding error or username missed
 */
public void setPassword(String password) throws URIException {
  setRawPassword((password == null) ? null : encode(password,
        allowed_within_userinfo, getProtocolCharset()));
}

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

/**
 * Set the raw-escaped user.
 *
 * @param escapedUser the raw-escaped user
 * @throws URIException escaped user not valid or user required
 */
public void setRawUser(char[] escapedUser) throws URIException {
  if (escapedUser == null || escapedUser.length == 0) {
    throw new URIException(URIException.PARSING, "user required");
  }
  if (!validate(escapedUser, within_userinfo)) {
    throw new URIException(URIException.ESCAPING,
        "escaped user not valid");
  }
  String username = new String(escapedUser);
  char[] rawPassword = getRawPassword();
  String password = rawPassword == null ? null : new String(rawPassword);
  String userinfo = username + ((password == null) ? "" : ":" + password);
  String hostname = new String(getRawHost());
  String hostport = (_port == -1) ? hostname : hostname + ":" + _port;
  String authority = userinfo + "@" + hostport;
  _userinfo = userinfo.toCharArray();
  _authority = authority.toCharArray();
  setURI();
}

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

/**
 * Set the raw-escaped password.
 *
 * @param escapedPassword the raw-escaped password; could be null
 * @throws URIException escaped password not valid or username missed
 */
public void setRawPassword(char[] escapedPassword) throws URIException {
  if (escapedPassword != null 
    && !validate(escapedPassword, within_userinfo)) {
    throw new URIException(URIException.ESCAPING,
      "escaped password not valid");
  }
  if (getRawUser() == null || getRawUser().length == 0) {
    throw new URIException(URIException.PARSING, "username required");
  }
  String username = new String(getRawUser());
  String password = escapedPassword == null ? null : new String(escapedPassword);
  // an emtpy string is allowed as a password
  String userinfo = username + ((password == null) ? "" : ":" + password);
  String hostname = new String(getRawHost());
  String hostport = (_port == -1) ? hostname : hostname + ":" + _port;
  String authority = userinfo + "@" + hostport;
  _userinfo = userinfo.toCharArray();
  _authority = authority.toCharArray();
  setURI();
}

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

/**
 * Get the password.
 *
 * @return the password
 * @throws URIException If {@link #decode(char[],String)} fails.
 */
public String getPassword() throws URIException {
  char[] password = getRawPassword();
  return (password == null) ? null : decode(password,
      getProtocolCharset());
}

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

/**
 * Set the user string.
 *
 * @param user the user string
 * @throws URIException user encoding error
 * @throws NullPointerException null user
 */
public void setUser(String user) throws URIException, NullPointerException {
  setRawUser(encode(user, allowed_within_userinfo, getProtocolCharset()));
}

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

/**
 * Set the user and password.
 *
 * @param user the user
 * @param password the password; could be null
 * @throws URIException encoding error or username missed
 * @throws NullPointerException null user
 */
public void setUserinfo(String user, String password) 
  throws URIException, NullPointerException {
  // set the charset to do escape encoding
  String charset = getProtocolCharset();
  setRawUserinfo(encode(user, within_userinfo, charset),
      (password == null) 
      ? null 
      : encode(password, within_userinfo, charset));
}

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

/**
 * Set the raw-escaped user and password.
 *
 * @param escapedUser the raw-escaped user
 * @param escapedPassword the raw-escaped password; could be null
 * @throws URIException escaped user not valid or user required; escaped
 * password not valid or username missed
 */
public void setRawUserinfo(char[] escapedUser, char[] escapedPassword)
  throws URIException {
  if (escapedUser == null || escapedUser.length == 0) {
    throw new URIException(URIException.PARSING, "user required");
  }
  if (!validate(escapedUser, within_userinfo) 
    || ((escapedPassword != null) 
    && !validate(escapedPassword, within_userinfo))) {
    throw new URIException(URIException.ESCAPING,
        "escaped userinfo not valid");
  }
  String username = new String(escapedUser);
  String password = (escapedPassword == null) 
    ? null : new String(escapedPassword);
  String userinfo = username + ((password == null) ? "" : ":" + password);
  String hostname = new String(getRawHost());
  String hostport = (_port == -1) ? hostname : hostname + ":" + _port;
  String authority = userinfo + "@" + hostport;
  _userinfo = userinfo.toCharArray();
  _authority = authority.toCharArray();
  setURI();
}

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

/**
 * Set the query as the name and value pair.
 *
 * @param queryName the query string.
 * @param queryValue the query string.
 * @throws URIException incomplete trailing escape pattern
 * Or unsupported character encoding
 * @throws NullPointerException null query
 * @see #encode
 */
public void setQuery(String queryName, String queryValue)
  throws URIException, NullPointerException {
  StringBuffer buff = new StringBuffer();
  // set the charset to do escape encoding
  String charset = getProtocolCharset();
  buff.append(encode(queryName, allowed_within_query, charset));
  buff.append('=');
  buff.append(encode(queryValue, allowed_within_query, charset));
  _query = buff.toString().toCharArray();
  setURI();
}

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

@Override
public boolean execute()
  throws Exception {
 if (_controllerHost == null) {
  _controllerHost = NetUtil.getHostAddress();
 }
 String stateValue = _state.toLowerCase();
 if (!stateValue.equals("enable") && !stateValue.equals("disable") && !stateValue.equals("drop")) {
  throw new IllegalArgumentException(
    "Invalid value for state: " + _state + "\n Value must be one of enable|disable|drop");
 }
 HttpClient httpClient = new HttpClient();
 HttpURL url = new HttpURL(_controllerHost, Integer.parseInt(_controllerPort), URI_TABLES_PATH + _tableName);
 url.setQuery("state", stateValue);
 GetMethod httpGet = new GetMethod(url.getEscapedURI());
 int status = httpClient.executeMethod(httpGet);
 if (status != 200) {
  throw new RuntimeException("Failed to change table state, error: " + httpGet.getResponseBodyAsString());
 }
 return true;
}

代码示例来源:origin: slide/slide-webdavlib

/**
 * Get the HttpURL except for userinfo.
 *
 * @return httpURL the http URL.
 */
public HttpURL getHttpURLExceptForUserInfo()
  throws URIException {
  return httpURL instanceof HttpsURL ? new HttpsURL(httpURL.getRawURI())
                    : new HttpURL(httpURL.getRawURI());
}

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

/**
 * Get the level above the this hierarchy level.
 *
 * @return the raw above hierarchy level
 * @throws URIException If {@link #getRawCurrentHierPath(char[])} fails.
 */
public char[] getRawAboveHierPath() throws URIException {
  char[] path = getRawCurrentHierPath();
  return (path == null || path.length == 0) ? rootPath : getRawCurrentHierPath(path);
}

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

/**
 * Get the escaped user
 *
 * @return the escaped user
 */
public String getEscapedUser() {
  char[] user = getRawUser();
  return (user == null) ? null : new String(user);
}

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

/**
 * Verify the valid class use for construction.
 *
 * @throws URIException the wrong scheme use
 */
protected void checkValid() throws URIException {
  // could be explicit protocol or undefined.
  if (!(equals(_scheme, DEFAULT_SCHEME) || _scheme == null)) {
    throw new URIException(URIException.PARSING, "wrong class use");
  }
}

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

/**
 * Construct a HTTP URL with a given relative URL.
 *
 * @param base the base HttpURL
 * @param relative the relative HttpURL
 * @throws URIException If {@link #checkValid()} fails
 */
public HttpURL(HttpURL base, HttpURL relative) throws URIException {
  super(base, relative);
  checkValid();
}

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

/**
 * Get the escaped password.
 *
 * @return the escaped password
 */
public String getEscapedPassword() {
  char[] password = getRawPassword();
  return (password == null) ? null : new String(password);
}

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

/**
 * Set the raw-escaped user.
 *
 * @param escapedUser the raw-escaped user
 * @throws URIException escaped user not valid or user required
 */
public void setRawUser(char[] escapedUser) throws URIException {
  if (escapedUser == null || escapedUser.length == 0) {
    throw new URIException(URIException.PARSING, "user required");
  }
  if (!validate(escapedUser, within_userinfo)) {
    throw new URIException(URIException.ESCAPING,
        "escaped user not valid");
  }
  String username = new String(escapedUser);
  char[] rawPassword = getRawPassword();
  String password = rawPassword == null ? null : new String(rawPassword);
  String userinfo = username + ((password == null) ? "" : ":" + password);
  String hostname = new String(getRawHost());
  String hostport = (_port == -1) ? hostname : hostname + ":" + _port;
  String authority = userinfo + "@" + hostport;
  _userinfo = userinfo.toCharArray();
  _authority = authority.toCharArray();
  setURI();
}

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

/**
 * Set the raw-escaped password.
 *
 * @param escapedPassword the raw-escaped password; could be null
 * @throws URIException escaped password not valid or username missed
 */
public void setRawPassword(char[] escapedPassword) throws URIException {
  if (escapedPassword != null 
    && !validate(escapedPassword, within_userinfo)) {
    throw new URIException(URIException.ESCAPING,
      "escaped password not valid");
  }
  if (getRawUser() == null || getRawUser().length == 0) {
    throw new URIException(URIException.PARSING, "username required");
  }
  String username = new String(getRawUser());
  String password = escapedPassword == null ? null : new String(escapedPassword);
  // an emtpy string is allowed as a password
  String userinfo = username + ((password == null) ? "" : ":" + password);
  String hostname = new String(getRawHost());
  String hostport = (_port == -1) ? hostname : hostname + ":" + _port;
  String authority = userinfo + "@" + hostport;
  _userinfo = userinfo.toCharArray();
  _authority = authority.toCharArray();
  setURI();
}

相关文章