Skip to content

Commit 6051f4e

Browse files
committed
Handle forwarded header parse issues
Closes gh-26459
1 parent 698e74f commit 6051f4e

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

spring-web/src/main/java/org/springframework/web/server/adapter/HttpWebHandlerAdapter.java

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -224,7 +224,16 @@ public void afterPropertiesSet() {
224224
@Override
225225
public Mono<Void> handle(ServerHttpRequest request, ServerHttpResponse response) {
226226
if (this.forwardedHeaderTransformer != null) {
227-
request = this.forwardedHeaderTransformer.apply(request);
227+
try {
228+
request = this.forwardedHeaderTransformer.apply(request);
229+
}
230+
catch (Throwable ex) {
231+
if (logger.isDebugEnabled()) {
232+
logger.debug("Failed to apply forwarded headers to " + formatRequest(request), ex);
233+
}
234+
response.setStatusCode(HttpStatus.BAD_REQUEST);
235+
return response.setComplete();
236+
}
228237
}
229238
ServerWebExchange exchange = createExchange(request, response);
230239

0 commit comments

Comments
 (0)