本文整理汇总了Java中io.vertx.core.http.HttpClientOptions.setKeepAlive方法的典型用法代码示例。如果您正苦于以下问题:Java HttpClientOptions.setKeepAlive方法的具体用法?Java HttpClientOptions.setKeepAlive怎么用?Java HttpClientOptions.setKeepAlive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.vertx.core.http.HttpClientOptions
的用法示例。
在下文中一共展示了HttpClientOptions.setKeepAlive方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createHttpClientOptions
import io.vertx.core.http.HttpClientOptions; //导入方法依赖的package包/类
private static HttpClientOptions createHttpClientOptions() {
HttpClientOptions httpClientOptions = new HttpClientOptions();
httpClientOptions.setMaxPoolSize(TransportClientConfig.getConnectionMaxPoolSize());
httpClientOptions.setIdleTimeout(TransportClientConfig.getConnectionIdleTimeoutInSeconds());
httpClientOptions.setKeepAlive(TransportClientConfig.getConnectionKeepAlive());
VertxTLSBuilder.buildHttpClientOptions(SSL_KEY, httpClientOptions);
return httpClientOptions;
}
示例2: initHttpClient
import io.vertx.core.http.HttpClientOptions; //导入方法依赖的package包/类
private void initHttpClient() {
HttpClientOptions httpClientOptions = new HttpClientOptions();
httpClientOptions.setKeepAlive(true);
httpClientOptions.setPipelining(true);
httpClientOptions.setConnectTimeout(CONNECT_TIMEOUT);
httpClientOptions.setMaxWebsocketFrameSize(MAX_WEBSOCKET_FRAME_SIZE_IN_BYTES);
httpClient = vertx.createHttpClient(httpClientOptions);
}
示例3: DefaultRestService
import io.vertx.core.http.HttpClientOptions; //导入方法依赖的package包/类
private DefaultRestService(Builder builder) {
realm = new Realm(builder.authentication, builder.user, builder.password);
HttpClientOptions httpClientOptions = new HttpClientOptions();
httpClientOptions.setDefaultHost(builder.host);
httpClientOptions.setDefaultPort(builder.port);
httpClientOptions.setKeepAlive(builder.keepAlive);
this.httpClient = builder.vertx.createHttpClient(httpClientOptions);
}
示例4: download
import io.vertx.core.http.HttpClientOptions; //导入方法依赖的package包/类
public Future<Void> download(String target) {
Future<Void> future = Future.future();
HttpClientOptions options = new HttpClientOptions();
options.setKeepAlive(false);
options.setLogActivity(true);
HttpClient httpClient = vertx.createHttpClient(options);
httpClient.get(WORDNET_PORT, WORDNET_HOST, WORDNET_FILE, httpEvent -> {
// pause the http response till we complete setting up our async file handler
httpEvent.pause();
// setup file open handler
OpenOptions openOptions = new OpenOptions();
vertx.fileSystem().open(target, openOptions, fileEvent -> {
if (fileEvent.failed()) {
fileEvent.cause().printStackTrace();
return;
}
final AsyncFile asynFile = fileEvent.result();
final Pump downloadPump = Pump.pump(httpEvent, asynFile);
downloadPump.start();
// resume the receive operation
httpEvent.resume();
httpEvent.endHandler(event -> {
// close the file
asynFile.flush().close(closeEvent -> {
});
logger.info("Downloaded size = {}", downloadPump.numberPumped());
future.complete();
});
});
}).exceptionHandler(e -> {
logger.error("Error while downloading the dictionary!", e);
future.fail(e);
}).end();
return future;
}
示例5: EventSourceImpl
import io.vertx.core.http.HttpClientOptions; //导入方法依赖的package包/类
public EventSourceImpl(Vertx vertx, HttpClientOptions options) {
options.setKeepAlive(true);
this.vertx = vertx;
this.options = options;
eventHandlers = new HashMap<>();
}