use of org.eclipse.jetty.client.HttpClient in project camel by apache.
the class JettyHttpEndpoint method createProducer.
@Override
public Producer createProducer() throws Exception {
JettyHttpProducer answer = new JettyHttpProducer(this);
if (httpClient != null) {
// use shared client, and ensure its started so we can use it
httpClient.start();
answer.setSharedClient(httpClient);
answer.setBinding(getJettyBinding(httpClient));
} else {
HttpClient httpClient = createJettyHttpClient();
answer.setClient(httpClient);
answer.setBinding(getJettyBinding(httpClient));
}
if (isSynchronous()) {
return new SynchronousDelegateProducer(answer);
} else {
return answer;
}
}
use of org.eclipse.jetty.client.HttpClient in project camel by apache.
the class JettyHttpEndpoint method createJettyHttpClient.
protected HttpClient createJettyHttpClient() throws Exception {
// create a new client
// thread pool min/max from endpoint take precedence over from component
Integer min = httpClientMinThreads != null ? httpClientMinThreads : getComponent().getHttpClientMinThreads();
Integer max = httpClientMaxThreads != null ? httpClientMaxThreads : getComponent().getHttpClientMaxThreads();
HttpClient httpClient = getComponent().createHttpClient(this, min, max, sslContextParameters);
// set optional http client parameters
if (httpClientParameters != null) {
// copy parameters as we need to re-use them again if creating a new producer later
Map<String, Object> params = new HashMap<String, Object>(httpClientParameters);
// Can not be set on httpClient for jetty 9
params.remove("timeout");
IntrospectionSupport.setProperties(httpClient, params);
// validate we could set all parameters
if (params.size() > 0) {
throw new ResolveEndpointFailedException(getEndpointUri(), "There are " + params.size() + " parameters that couldn't be set on the endpoint." + " Check the uri if the parameters are spelt correctly and that they are properties of the endpoint." + " Unknown parameters=[" + params + "]");
}
}
return httpClient;
}
use of org.eclipse.jetty.client.HttpClient in project airlift by airlift.
the class TestHttpServerCipher method testExcludedCipher.
@Test
public void testExcludedCipher() throws Exception {
HttpServerConfig config = createHttpServerConfig().setHttpsExcludedCipherSuites(CIPHER_1 + "," + CIPHER_2);
NodeInfo nodeInfo = new NodeInfo("test");
HttpServerInfo httpServerInfo = new HttpServerInfo(config, nodeInfo);
HttpServer server = createServer(nodeInfo, httpServerInfo, config);
try {
server.start();
URI httpsUri = httpServerInfo.getHttpsUri();
// should succeed because all ciphers accepted
HttpClient httpClient = createClientIncludeCiphers();
httpClient.GET(httpsUri);
httpClient = createClientIncludeCiphers(CIPHER_1, CIPHER_2);
try {
httpClient.GET(httpsUri);
fail("SSL handshake should fail because client included only ciphers the server excluded");
} catch (ExecutionException e) {
// expected
}
} finally {
server.stop();
}
}
use of org.eclipse.jetty.client.HttpClient in project airlift by airlift.
the class TestHttpServerCipher method testIncludedCipher.
@Test
public void testIncludedCipher() throws Exception {
HttpServerConfig config = createHttpServerConfig().setHttpsIncludedCipherSuites(CIPHER_1 + "," + CIPHER_2);
NodeInfo nodeInfo = new NodeInfo("test");
HttpServerInfo httpServerInfo = new HttpServerInfo(config, nodeInfo);
HttpServer server = createServer(nodeInfo, httpServerInfo, config);
try {
server.start();
URI httpsUri = httpServerInfo.getHttpsUri();
// should succeed because only one of the two allowed certificate is excluded
HttpClient httpClient = createClientIncludeCiphers(CIPHER_1);
httpClient.GET(httpsUri);
// should succeed because only one of the two allowed certificate is excluded
httpClient = createClientIncludeCiphers(CIPHER_2);
httpClient.GET(httpsUri);
httpClient = createClientIncludeCiphers(CIPHER_3);
try {
httpClient.GET(httpsUri);
fail("SSL handshake should fail because client included only ciphers the server didn't include");
} catch (ExecutionException e) {
// expected
}
} finally {
server.stop();
}
}
use of org.eclipse.jetty.client.HttpClient in project wikidata-query-rdf by wikimedia.
the class GeoService method create.
@Override
public BigdataServiceCall create(ServiceCallCreateParams params, ServiceParams serviceParams) {
if (params == null)
throw new IllegalArgumentException();
final JoinGroupNode newGroup = buildServiceNode(params, serviceParams);
final BigdataValueFactory vf = params.getTripleStore().getValueFactory();
ServiceNode newServiceNode = new ServiceNode(new DummyConstantNode(vf.asValue(GeoSpatial.SEARCH)), newGroup);
// Transfer hints
newServiceNode.setQueryHints(params.getServiceNode().getQueryHints());
// Call delegate service
HttpClient client = params.getClientConnectionManager();
return (BigdataServiceCall) ServiceRegistry.getInstance().toServiceCall(params.getTripleStore(), client, GeoSpatial.SEARCH, newServiceNode, params.getStats());
}
Aggregations