jetty.project icon indicating copy to clipboard operation
jetty.project copied to clipboard

Why is HttpResponse.getReason() always null?

Open cowwoc opened this issue 4 months ago • 2 comments

Jetty Version 12.0.6

Jetty Environment core

Java Version 21

Question When using HTTP/1.1 in the past, I remember HttpResponse.getReason() returning the equivalent of HttpStatus.Code.getMessage() but when using HTTP/2 I see that HttpChannelState.lockedPrepareResponse() always sets the reason to null. Is there a reason for the different behavior across HTTP versions? Or is this perhaps a bug?

cowwoc avatar Mar 28 '24 21:03 cowwoc

The Response line status reason phrase is optional (the words like "OK" or "Not Found").

It was declared optional in HTTP/1. - https://datatracker.ietf.org/doc/html/rfc9110#section-15.1

and is completely absent from HTTP/2 and HTTP/3. - https://datatracker.ietf.org/doc/html/rfc7540#section-8.1.2.4

joakime avatar Mar 28 '24 22:03 joakime

Thank you. Is it possible to add this clarification to the getReason() javadoc?

cowwoc avatar Mar 28 '24 22:03 cowwoc