如何在 Spring reactive 的 ServerHttpResponse 中设置非标准的 HttpStatus?
how to set non-standard HttpStatus in Spring reactive's ServerHttpResponse?
在org.springframework.http.server.reactive.ServerHttpResponse
中我们有以下方法:
boolean setStatusCode(@Nullable HttpStatus status);
这应该允许我们为响应设置 http 状态代码。问题是我们不能使用简单的 int
值,我们必须通过无法解析非标准 Http 状态代码的 HttpStatus (498 在我的例子中)
关于如何设置状态的任何建议?
在 Github 中创建 issue 之后。我知道我们可以将接口向下转换为 AbstractServerHttpResponse
以便访问 setStatusCodeValue
方法,该方法将整数作为参数,从而使我们能够设置非标准状态。
此外,Spring 团队可能会考虑在 ServerHttpResponse
接口中公开此方法以供将来发布。
在org.springframework.http.server.reactive.ServerHttpResponse
中我们有以下方法:
boolean setStatusCode(@Nullable HttpStatus status);
这应该允许我们为响应设置 http 状态代码。问题是我们不能使用简单的 int
值,我们必须通过无法解析非标准 Http 状态代码的 HttpStatus (498 在我的例子中)
关于如何设置状态的任何建议?
在 Github 中创建 issue 之后。我知道我们可以将接口向下转换为 AbstractServerHttpResponse
以便访问 setStatusCodeValue
方法,该方法将整数作为参数,从而使我们能够设置非标准状态。
此外,Spring 团队可能会考虑在 ServerHttpResponse
接口中公开此方法以供将来发布。