io.reactivex.netty.protocol.http.client.HttpClient类的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(6.2k)|赞(0)|评价(0)|浏览(198)

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

HttpClient介绍

暂无

代码示例

代码示例来源:origin: io.reactivex/rxnetty

protected Observable<HttpClientResponse<O>> redirect(HttpClientRequest<I> redirectRequest,
                           HttpClient.HttpClientConfig config) {
  return client.submit(redirectRequest, config);
}

代码示例来源:origin: com.netflix.rxnetty/rx-netty

@Override
public void shutdown() {
  for (HttpClient<I, O> client : httpClients.values()) { // This map also contains the default client, so we don't need to shut the default explicitly.
    client.shutdown();
  }
}

代码示例来源:origin: com.netflix.rxnetty/rx-netty-servo

@Override
public HttpClientListener forHttpClient(@SuppressWarnings("rawtypes") HttpClient client) {
  return HttpClientListener.newHttpListener(clientMetricNamePrefix + client.name());
}

代码示例来源:origin: nurkiewicz/rxjava-book-examples

@Test
public void sample_22() throws Exception {
  Observable<URL> sources = Observable.just(new URL("http://www.google.com"));
  Observable<ByteBuf> packets =
      sources
          .flatMap(url -> HttpClient
              .newClient(url.getHost(), url.getPort())
              .createGet(url.getPath()))
          .flatMap(HttpClientResponse::getContent);
}

代码示例来源:origin: io.reactivex/rxnetty

public Subscription subscribe(ServerInfo server, MetricEventsListener<? extends ClientMetricsEvent<?>> listener) {
  HttpClient<I, O> client = httpClients.get(server);
  if (null == client) {
    throw new IllegalArgumentException("Invalid server: " + server.getHost() + ':' + server.getPort());
  }
  return client.subscribe(listener);
}

代码示例来源:origin: org.springframework/spring-web-reactive

private static HttpClient<ByteBuf, ByteBuf> getDefaultHttpClientProvider(URI url) {
  boolean secure = "wss".equals(url.getScheme());
  int port = (url.getPort() > 0 ? url.getPort() : secure ? 443 : 80);
  return HttpClient.newClient(url.getHost(), port);
}

代码示例来源:origin: org.springframework/spring-web-reactive

private WebSocketRequest<ByteBuf> createRequest(URI url, HttpHeaders headers, String[] protocols) {
  String query = url.getRawQuery();
  String requestUrl = url.getRawPath() + (query != null ? "?" + query : "");
  HttpClientRequest<ByteBuf, ByteBuf> request = getHttpClient(url).createGet(requestUrl);
  if (!headers.isEmpty()) {
    Map<String, List<Object>> map = new HashMap<>(headers.size());
    headers.forEach((key, values) -> map.put(key, new ArrayList<>(headers.get(key))));
    request = request.setHeaders(map);
  }
  return (ObjectUtils.isEmpty(protocols) ?
      request.requestWebSocketUpgrade() :
      request.requestWebSocketUpgrade().requestSubProtocols(protocols));
}

代码示例来源:origin: nurkiewicz/rxjava-book-examples

@Test
public void sample_9() throws Exception {
  Observable<ByteBuf> response = HttpClient
      .newClient("example.com", 80)
      .createGet("/")
      .flatMap(HttpClientResponse::getContent);
  response
      .map(bb -> bb.toString(UTF_8))
      .subscribe(System.out::println);
}

代码示例来源:origin: com.netflix.rxnetty/rx-netty

public Subscription subscribe(ServerInfo server, MetricEventsListener<? extends ClientMetricsEvent<?>> listener) {
  HttpClient<I, O> client = httpClients.get(server);
  if (null == client) {
    throw new IllegalArgumentException("Invalid server: " + server.getHost() + ':' + server.getPort());
  }
  return client.subscribe(listener);
}

代码示例来源:origin: com.netflix.rxnetty/rx-netty

protected Observable<HttpClientResponse<O>> redirect(HttpClientRequest<I> redirectRequest,
                           HttpClient.HttpClientConfig config) {
  return client.submit(redirectRequest, config);
}

代码示例来源:origin: com.netflix.iep/iep-rxhttp

/**
 * Shutdown all connections that are currently open.
 */
@PreDestroy
public void stop() {
 LOGGER.info("shutting down backround cleanup threads");
 executor.shutdown();
 for (HttpClient<ByteBuf, ByteBuf> client : clients.values()) {
  client.shutdown();
 }
}

代码示例来源:origin: io.reactivex/rxnetty-spectator

@Override
public HttpClientListener forHttpClient(@SuppressWarnings("rawtypes") HttpClient client) {
  return HttpClientListener.newHttpListener(clientMetricNamePrefix + client.name());
}

代码示例来源:origin: io.reactivex/rxnetty

public Observable<HttpClientResponse<O>> submit(ServerInfo serverInfo, HttpClientRequest<I> request,
                        HttpClientConfig config) {
  HttpClient<I, O> client = getClient(serverInfo);
  return client.submit(request, config);
}

代码示例来源:origin: com.netflix.ribbon/ribbon

@Override
  public synchronized void shutdown() {
    if (!shutdownFlag) {
      httpResourceGroup.getClient().shutdown();
      shutdownFlag = true;
    }
  }
}

代码示例来源:origin: io.reactivex/rxnetty-servo

@Override
public HttpClientListener forHttpClient(@SuppressWarnings("rawtypes") HttpClient client) {
  return HttpClientListener.newHttpListener(clientMetricNamePrefix + client.name());
}

代码示例来源:origin: com.netflix.rxnetty/rx-netty

public Observable<HttpClientResponse<O>> submit(ServerInfo serverInfo, HttpClientRequest<I> request,
                        HttpClientConfig config) {
  HttpClient<I, O> client = getClient(serverInfo);
  return client.submit(request, config);
}

代码示例来源:origin: com.netflix.rxnetty/rx-netty

private HttpClient<I, O> getClient(ServerInfo serverInfo) {
  HttpClient<I, O> client = httpClients.get(serverInfo);
  if (null == client) {
    client = newClient(serverInfo);
    HttpClient<I, O> existing = httpClients.putIfAbsent(serverInfo, client);
    if (null != existing) {
      client.shutdown();
      client = existing;
    }
  }
  return client;
}

代码示例来源:origin: com.netflix.ribbon/ribbon

this.setter = setter;
} else {
  this.setter = HystrixObservableCommand.Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey(client.name()))
      .andCommandKey(HystrixCommandKey.Factory.asKey(name()));
  HystrixCommandProperties.Setter commandProps = HystrixCommandProperties.Setter();

代码示例来源:origin: com.netflix.rxnetty/rx-netty

public Observable<HttpClientResponse<O>> submit(ServerInfo serverInfo, HttpClientRequest<I> request) {
  HttpClient<I, O> client = getClient(serverInfo);
  return client.submit(request);
}

代码示例来源:origin: io.reactivex/rxnetty

private HttpClient<I, O> getClient(ServerInfo serverInfo) {
  HttpClient<I, O> client = httpClients.get(serverInfo);
  if (null == client) {
    client = newClient(serverInfo);
    HttpClient<I, O> existing = httpClients.putIfAbsent(serverInfo, client);
    if (null != existing) {
      client.shutdown();
      client = existing;
    }
  }
  return client;
}

相关文章