-
Couldn't load subscription status.
- Fork 35
Description
Hi guys, @OlgaMaciaszek
I am trying to implement a decorator to ClientHttpRequestDecorator to print some logs using @RetrofitClient @Body with Flux for the request body using WebClient, but it is not working. The method writeWith(body: Publisher) of the decorator is being invoked (actually this method should have been invoked: writeAndFlushWith()) and it doesn't receive correctly the data buffers causing the logs are not printed correctly, only the text {"prefetch":-1} is printed as request body.
I am trying with the following Retrofit Client:
@Headers(*["Content-Type: application/stream+json", "Accept: application/stream+json"])
@Streaming
@POST("cards/search-stream")
fun searchStream(@Body cardsSearchAllRequest: Flux<Card>): Flux<Card>
Note:
The method writeAndFlushWith() is being invoked and works correctly when an http request is invoked directly using WebClient (but We would like to use the component @RetrofitClient and not just the WebClient directly), like this:
val webClient =
WebClient.builder().baseUrl("http://localhost:8082/support/cards/v1").defaultHeader("Content-Type", "application/stream+json").clientConnector(
DefaultReactorClientHttpConnectorDecorator(
ReactorClientHttpConnector(HttpClient.create()), { -> true}))
.build()
return webClient
.post()
.uri("/cards/search-stream")
.header(org.springframework.http.HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_STREAM_JSON_VALUE)
.header("caller-name", "web-client")
.header("Request-ID", "550e8400-1234-41d4-a716-446655440025")
.body(Flux.just(Card("a", "b"), Card("c", "d"), Card("e", "f"), Card("g", "h")), Card::class.java)
.retrieve()
.bodyToMono(Card::class.java);
We want to know if there is a bug for this scenery or there is not still support for making this type of call: @post call with request @Body Flux using @RetrofitClient(WebClient)?
I am looking forward to hearing from you!