As noted here and here, the latest version of Spring Boot (1.4.x) does not return the reason phrase due to the new version of Tomcat.
Unfortunately I am constrained by some legacy code that I cannot influence, and I need to add the "OK" reason phrase back to my responses. Any idea how to do this? If it was a header, it would be easy to modify with an HttpServletResponseWrapper
. But with the status line, I cannot even find the code where the status line is written.
I really don't want to have to (indefinitely) downgrade to old tech. Hopefully someone knows a way to add this back in.
Add the following attribute to your Connection
in conf\server.xml
:
sendReasonPhrase="true"
In Tomcat 8.5.x the reason phrase was no longer sent by default.
To add reason phrase back to spring-boot's embedded tomcat simply declare the following bean in your app config:
@Bean
public EmbeddedServletContainerFactory servletContainer() {
TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory();
factory.addConnectorCustomizers(
(TomcatConnectorCustomizer) connector -> connector.setProperty("sendReasonPhrase", "true"));
return factory;
}
Works since Spring-Boot 1.5.3.RELEASE and untill embedded tomcat will be updated to 9.x version https://bz.apache.org/bugzilla/show_bug.cgi?id=61160
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With