Search in sources :

Example 96 with HttpClient

use of org.eclipse.jetty.client.HttpClient in project rpki-validator-3 by RIPE-NCC.

the class HttpRrdpClient method postConstruct.

@PostConstruct
public void postConstruct() throws Exception {
    final SslContextFactory sslContextFactory = new SslContextFactory();
    sslContextFactory.setTrustAll(trustAllTlsCertificates);
    httpClient = new HttpClient(sslContextFactory);
    httpClient.start();
}
Also used : SslContextFactory(org.eclipse.jetty.util.ssl.SslContextFactory) HttpClient(org.eclipse.jetty.client.HttpClient) PostConstruct(javax.annotation.PostConstruct)

Example 97 with HttpClient

use of org.eclipse.jetty.client.HttpClient in project java-docs-samples by GoogleCloudPlatform.

the class AsyncRestServlet method init.

@Override
public void init(ServletConfig servletConfig) throws ServletException {
    super.init(servletConfig);
    SslContextFactory sslContextFactory = new SslContextFactory();
    client = new HttpClient(sslContextFactory);
    try {
        client.start();
    } catch (Exception e) {
        throw new ServletException(e);
    }
}
Also used : ServletException(javax.servlet.ServletException) SslContextFactory(org.eclipse.jetty.util.ssl.SslContextFactory) HttpClient(org.eclipse.jetty.client.HttpClient) ServletException(javax.servlet.ServletException) IOException(java.io.IOException)

Example 98 with HttpClient

use of org.eclipse.jetty.client.HttpClient in project learning-spark by databricks.

the class BasicMapPartitions method main.

public static void main(String[] args) throws Exception {
    String master;
    if (args.length > 0) {
        master = args[0];
    } else {
        master = "local";
    }
    JavaSparkContext sc = new JavaSparkContext(master, "basicmappartitions", System.getenv("SPARK_HOME"), System.getenv("JARS"));
    JavaRDD<String> rdd = sc.parallelize(Arrays.asList("KK6JKQ", "Ve3UoW", "kk6jlk", "W6BB"));
    JavaRDD<String> result = rdd.mapPartitions(new FlatMapFunction<Iterator<String>, String>() {

        public Iterable<String> call(Iterator<String> input) {
            ArrayList<String> content = new ArrayList<String>();
            ArrayList<ContentExchange> cea = new ArrayList<ContentExchange>();
            HttpClient client = new HttpClient();
            try {
                client.start();
                while (input.hasNext()) {
                    ContentExchange exchange = new ContentExchange(true);
                    exchange.setURL("http://qrzcq.com/call/" + input.next());
                    client.send(exchange);
                    cea.add(exchange);
                }
                for (ContentExchange exchange : cea) {
                    exchange.waitForDone();
                    content.add(exchange.getResponseContent());
                }
            } catch (Exception e) {
            }
            return content;
        }
    });
    System.out.println(StringUtils.join(result.collect(), ","));
}
Also used : ArrayList(java.util.ArrayList) HttpClient(org.eclipse.jetty.client.HttpClient) Iterator(java.util.Iterator) JavaSparkContext(org.apache.spark.api.java.JavaSparkContext) ContentExchange(org.eclipse.jetty.client.ContentExchange)

Example 99 with HttpClient

use of org.eclipse.jetty.client.HttpClient in project dropwizard by dropwizard.

the class AbstractHttp2Test method setUp.

@BeforeEach
void setUp() throws Exception {
    sslContextFactory.setTrustStorePath(resourceFilePath("stores/http2_client.jts"));
    sslContextFactory.setTrustStorePassword("http2_client");
    sslContextFactory.start();
    http1Client = new HttpClient(sslContextFactory);
    http1Client.start();
    http2Client = new HttpClient(new HttpClientTransportOverHTTP2(new HTTP2Client()), sslContextFactory);
    http2Client.start();
}
Also used : HttpClientTransportOverHTTP2(org.eclipse.jetty.http2.client.http.HttpClientTransportOverHTTP2) HttpClient(org.eclipse.jetty.client.HttpClient) HTTP2Client(org.eclipse.jetty.http2.client.HTTP2Client) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 100 with HttpClient

use of org.eclipse.jetty.client.HttpClient in project cayenne by apache.

the class JettyHttpClientConnectionProvider method createJettyHttpRopConnector.

protected JettyHttpROPConnector createJettyHttpRopConnector() {
    String url = runtimeProperties.get(ClientConstants.ROP_SERVICE_URL_PROPERTY);
    if (url == null) {
        throw new ConfigurationException("No property defined for '%s', can't initialize connection", ClientConstants.ROP_SERVICE_URL_PROPERTY);
    }
    String username = runtimeProperties.get(ClientConstants.ROP_SERVICE_USERNAME_PROPERTY);
    long readTimeout = runtimeProperties.getLong(ClientConstants.ROP_SERVICE_TIMEOUT_PROPERTY, -1L);
    HttpClient httpClient = initJettyHttpClient();
    addBasicAuthentication(httpClient, url, username);
    JettyHttpROPConnector result = new JettyHttpROPConnector(httpClient, url, username);
    if (readTimeout > 0) {
        result.setReadTimeout(readTimeout);
    }
    return result;
}
Also used : ConfigurationException(org.apache.cayenne.ConfigurationException) HttpClient(org.eclipse.jetty.client.HttpClient) JettyHttpROPConnector(org.apache.cayenne.rop.http.JettyHttpROPConnector)

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