Search in sources :

Example 66 with HttpClient

use of org.eclipse.jetty.client.HttpClient in project druid by druid-io.

the class AsyncQueryForwardingServlet method createHttpClient.

@Override
protected HttpClient createHttpClient() throws ServletException {
    HttpClient client = super.createHttpClient();
    // override timeout set in ProxyServlet.createHttpClient
    setTimeout(httpClientConfig.getReadTimeout().getMillis());
    return client;
}
Also used : HttpClient(org.eclipse.jetty.client.HttpClient)

Example 67 with HttpClient

use of org.eclipse.jetty.client.HttpClient in project elastic-job by dangdangdotcom.

the class RestfulServerTest method sentRequest.

private static ContentExchange sentRequest(final String content) throws Exception {
    HttpClient httpClient = new HttpClient();
    try {
        httpClient.start();
        ContentExchange result = new ContentExchange();
        result.setMethod("POST");
        result.setRequestContentType(MediaType.APPLICATION_JSON);
        result.setRequestContent(new ByteArrayBuffer(content.getBytes("UTF-8")));
        httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
        result.setURL(URL);
        httpClient.send(result);
        result.waitForDone();
        return result;
    } finally {
        httpClient.stop();
    }
}
Also used : HttpClient(org.eclipse.jetty.client.HttpClient) ContentExchange(org.eclipse.jetty.client.ContentExchange) ByteArrayBuffer(org.eclipse.jetty.io.ByteArrayBuffer)

Example 68 with HttpClient

use of org.eclipse.jetty.client.HttpClient in project elastic-job by dangdangdotcom.

the class RestfulTestsUtil method sentGetRequest.

public static String sentGetRequest(final String url) throws Exception {
    HttpClient httpClient = new HttpClient();
    try {
        httpClient.start();
        ContentExchange contentExchange = new ContentExchange();
        contentExchange.setMethod("GET");
        contentExchange.setRequestContentType(MediaType.APPLICATION_JSON);
        httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
        contentExchange.setURL(url);
        httpClient.send(contentExchange);
        contentExchange.waitForDone();
        return contentExchange.getResponseContent();
    } finally {
        httpClient.stop();
    }
}
Also used : HttpClient(org.eclipse.jetty.client.HttpClient) ContentExchange(org.eclipse.jetty.client.ContentExchange)

Example 69 with HttpClient

use of org.eclipse.jetty.client.HttpClient in project elastic-job by dangdangdotcom.

the class RestfulTestsUtil method sentRequest.

public static int sentRequest(final String url, final String method) throws Exception {
    HttpClient httpClient = new HttpClient();
    try {
        httpClient.start();
        ContentExchange contentExchange = new ContentExchange();
        contentExchange.setMethod(method);
        contentExchange.setURL(url);
        httpClient.send(contentExchange);
        contentExchange.waitForDone();
        return contentExchange.getResponseStatus();
    } finally {
        httpClient.stop();
    }
}
Also used : HttpClient(org.eclipse.jetty.client.HttpClient) ContentExchange(org.eclipse.jetty.client.ContentExchange)

Example 70 with HttpClient

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

the class BulkApiIntegrationTest method testRetry.

@Test
public void testRetry() throws Exception {
    final SalesforceComponent sf = context().getComponent("salesforce", SalesforceComponent.class);
    final String accessToken = sf.getSession().getAccessToken();
    final SslContextFactory sslContextFactory = new SslContextFactory();
    sslContextFactory.setSslContext(new SSLContextParameters().createSSLContext(context));
    final HttpClient httpClient = new HttpClient(sslContextFactory);
    httpClient.setConnectTimeout(60000);
    httpClient.start();
    final String uri = sf.getLoginConfig().getLoginUrl() + "/services/oauth2/revoke?token=" + accessToken;
    final Request logoutGet = httpClient.newRequest(uri).method(HttpMethod.GET).timeout(1, TimeUnit.MINUTES);
    final ContentResponse response = logoutGet.send();
    assertEquals(HttpStatus.OK_200, response.getStatus());
    final JobInfo jobInfo = new JobInfo();
    jobInfo.setOperation(OperationEnum.INSERT);
    jobInfo.setContentType(ContentType.CSV);
    jobInfo.setObject(Merchandise__c.class.getSimpleName());
    createJob(jobInfo);
}
Also used : SslContextFactory(org.eclipse.jetty.util.ssl.SslContextFactory) ContentResponse(org.eclipse.jetty.client.api.ContentResponse) JobInfo(org.apache.camel.component.salesforce.api.dto.bulk.JobInfo) HttpClient(org.eclipse.jetty.client.HttpClient) Request(org.eclipse.jetty.client.api.Request) Merchandise__c(org.apache.camel.component.salesforce.dto.generated.Merchandise__c) SSLContextParameters(org.apache.camel.util.jsse.SSLContextParameters) Test(org.junit.Test)

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