Affects: 5.2.1.RELEASE
in org.springframework.http.server.reactive.ServerHttpResponse we have the following method :
boolean setStatusCode(@Nullable HttpStatus status);
that is supposed to allow us to set the http status code for the response. The problem is that we can't use a simple int value and we have to pass through HttpStatus that cannot resolve non-standard Http status codes (498 in my case)
I've already asked on SO and apparently there is no way to make this work in the current release ?
Comment From: rstoyanchev
An @Controller can set the status to an integer value via ResponseEntity#status(int) and a HandlerFunction can do the same use ServerResponse#status(int). Does either of those work for your case?
Comment From: saad14092
@rstoyanchev I don't think so. I need to set the status code in a org.springframework.web.server.WebFilter
Which has a method WebFilter#filter(ServerWebExchange ex, WebFilterChain chain)
and ex.getResponse() returns a ServerHttpResponse
Comment From: jhoeller
Note that a pair of plain status accessors is available on AbstractServerHttpResponse: namely setStatusCodeValue and getStatusCodeValue. We could consider exposing them on the interface as well. For the time being, feel free to downcast accordingly.
Comment From: saad14092
@jhoeller Thanks for the tip. That should do the trick for the time being.
Comment From: rstoyanchev
Since this is now used as unofficial API (case here and also in Boot), we need to make sure setStatusCodeValue is protected against being set after response is committed. It would also make it consistent with the programming models (annotation and functional) as well as with ClientHttpResponse