/** * Default constructor that creates a new instance of {@link HttpClient}. */ public JettyClientHttpConnector() { this(new HttpClient()); }
/** * Default constructor that creates a new instance of {@link HttpClient}. */ public JettyClientHttpConnector() { this(new HttpClient()); }
@Override protected AbstractXhrTransport createXhrTransport() { return new JettyXhrTransport(new HttpClient()); }
/** * Constructor with an {@link JettyResourceFactory} that will manage shared resources. * @param resourceFactory the {@link JettyResourceFactory} to use * @param customizer the lambda used to customize the {@link HttpClient} */ public JettyClientHttpConnector( JettyResourceFactory resourceFactory, @Nullable Consumer<HttpClient> customizer) { HttpClient httpClient = new HttpClient(); httpClient.setExecutor(resourceFactory.getExecutor()); httpClient.setByteBufferPool(resourceFactory.getByteBufferPool()); httpClient.setScheduler(resourceFactory.getScheduler()); if (customizer != null) { customizer.accept(httpClient); } this.httpClient = httpClient; }
public CodeServlet(String mainClass, String[] classPath) { this.mainClass = mainClass; this.classPath = classPath.clone(); httpClient = new HttpClient(); httpClient.setFollowRedirects(false); }
public Iterable<Tuple2<String, CallLog[]>> call(Iterator<String> input) { // List for our results. ArrayList<Tuple2<String, CallLog[]>> callsignQsos = new ArrayList<Tuple2<String, CallLog[]>>(); ArrayList<Tuple2<String, ContentExchange>> requests = new ArrayList<Tuple2<String, ContentExchange>>(); ObjectMapper mapper = createMapper(); HttpClient client = new HttpClient(); try { client.start(); while (input.hasNext()) { requests.add(createRequestForSign(input.next(), client)); } for (Tuple2<String, ContentExchange> signExchange : requests) { callsignQsos.add(fetchResultFromRequest(mapper, signExchange)); } } catch (Exception e) { } return callsignQsos; }}); System.out.println(StringUtils.join(contactsContactLists.collect(), ","));
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(), ","));
/** * Constructor with an {@link JettyResourceFactory} that will manage shared resources. * @param resourceFactory the {@link JettyResourceFactory} to use * @param customizer the lambda used to customize the {@link HttpClient} */ public JettyClientHttpConnector( JettyResourceFactory resourceFactory, @Nullable Consumer<HttpClient> customizer) { HttpClient httpClient = new HttpClient(); httpClient.setExecutor(resourceFactory.getExecutor()); httpClient.setByteBufferPool(resourceFactory.getByteBufferPool()); httpClient.setScheduler(resourceFactory.getScheduler()); if (customizer != null) { customizer.accept(httpClient); } this.httpClient = httpClient; }
final SslContextFactory sslContextFactory = new SslContextFactory(); sslContextFactory.setSslContext(getSslContextBinding().getProvider().get()); httpClient = new HttpClient(sslContextFactory); } else { httpClient = new HttpClient();
this.client = new HttpClient(sslContextFactory);
httpClient = new HttpClient(); httpClient.setFollowRedirects(false); // Configure HttpClient, for example:
httpClient = new HttpClient(); httpClient.setFollowRedirects(false); // Configure HttpClient, for example:
public StreamClientImpl(StreamClientConfigurationImpl configuration) throws InitializationException { this.configuration = configuration; log.info("Starting Jetty HttpClient..."); client = new HttpClient(); // Jetty client needs threads for its internal expiration routines, which we don't need but // can't disable, so let's abuse the request executor service for this client.setThreadPool( new ExecutorThreadPool(getConfiguration().getRequestExecutorService()) { @Override protected void doStop() throws Exception { // Do nothing, don't shut down the Cling ExecutorService when Jetty stops! } } ); // These are some safety settings, we should never run into these timeouts as we // do our own expiration checking client.setTimeout((configuration.getTimeoutSeconds()+5) * 1000); client.setConnectTimeout((configuration.getTimeoutSeconds()+5) * 1000); client.setMaxRetries(configuration.getRequestRetryCount()); try { client.start(); } catch (Exception ex) { throw new InitializationException( "Could not start Jetty HTTP client: " + ex, ex ); } }
private HttpClient createHttpClient() { SslContextFactory sslContextFactory = new SslContextFactory(); sslContextFactory.setExcludeCipherSuites(""); HttpClient client = new HttpClient(sslContextFactory); client.setFollowRedirects(false); client.setMaxConnectionsPerDestination(2); //You can set more restrictive timeouts per request, but not less, so // we set the maximum timeout of 1 hour here. client.setIdleTimeout(60 * 60 * 1000); try { client.start(); } catch (Exception e) { logger.error("Error building http client", e); } return client; }
@Provides public HttpClient getHttpClient() { HttpClient client = new HttpClient(); client.setFollowRedirects(false); client.setMaxConnectionsPerDestination(32); client.setConnectTimeout(100); client.setAddressResolutionTimeout(100); //You can set more restrictive timeouts per request, but not less, so // we set the maximum timeout of 1 hour here. client.setIdleTimeout(60 * 60 * 1000); try { client.start(); } catch (Exception e) { logger.error("Error building http client", e); } return client; }
private HttpClient createHttpClient() { //Allow ssl by default SslContextFactory sslContextFactory = new SslContextFactory(); //Don't exclude RSA because Sixt needs them, dammit! sslContextFactory.setExcludeCipherSuites(""); HttpClient client = new HttpClient(sslContextFactory); client.setFollowRedirects(false); client.setMaxConnectionsPerDestination(16); client.setRequestBufferSize(65536); client.setConnectTimeout(FeatureFlags.getHttpConnectTimeout(serviceProperties)); client.setAddressResolutionTimeout(FeatureFlags.getHttpAddressResolutionTimeout(serviceProperties)); //You can set more restrictive timeouts per request, but not less, so // we set the maximum timeout of 1 hour here. client.setIdleTimeout(60 * 60 * 1000); try { client.start(); } catch (Exception e) { logger.error("Error building http client", e); } return client; }
public StreamClientImpl(StreamClientConfigurationImpl configuration) throws InitializationException { this.configuration = configuration; log.info("Starting Jetty HttpClient..."); client = new HttpClient(); // Jetty client needs threads for its internal expiration routines, which we don't need but // can't disable, so let's abuse the request executor service for this client.setThreadPool( new ExecutorThreadPool(getConfiguration().getRequestExecutorService()) { @Override protected void doStop() throws Exception { // Do nothing, don't shut down the Cling ExecutorService when Jetty stops! } } ); // These are some safety settings, we should never run into these timeouts as we // do our own expiration checking client.setTimeout((configuration.getTimeoutSeconds()+5) * 1000); client.setConnectTimeout((configuration.getTimeoutSeconds()+5) * 1000); client.setMaxRetries(configuration.getRequestRetryCount()); try { client.start(); } catch (Exception ex) { throw new InitializationException( "Could not start Jetty HTTP client: " + ex, ex ); } }
public HttpClient createClientForHttp2() { ExecutorService executor = executorFactory.getExecutorService("jetty-http2-client", configFactory.getIntProperty(CONSUMER_HTTP2_CLIENT_THREAD_POOL_SIZE), configFactory.getBooleanProperty(CONSUMER_HTTP2_CLIENT_THREAD_POOL_MONITORING)); HTTP2Client h2Client = new HTTP2Client(); h2Client.setExecutor(executor); HttpClientTransportOverHTTP2 transport = new HttpClientTransportOverHTTP2(h2Client); HttpClient client = new HttpClient(transport, createSslContextFactory()); client.setMaxRequestsQueuedPerDestination(configFactory.getIntProperty(CONSUMER_INFLIGHT_SIZE)); client.setCookieStore(new HttpCookieStore.Empty()); return client; }
public HttpClient createClientForHttp1(String name) { ExecutorService executor = executorFactory.getExecutorService(name, configFactory.getIntProperty(CONSUMER_HTTP_CLIENT_THREAD_POOL_SIZE), configFactory.getBooleanProperty(CONSUMER_HTTP_CLIENT_THREAD_POOL_MONITORING)); HttpClient client = new HttpClient(createSslContextFactory()); client.setMaxConnectionsPerDestination(configFactory.getIntProperty(CONSUMER_HTTP_CLIENT_MAX_CONNECTIONS_PER_DESTINATION)); client.setMaxRequestsQueuedPerDestination(configFactory.getIntProperty(CONSUMER_INFLIGHT_SIZE)); client.setExecutor(executor); client.setCookieStore(new HttpCookieStore.Empty()); return client; }
@BeforeClass public static void setupEnvironment() throws Exception { wireMockServer = new WireMockServer(ENDPOINT_PORT); wireMockServer.start(); client = new HttpClient(); client.setCookieStore(new HttpCookieStore.Empty()); client.setConnectTimeout(1000); client.setIdleTimeout(1000); client.start(); }