jakartaee / servlet

Jakarta Servlet
https://eclipse.org/ee4j/servlet
Other
253 stars 81 forks source link

Generic support for 1xx responses and early hints in particular #542

Open markt-asf opened 9 months ago

markt-asf commented 9 months ago

This issue arose from discussions around dropping HTTP/2 push support in #538.

Do we reuse sendError(), introduce a new method or something else?

Given the Javadoc for sendError(), I think a new method (name?) would be better.

Given the number of different methods that can set status codes, I think we should also add a requirement to throw IllegalArgumentException if any such method is used with an inappropriate status code (e.g. a 4xx code with sendRedirect)

gregw commented 9 months ago

Note that eclipse jetty has had a proprietary extension to sendError for some time to support 102 Processing and now 103 Early Hints. We also treat -1 specially as a request to abort/reset the response. This is useful for trying to communicate failure when an error has been detected, but the response is already committed.

I think a sendInformationalStatus(int) method would be fine... although we probably would need to block 101, as that has other implications beyond what can be done in a servlet. Perhaps an abort() method to cover the -1 case above?

markt-asf commented 9 months ago

By abort() do you mean close the connection?