jakartaee / rest

Jakarta RESTful Web Services
Other
354 stars 114 forks source link

Support for trailing headers in the server and client API #1060

Open kingsfleet opened 2 years ago

kingsfleet commented 2 years ago

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.

mkarg commented 2 years ago

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