The ResponseEntity object has no way to access the trailer. The data you get from the body doesn't contain the trailer info, and neither does the headers object. I debugged the issue a little and found that netty correctly parses and makes the data available:
But the info is "thrown away" in the reactor.netty.ByteBufFlux
final static Function<Object, ByteBuf> bytebufExtractor = o -> {
if (o instanceof ByteBuf) {
return (ByteBuf) o;
}
if (o instanceof ByteBufHolder) {
return ((ByteBufHolder) o).content();
}
if (o instanceof byte[]) {
return Unpooled.wrappedBuffer((byte[]) o);
}
throw new IllegalArgumentException("Object " + o + " of type " + o.getClass() + " " + "cannot be converted to ByteBuf");
};
As this only looks at the content of the LastHttpContent, and ignores the trailerHeaders.
That said, i'm also not really sure how to properly make the trailers available, best i could come up with is an extra mono in the response entity object, as the info would only be available once the full body has been read. But hopefully you can think of something better :)
Currently, neither Spring MVC, Spring WebFlux nor any of our HTTP clients support HTTP trailing headers. This is a requirement for enhancement requests like #24425
With the current WebClient implementation its not possible to get the trailer data of a chunked http response. For example for the response:
The ResponseEntity object has no way to access the trailer. The data you get from the body doesn't contain the trailer info, and neither does the headers object. I debugged the issue a little and found that netty correctly parses and makes the data available:![image](https://github.com/spring-projects/spring-framework/assets/36533357/95d804f7-f011-4b36-9966-5968aacd65fc)
But the info is "thrown away" in the
reactor.netty.ByteBufFlux
As this only looks at the content of the
LastHttpContent
, and ignores thetrailerHeaders
.That said, i'm also not really sure how to properly make the trailers available, best i could come up with is an extra mono in the response entity object, as the info would only be available once the full body has been read. But hopefully you can think of something better :)