rest
rest copied to clipboard
Support for trailing headers in the server and client API
HTTP/2 bring renewed support for tailing headers, this useful when using headers such as Server-Timing where you want to report on work done when streaming the response body after the primary headers has been written. This is great for providing diagnostics to the client without have to resort to accessing server logs.
You can do this indirectly on servers where Servlets are available:
HttpServletResponse response = rc.getResource(HttpServletResponse.class);
if (response!=null) {
Supplier<Map<String, String>> existing = response.getTrailerFields();
try {
response.setTrailerFields(() -> {
Map<String, String> fields = new HashMap<>();
.... });
But it would be excellent to have this ability in the JAX-RS directly.
This is an open source project, so feel free to propose an API for that. :-)