org.apache.http.client.fluent.Executor类的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(321)

本文整理了Java中org.apache.http.client.fluent.Executor类的一些代码示例,展示了Executor类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Executor类的具体详情如下:
包路径:org.apache.http.client.fluent.Executor
类名称:Executor

Executor介绍

[英]An Executor for fluent requests.

A PoolingHttpClientConnectionManager with maximum 100 connections per route and a total maximum of 200 connections is used internally.
[中]流畅请求的执行者。
内部使用PoollightTPClientConnectionManager,每个路由最多有100个连接,总共最多有200个连接。

代码示例

代码示例来源:origin: dreamhead/moco

public HttpResponse execute(final Request request) throws IOException {
  return executor.execute(request).returnResponse();
}

代码示例来源:origin: dreamhead/moco

public MocoTestHelper() {
  // make fluent HC accept any certificates so we can test HTTPS calls as well
  Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create()
      .register("http", PlainConnectionSocketFactory.getSocketFactory())
      .register("https", new SSLConnectionSocketFactory(createClientContext()))
      .build();
  HttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(registry);
  CloseableHttpClient client = HttpClients.custom()
      .setConnectionManager(cm)
      .setDefaultRequestConfig(RequestConfig.custom().setCookieSpec(CookieSpecs.STANDARD).build())
      .build();
  executor = Executor.newInstance(client);
}

代码示例来源:origin: jooby-project/jooby

private Executor executor() {
 if (executor == null) {
  if (this.host.startsWith("https://")) {
   Try.run(() -> {
    SSLContext sslContext = SSLContexts.custom()
      .loadTrustMaterial(null, (chain, authType) -> true)
      .build();
    builder.setSSLContext(sslContext);
    builder.setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE);
   }).throwException();
  }
  client = builder.build();
  executor = Executor.newInstance(client);
  if (creds != null) {
   executor.auth(creds);
  }
 }
 return executor;
}

代码示例来源:origin: org.biopax.validator/biopax-validator-client

String content = Executor.newInstance()
    .execute(Request.Post(url).body(httpEntity))
      .returnContent().asString();

代码示例来源:origin: org.talend.components/components-jira

get.addHeader(header);
executor.clearCookies();
Response response = executor.execute(get);
HttpResponse httpResponse = response.returnResponse();
HttpEntity entity = httpResponse.getEntity();

代码示例来源:origin: org.apache.sling/org.apache.sling.distribution.core

private Executor buildAuthExecutor(String username, String password) {
  URI uri = distributionEndpoint.getUri();
  Executor executor = Executor.newInstance()
      .auth(new HttpHost(uri.getHost(), uri.getPort(), uri.getScheme()), username, password)
      .authPreemptive(new HttpHost(uri.getHost(), uri.getPort(), uri.getScheme()));
  log.debug("authenticate user={}, endpoint={}", username, uri);
  return executor;
}

代码示例来源:origin: org.talend.components/components-jira

/**
 * Constructor sets schema(http or https), host(google.com) and port number(8080) using one hostPort parameter
 * 
 * @param hostPort URL
 */
public Rest(String hostPort) {
  headers = new LinkedList<>();
  if (!hostPort.endsWith("/")) {
    hostPort = hostPort + "/";
  }
  this.hostPort = hostPort;
  contentType = ContentType.create("application/json", StandardCharsets.UTF_8);
  executor = Executor.newInstance(createHttpClient());
  executor.use(new BasicCookieStore());
}

代码示例来源:origin: org.apache.httpcomponents/fluent-hc

public Executor auth(final Credentials cred) {
  return auth(AuthScope.ANY, cred);
}

代码示例来源:origin: org.apache.httpcomponents/fluent-hc

public static Executor newInstance() {
  return new Executor(CLIENT);
}

代码示例来源:origin: org.apache.httpcomponents/fluent-hc

/**
 * @since 4.4
 */
public Executor authPreemptive(final String host) {
  return authPreemptive(HttpHost.create(host));
}

代码示例来源:origin: org.apache.james/james-server-jmap-integration-testing

@When("^someone upload a content without authentification$")
public void userUploadContentWithoutAuthentification() throws Throwable {
  Request request = Request.Post(uploadUri)
    .bodyStream(new BufferedInputStream(new ZeroedInputStream(_1M), _1M), org.apache.http.entity.ContentType.DEFAULT_BINARY);
  response = Executor.newInstance(HttpClientBuilder.create().disableAutomaticRetries().build()).execute(request).returnResponse();
}

代码示例来源:origin: org.talend.components/components-jira

delete.addHeader(header);
executor.clearCookies();
Response response = executor.execute(delete);
HttpResponse httpResponse = response.returnResponse();
StatusLine statusLine = httpResponse.getStatusLine();

代码示例来源:origin: Adobe-Consulting-Services/acs-aem-commons

executor = Executor.newInstance(httpClient);
if (username != null && password != null) {
  HttpHost httpHost = new HttpHost(hostname, port, useSSL ? "https" : "http");
  executor.auth(httpHost, username, password).authPreemptive(httpHost);

代码示例来源:origin: Talend/components

/**
 * Constructor sets schema(http or https), host(google.com) and port number(8080) using one hostPort parameter
 * 
 * @param hostPort URL
 */
public Rest(String hostPort) {
  headers = new LinkedList<>();
  if (!hostPort.endsWith("/")) {
    hostPort = hostPort + "/";
  }
  this.hostPort = hostPort;
  contentType = ContentType.create("application/json", StandardCharsets.UTF_8);
  executor = Executor.newInstance(createHttpClient());
  executor.use(new BasicCookieStore());
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.apache.httpcomponents.httpclient

public Executor auth(final Credentials cred) {
  return auth(AuthScope.ANY, cred);
}

代码示例来源:origin: org.apache.httpcomponents/fluent-hc

public static Executor newInstance(final HttpClient httpclient) {
  return new Executor(httpclient != null ? httpclient : CLIENT);
}

代码示例来源:origin: dreamhead/moco

public String executeAsString(final Request request) throws IOException {
  return executor.execute(request).returnContent().asString();
}

代码示例来源:origin: net.aequologica.neo/dagr-vebchar

.build();
  this.executor = Executor.newInstance(httpClient);
} catch (Exception e) {
  throw new RuntimeException(e);
    org.apache.http.client.fluent.Response response = executor.execute(request);

代码示例来源:origin: Talend/components

get.addHeader(header);
executor.clearCookies();
Response response = executor.execute(get);
HttpResponse httpResponse = response.returnResponse();
HttpEntity entity = httpResponse.getEntity();

代码示例来源:origin: mesosphere/dcos-commons

/**
 * Validates that the provided client is valid before constructing an {@link Executor} which may
 * be used via {@link #execute(Request)}.
 */
public DcosHttpExecutor(HttpClientBuilder clientBuilder) {
 this.executor = Executor.newInstance(clientBuilder.build());
}

相关文章