rest icon indicating copy to clipboard operation
rest copied to clipboard

Support for trailing headers in the server and client API

Open kingsfleet opened this issue 3 years ago • 1 comments

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.

kingsfleet avatar Nov 12 '21 21:11 kingsfleet

This is an open source project, so feel free to propose an API for that. :-)

mkarg avatar Nov 13 '21 11:11 mkarg