Search in sources :

Example 71 with HttpClient

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;
    }
}
Also used : HttpClient(org.eclipse.jetty.client.HttpClient) SynchronousDelegateProducer(org.apache.camel.impl.SynchronousDelegateProducer)

Example 72 with HttpClient

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;
}
Also used : ResolveEndpointFailedException(org.apache.camel.ResolveEndpointFailedException) HashMap(java.util.HashMap) HttpClient(org.eclipse.jetty.client.HttpClient)

Example 73 with 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();
    }
}
Also used : NodeInfo(io.airlift.node.NodeInfo) HttpClient(org.eclipse.jetty.client.HttpClient) ExecutionException(java.util.concurrent.ExecutionException) URI(java.net.URI) Test(org.testng.annotations.Test)

Example 74 with HttpClient

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();
    }
}
Also used : NodeInfo(io.airlift.node.NodeInfo) HttpClient(org.eclipse.jetty.client.HttpClient) ExecutionException(java.util.concurrent.ExecutionException) URI(java.net.URI) Test(org.testng.annotations.Test)

Example 75 with HttpClient

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());
}
Also used : ServiceNode(com.bigdata.rdf.sparql.ast.service.ServiceNode) BigdataValueFactory(com.bigdata.rdf.model.BigdataValueFactory) DummyConstantNode(com.bigdata.rdf.sparql.ast.DummyConstantNode) HttpClient(org.eclipse.jetty.client.HttpClient) JoinGroupNode(com.bigdata.rdf.sparql.ast.JoinGroupNode) BigdataServiceCall(com.bigdata.rdf.sparql.ast.service.BigdataServiceCall)

Aggregations

HttpClient (org.eclipse.jetty.client.HttpClient)197 ContentResponse (org.eclipse.jetty.client.api.ContentResponse)102 Test (org.junit.Test)94 Request (org.eclipse.jetty.client.api.Request)53 HttpServletRequest (javax.servlet.http.HttpServletRequest)42 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)40 Test (org.testng.annotations.Test)34 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)24 QueuedThreadPool (org.eclipse.jetty.util.thread.QueuedThreadPool)19 CloudStore (com.yahoo.athenz.zts.store.CloudStore)17 SslContextFactory (org.eclipse.jetty.util.ssl.SslContextFactory)16 HttpCertSigner (com.yahoo.athenz.zts.cert.impl.HttpCertSigner)14 HttpCertSignerFactory (com.yahoo.athenz.zts.cert.impl.HttpCertSignerFactory)14 URI (java.net.URI)11 HTTP2Client (org.eclipse.jetty.http2.client.HTTP2Client)11 ExecutionException (java.util.concurrent.ExecutionException)8 HttpProxy (org.eclipse.jetty.client.HttpProxy)8 StacklessLogging (org.eclipse.jetty.util.log.StacklessLogging)8 IOException (java.io.IOException)7 CountDownLatch (java.util.concurrent.CountDownLatch)7