org.apache.commons.httpclient.protocol.Protocol.unregisterProtocol()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(3.3k)|赞(0)|评价(0)|浏览(173)

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

Protocol.unregisterProtocol介绍

[英]Unregisters the protocol with the given ID.
[中]用给定的ID注销协议。

代码示例

代码示例来源:origin: edu.ucar/netcdf

static synchronized public void
registerProtocol(String protocol, int port, Protocol handler)
  throws IllegalArgumentException
{
  if(protocol == null)
    throw new IllegalArgumentException();
  if(port < 0) port = 0;
  // port == 0 is wildcard, so use standard Protocol registry
  if(port == 0) {// look to the standard protocol registry
    if(handler == null)
      Protocol.unregisterProtocol(protocol);
    else
      Protocol.registerProtocol(protocol, handler);
  } else {
    for(int i = 0;i < registry.size();i++) {
      ProtocolEntry entry = registry.get(i);
      if(!entry.protocol.equals(protocol)) continue;
      if(entry.port != port) continue;
      if(handler == null)
        registry.remove(i); //delete
      else
        entry.handler = handler; // replace
      return;
    }
    registry.add(new ProtocolEntry(protocol, port, handler));
  }
}

代码示例来源:origin: org.jvnet.hudson/htmlunit

/**
 * If set to <tt>true</tt>, the client will accept connections to any host, regardless of
 * whether they have valid certificates or not. This is especially useful when you are trying to
 * connect to a server with expired or corrupt certificates.
 *
 * @param useInsecureSSL whether or not to use insecure SSL
 * @throws GeneralSecurityException if a security error occurs
 */
public void setUseInsecureSSL(final boolean useInsecureSSL) throws GeneralSecurityException {
  if (useInsecureSSL) {
    final ProtocolSocketFactory factory = new InsecureSSLProtocolSocketFactory();
    final Protocol https = new Protocol("https", factory, 443);
    Protocol.registerProtocol("https", https);
  }
  else {
    Protocol.unregisterProtocol("https");
  }
}

代码示例来源:origin: org.jenkins-ci/htmlunit

/**
 * If set to <tt>true</tt>, the client will accept connections to any host, regardless of
 * whether they have valid certificates or not. This is especially useful when you are trying to
 * connect to a server with expired or corrupt certificates.
 *
 * @param useInsecureSSL whether or not to use insecure SSL
 * @throws GeneralSecurityException if a security error occurs
 */
public void setUseInsecureSSL(final boolean useInsecureSSL) throws GeneralSecurityException {
  if (useInsecureSSL) {
    final ProtocolSocketFactory factory = new InsecureSSLProtocolSocketFactory();
    final Protocol https = new Protocol("https", factory, 443);
    Protocol.registerProtocol("https", https);
  }
  else {
    Protocol.unregisterProtocol("https");
  }
}

代码示例来源:origin: net.disy.htmlunit/htmlunit

/**
 * If set to <tt>true</tt>, the client will accept connections to any host, regardless of
 * whether they have valid certificates or not. This is especially useful when you are trying to
 * connect to a server with expired or corrupt certificates.
 *
 * @param useInsecureSSL whether or not to use insecure SSL
 * @throws GeneralSecurityException if a security error occurs
 */
public void setUseInsecureSSL(final boolean useInsecureSSL) throws GeneralSecurityException {
  if (useInsecureSSL) {
    final ProtocolSocketFactory factory = new InsecureSSLProtocolSocketFactory();
    final Protocol https = new Protocol("https", factory, 443);
    Protocol.registerProtocol("https", https);
  }
  else {
    Protocol.unregisterProtocol("https");
  }
}

相关文章