-
Notifications
You must be signed in to change notification settings - Fork 6k
HttpHeaders.writeHttpHeaders Fails with UnsupportedOperationException #15989
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'm going to close this issue in favor of spring-projects/spring-framework#33789 |
For those experiencing this issue, DO NOT disable Spring Security's firewall as a workaround to the underlying Spring Framework issue. Instead, you can use the following as a workaround: @Bean
@Order(Ordered.HIGHEST_PRECEDENCE)
WebFilter writeableHeaders() {
return (exchange, chain) -> {
HttpHeaders writeableHeaders = HttpHeaders.writableHttpHeaders(
exchange.getRequest().getHeaders());
ServerHttpRequestDecorator writeableRequest = new ServerHttpRequestDecorator(
exchange.getRequest()) {
@Override
public HttpHeaders getHeaders() {
return writeableHeaders;
}
};
ServerWebExchange writeableExchange = exchange.mutate()
.request(writeableRequest)
.build();
return chain.filter(writeableExchange);
};
} You can find a complete demo of the workaround at https://github.com/rwinch/spring-sample/tree/spring-framework-33789-readonly-headers |
@rwinch |
Superseded by spring-projects/spring-framework#33789
Related spring-cloud/spring-cloud-gateway#3568 #15995 #16002 #16013
Workaround #15989 (comment)
Updated Description
When using WebFlux + Spring Cloud + Spring Security's
StrictServerWebExchangeFirewall
the following exception occursOriginal Description
Rob and I chatted about it
https://github.com/spring-projects/spring-framework/blob/c27a5687dcc8708584edd0141630af66ce6cbe90/spring-web/src/main/java/org/springframework/http/HttpHeaders.java#L1890
headers is read only, AND headers.headers is read only, so calling HttpHeaders.writableHttpHeaders() does not, in fact, result in writable headers.
The question is, is it a security or framework bug.
/cc @rwinch @rstoyanchev
The text was updated successfully, but these errors were encountered: