0

I'm new to Java and Spring, and I'm wondering if it's possible to write my own HttpClient doOnConnected handler. The main reason for this is to check if some headers exist before each request and possibly do other things.

Something like this in c#

My code for example:

HttpClient httpClient = HttpClient.create()
        .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 5000)
        .responseTimeout(Duration.ofMillis(5000))
        .doOnConnected(conn ->
                conn.addHandlerLast(new ReadTimeoutHandler(5000, TimeUnit.MILLISECONDS))
                    .addHandlerLast(new WriteTimeoutHandler(5000, TimeUnit.MILLISECONDS))
                    .addHandlerLast(new MyCustomHandler()
        );
Raushan Kumar
  • 1,195
  • 12
  • 21
TryHard
  • 125
  • 9
  • This question is not clear. Please don't send us to some other links for an example of what you want - actually state what you are trying to achieve and what exactly doesn't work – J Asgarov Jan 07 '23 at 18:56

0 Answers0