reactor.netty.http.client.HttpClient.doOnRequest()方法的使用及代码示例

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

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

HttpClient.doOnRequest介绍

[英]Setup a callback called when HttpClientRequest is about to be sent.
[中]设置将要发送HttpClientRequest时调用的回调。

代码示例

代码示例来源:origin: spring-cloud/spring-cloud-sleuth

@Override
public Object postProcessAfterInitialization(Object bean, String beanName)
    throws BeansException {
  if (bean instanceof HttpClient) {
    return ((HttpClient) bean).mapConnect(new TracingMapConnect(this.beanFactory))
        .doOnRequest(TracingDoOnRequest.create(this.beanFactory))
        .doOnRequestError(TracingDoOnErrorRequest.create(this.beanFactory))
        .doOnResponse(TracingDoOnResponse.create(this.beanFactory))
        .doOnResponseError(TracingDoOnErrorResponse.create(this.beanFactory));
  }
  return bean;
}

代码示例来源:origin: io.netifi.proteus/proteus-tracing-openzipkin

private static Function<Integer, Publisher<InputStream>> zipkinServerStream(
  String zipkinUrl, Mono<HttpClient> client) {
 return lookbackSeconds ->
   client.flatMapMany(
     c ->
       c.doOnRequest(
           (__, connection) -> connection.addHandler(new JsonObjectDecoder(true)))
         .get()
         .uri(zipkinQuery(zipkinUrl, lookbackSeconds))
         .responseContent()
         .asInputStream());
}

代码示例来源:origin: netifi-proteus/proteus-java

private static Function<Integer, Publisher<InputStream>> zipkinServerStream(
  String zipkinUrl, Mono<HttpClient> client) {
 return lookbackSeconds ->
   client.flatMapMany(
     c ->
       c.doOnRequest(
           (__, connection) -> connection.addHandler(new JsonObjectDecoder(true)))
         .get()
         .uri(zipkinQuery(zipkinUrl, lookbackSeconds))
         .responseContent()
         .asInputStream());
}

代码示例来源:origin: org.springframework.cloud/spring-cloud-sleuth-core

@Override
public Object postProcessAfterInitialization(Object bean, String beanName)
    throws BeansException {
  if (bean instanceof HttpClient) {
    return ((HttpClient) bean).mapConnect(new TracingMapConnect(this.beanFactory))
        .doOnRequest(TracingDoOnRequest.create(this.beanFactory))
        .doOnRequestError(TracingDoOnErrorRequest.create(this.beanFactory))
        .doOnResponse(TracingDoOnResponse.create(this.beanFactory))
        .doOnResponseError(TracingDoOnErrorResponse.create(this.beanFactory));
  }
  return bean;
}

代码示例来源:origin: reactor/reactor-netty

.doOnRequest((r, c) -> System.out.println("onReq: "+r))
.doAfterRequest((r, c) -> System.out.println("afterReq: "+r))
.doOnResponse((r, c) -> System.out.println("onResp: "+r))
.doOnRequest((r, c) -> System.out.println("onReq: "+r))
.doAfterRequest((r, c) -> System.out.println("afterReq: "+r))
.doOnResponse((r, c) -> System.out.println("onResp: "+r))
.doOnRequest((r, c) -> System.out.println("onReq: "+r))
.doAfterRequest((r, c) -> System.out.println("afterReq: "+r))
.doOnResponse((r, c) -> System.out.println("onResp: "+r))

代码示例来源:origin: reactor/reactor-netty

.headers(h -> h.add("Accept-Encoding", "gzip")
        .add("Accept-Encoding", "deflate"))
.doOnRequest((req, conn) ->
    conn.addHandlerFirst("gzipDecompressor", new HttpContentDecompressor()))
.get()

代码示例来源:origin: reactor/reactor-netty

HttpClient.create(ConnectionProvider.newConnection())
     .port(server.port())
     .doOnRequest((req, c) -> {
       if (req.currentContext().hasKey("test")) {
         i.incrementAndGet();

相关文章