I’m using the spring webclient to make my api calls, and one of the calls has a optional trailer response if anything went wrong. The response is chunked encoded.
A simple example:
< HTTP/1.1 200 OK
< Transfer-Encoding: chunked
< Content-Type: text/binary
< Connection: Keep-Alive
< Keep-Alive: timeout-20
< Date: Fri, 03 May 2024 14:26:43 GMT
< Cache-Control: max-age=1
< accept-ranges: bytes
<
0
x-result: 1
x-error: Failed to determine asset size
If i make the request the response body is empty for the above, but i can’t access the trailer headers.
List<byte[]> response = webClient.get().uri( "https://apiwithtailerresponse.com" )
.retrieve().bodyToFlux( byte[].class )
.collectList()
.block();
Any way to retrieve the trailer headers values?
New contributor
Bernard Maassen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.