當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpClientOptions.setKeepAlive方法代碼示例

本文整理匯總了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;
}
 
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:10,代碼來源:RestTransportClient.java

示例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);
}
 
開發者ID:ocraft,項目名稱:ocraft-s2client,代碼行數:9,代碼來源:S2ClientVerticle.java

示例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);
}
 
開發者ID:etourdot,項目名稱:vertx-marklogic,代碼行數:9,代碼來源:DefaultRestService.java

示例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;
	}
 
開發者ID:bpark,項目名稱:chlorophytum-semantics,代碼行數:43,代碼來源:DownloadService.java

示例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<>();
}
 
開發者ID:aesteve,項目名稱:vertx-sse,代碼行數:7,代碼來源:EventSourceImpl.java


注:本文中的io.vertx.core.http.HttpClientOptions.setKeepAlive方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。