1

I am working on a Spring-Boot application. With each response I would like to return http Status-Line, Headers and Body. As per standards a Status-Line looks like: HTTP-Version SP Status-Code SP Reason-Phrase CRLF. For Example: Http/1.1 400 Bad Request

I am using ResponseEntity with VnDErrors but Status-Line is not forming as per standards. I am able to see only "Http/1.1 400". Here Reason-Phrase is missing.

I have tried with @ResponseBody with @ResponseStatus annotation but no luck to achieve desired result.

Here is piece of code which I am using:

@ExceptionHandler(HttpRequestMethodNotSupportedException) ResponseEntity<VndErrors> httpRequestMethodNotSupportedException(ex) { LOGGER.error(ex.message) ResponseEntity.status(BAD_REQUEST).contentType(VND_ERROR).body(new VndErrors(BAD_REQUEST, exceptionMessage)) } 

Expected reponse which conatins Status-Line: "Http/1.1 400 Bad Request" Would like to know is this achievable? If yes, then how I can proceed to do same.

1 Answer 1

1

This is the standard behavior of tomcat see tomcat-8.5-changelog.html

spring-boot-issue-6789

RFC 7230 states that clients should ignore reason phrases in HTTP/1.1 response messages. Since the reason phrase is optional, Tomcat no longer sends it. As a result the system property org.apache.coyote.USE_CUSTOM_STATUS_MSG_IN_HEADER is no longer used and has been removed. (markt)

Sign up to request clarification or add additional context in comments.

1 Comment

Okay. But is there any way to send it in response. Might be programtically ?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.