本文整理了Java中org.eclipse.jetty.client.HttpClient.<init>()
方法的一些代码示例,展示了HttpClient.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpClient.<init>()
方法的具体详情如下:
包路径:org.eclipse.jetty.client.HttpClient
类名称:HttpClient
方法名:<init>
[英]Creates a HttpClient instance that can perform requests to non-TLS destinations only (that is, requests with the "http" scheme only, and not "https").
[中]创建一个HttpClient实例,该实例只能执行对非TLS目的地的请求(即,仅使用“http”方案的请求,而不使用“https”)。
代码示例来源:origin: spring-projects/spring-framework
/**
* Default constructor that creates a new instance of {@link HttpClient}.
*/
public JettyClientHttpConnector() {
this(new HttpClient());
}
代码示例来源:origin: org.springframework/spring-web
/**
* Default constructor that creates a new instance of {@link HttpClient}.
*/
public JettyClientHttpConnector() {
this(new HttpClient());
}
代码示例来源:origin: spring-projects/spring-framework
@Override
protected AbstractXhrTransport createXhrTransport() {
return new JettyXhrTransport(new HttpClient());
}
代码示例来源:origin: spring-projects/spring-framework
/**
* 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;
}
代码示例来源:origin: konsoletyper/teavm
public CodeServlet(String mainClass, String[] classPath) {
this.mainClass = mainClass;
this.classPath = classPath.clone();
httpClient = new HttpClient();
httpClient.setFollowRedirects(false);
}
代码示例来源:origin: databricks/learning-spark
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(), ","));
代码示例来源:origin: databricks/learning-spark
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(), ","));
代码示例来源:origin: org.springframework/spring-web
/**
* 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;
}
代码示例来源:origin: apache/incubator-druid
final SslContextFactory sslContextFactory = new SslContextFactory();
sslContextFactory.setSslContext(getSslContextBinding().getProvider().get());
httpClient = new HttpClient(sslContextFactory);
} else {
httpClient = new HttpClient();
代码示例来源:origin: jersey/jersey
this.client = new HttpClient(sslContextFactory);
代码示例来源:origin: xuxueli/xxl-job
httpClient = new HttpClient();
httpClient.setFollowRedirects(false); // Configure HttpClient, for example:
代码示例来源:origin: xuxueli/xxl-job
httpClient = new HttpClient();
httpClient.setFollowRedirects(false); // Configure HttpClient, for example:
代码示例来源:origin: 4thline/cling
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
);
}
}
代码示例来源:origin: sixt/ja-micro
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;
}
代码示例来源:origin: sixt/ja-micro
@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;
}
代码示例来源:origin: sixt/ja-micro
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;
}
代码示例来源:origin: kingthy/TVRemoteIME
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
);
}
}
代码示例来源:origin: allegro/hermes
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;
}
代码示例来源:origin: allegro/hermes
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;
}
代码示例来源:origin: allegro/hermes
@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();
}
内容来源于网络,如有侵权,请联系作者删除!