类org.apache.http.conn.UnsupportedSchemeException源码实例Demo

下面列出了怎么用org.apache.http.conn.UnsupportedSchemeException的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: lavaplayer   文件: ExtendedConnectionOperator.java
@Override
public void upgrade(ManagedHttpClientConnection connection, HttpHost host, HttpContext context) throws IOException {
  ConnectionSocketFactory socketFactory = getSocketFactory(host, HttpClientContext.adapt(context));

  if (!(socketFactory instanceof LayeredConnectionSocketFactory)) {
    throw new UnsupportedSchemeException(host.getSchemeName() +
        " protocol does not support connection upgrade");
  }

  LayeredConnectionSocketFactory layeredFactory = (LayeredConnectionSocketFactory) socketFactory;

  Socket socket = connection.getSocket();
  int port = this.schemePortResolver.resolve(host);
  socket = layeredFactory.createLayeredSocket(socket, host.getHostName(), port, context);

  connection.bind(socket);
}
 
源代码2 项目: quarkus   文件: Substitute_RestClient.java
protected HttpHost getKey(final HttpHost host) {
    if (host.getPort() <= 0) {
        final int port;
        try {
            port = schemePortResolver.resolve(host);
        } catch (final UnsupportedSchemeException ignore) {
            return host;
        }
        return new HttpHost(host.getHostName(), port, host.getSchemeName());
    } else {
        return host;
    }
}
 
源代码3 项目: lavaplayer   文件: ExtendedConnectionOperator.java
private ConnectionSocketFactory getSocketFactory(HttpHost host, HttpContext context) throws IOException {
  Lookup<ConnectionSocketFactory> registry = getSocketFactoryRegistry(context);
  ConnectionSocketFactory socketFactory = registry.lookup(host.getSchemeName());

  if (socketFactory == null) {
    throw new UnsupportedSchemeException(host.getSchemeName() + " protocol is not supported");
  }

  return socketFactory;
}
 
源代码4 项目: lavaplayer   文件: AbstractRoutePlanner.java
@Override
public HttpRoute determineRoute(final HttpHost host, final HttpRequest request, final HttpContext context) throws HttpException {
  Args.notNull(request, "Request");
  if (host == null) {
    throw new ProtocolException("Target host is not specified");
  }
  final HttpClientContext clientContext = HttpClientContext.adapt(context);
  final RequestConfig config = clientContext.getRequestConfig();
  int remotePort;
  if (host.getPort() <= 0) {
    try {
      remotePort = schemePortResolver.resolve(host);
    } catch (final UnsupportedSchemeException e) {
      throw new HttpException(e.getMessage());
    }
  } else
    remotePort = host.getPort();

  final Tuple<Inet4Address, Inet6Address> remoteAddresses = IpAddressTools.getRandomAddressesFromHost(host);
  final Tuple<InetAddress, InetAddress> addresses = determineAddressPair(remoteAddresses);

  final HttpHost target = new HttpHost(addresses.r, host.getHostName(), remotePort, host.getSchemeName());
  final HttpHost proxy = config.getProxy();
  final boolean secure = target.getSchemeName().equalsIgnoreCase("https");
  clientContext.setAttribute(CHOSEN_IP_ATTRIBUTE, addresses.l);
  log.debug("Setting route context attribute to {}", addresses.l);
  if (proxy == null) {
    return new HttpRoute(target, addresses.l, secure);
  } else {
    return new HttpRoute(target, addresses.l, proxy, secure);
  }
}
 
源代码5 项目: Bastion   文件: TestWithProxiedEmbeddedServer.java
private static DefaultSchemePortResolver prepareSchemePortResolver() {
    return new DefaultSchemePortResolver() {
        @Override
        public int resolve(HttpHost host) throws UnsupportedSchemeException {
            if (host.getHostName().equalsIgnoreCase("sushi-shop.test")) {
                return 9876;
            } else {
                return super.resolve(host);
            }
        }
    };
}
 
源代码6 项目: vespa   文件: VespaHttpClientBuilder.java
private HttpHost resolveTarget(HttpHost host) throws HttpException {
    try {
        String originalScheme = host.getSchemeName();
        String scheme = originalScheme.equalsIgnoreCase("http") ? "https" : originalScheme;
        int port = DefaultSchemePortResolver.INSTANCE.resolve(host);
        return new HttpHost(host.getHostName(), port, scheme);
    } catch (UnsupportedSchemeException e) {
        throw new HttpException(e.getMessage(), e);
    }
}
 
源代码7 项目: SolRDF   文件: IntegrationTestSupertypeLayer.java
/**
 * Initilisation procedure for this test case.
 * 
 * @throws UnableToBuildSolRDFClientException in case the client cannot be built.
 * @throws Exception in case of Solr startup failure.
 */
@BeforeClass
public static void initITTest() {
	System.setProperty("tests.asserts", "false");	
	System.setProperty("jetty.port", "8080");
	System.setProperty("solr.core.name", "store");
	System.setProperty("solr.data.dir", initCoreDataDir.getAbsolutePath());
		
	try {
		SOLR = createJetty(
				"target/solrdf-integration-tests-1.1-dev/solrdf",
				JettyConfig.builder()
					.setPort(8080)
					.setContext("/solr")
					.stopAtShutdown(true)
					.build());		
		
		final HttpClient httpClient = HttpClientBuilder.create()
				.setRoutePlanner(
						new DefaultRoutePlanner(
								new SchemePortResolver() {
									@Override
									public int resolve(final HttpHost host) throws UnsupportedSchemeException {
										return SOLR.getLocalPort();
									}
								})).build();
		
		
		SOLRDF_CLIENT = SolRDF.newBuilder()
	              .withEndpoint("http://127.0.0.1:8080/solr/store")
	              .withGraphStoreProtocolEndpointPath("/rdf-graph-store")
	              .withHttpClient(httpClient)
	              .withSPARQLEndpointPath("/sparql")
	              .build();
		
		PLAIN_SOLR_CLIENT = new HttpSolrClient(SOLR_URI);
	} catch (final Exception exception) {
		throw new RuntimeException(exception);
	}
}
 
 类所在包
 类方法
 同包方法