On 14/04/17 19:51, Shing Wai Chan wrote:
> 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
That isn't quite what we discussed. My understanding was:
- request body not chunked -> null
- request body chunked -> Possible empty Map with trailer headers
> *
> * @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) {
That needs to be Map<String,List<String>> to handle all of the RFC
permitted cases. (The only use case I am aware of is Set-Cookie but it
is a valid use case.)
Mark