I plan to add the following API:
----------
HttpServletRequest:
/**
* Get the request trailer.
* This method can only be called after the application reads all
* the request content.
*
* @implSpec
* The default implementation returns null.
*
* @return A map of trailers or null if the request did not contain any
*
* @throws IllegalStateException if neither
* {_at_link javax.servlet.ReadListener#onAllDataRead} has been called nor
* an EOF indication has been returned from the
* {_at_link #getReader} or {_at_link #getInputStream}
*
* @since Servlet 4.0
*/
default public Map<String, String> getTrailers() {
return null;
}
HttpServletResponse:
/**
* Set the supplier of trailer headers.
* The supplier will be called within the scope of whatever thread/call
* causes the response content to be completed. Typically this will
* be any thread calling close() on the output stream or writer.
*
* The trailers that run afoul of the provisions of section 4.1.2 of
* RFC 7230 are ignored.
*
* @implSpec
* The default implementation is a no-op.
*
* @param supplier the supplier of trailer headers
*
* @since Servlet 4.0
*/
default public void setTrailers(Supplier<Map<String, String>> supplier) {
}
—————
A remaining question is whether we need to clarify the null value about.
Please let me know your comments.
Shing Wai Chan