mirror of https://github.com/halo-dev/halo
Fix the problem of not being able to resolve headers correctly (#6786)
#### What type of PR is this?
/kind bug
/area core
/milestone 2.20.x
#### What this PR does / why we need it:
This PR changes server.forward-header-strategy to native instead of framework due to a bug of Spring Framework 6.20.0-RC.1.
See https://github.com/spring-projects/spring-framework/pull/32097#discussion_r1791264218 for more.
If Halo server is proxied by OpenResty which is using HTTP 2, all header names proxied into Halo server will be lowercase. This behavior makes Halo get a null header(e.g.:: `content-type: application/json`) while invoking `request.getHeaders().getContentType()`.
And I found that `ServerHttpRequest` is mutated by `org.springframework.web.server.adapter.ForwardedHeaderTransformer`, so I try to use native forward-header-strategy to resolve the problem and it works very well. See [reactor.netty.http.server.DefaultHttpForwardedHeaderHandler](446683826b/reactor-netty-http/src/main/java/reactor/netty/http/server/DefaultHttpForwardedHeaderHandler.java
) for more.
#### Does this PR introduce a user-facing change?
```release-note
None
```
pull/6794/head
parent
1d31d32312
commit
f1d5911bb3
|
@ -1,6 +1,6 @@
|
|||
server:
|
||||
port: 8090
|
||||
forward-headers-strategy: framework
|
||||
forward-headers-strategy: native
|
||||
compression:
|
||||
enabled: true
|
||||
error:
|
||||
|
|
|
@ -17,7 +17,7 @@ import org.springframework.web.reactive.function.server.ServerResponse;
|
|||
import reactor.test.StepVerifier;
|
||||
|
||||
@SpringBootTest(webEnvironment = RANDOM_PORT,
|
||||
properties = "server.forward-headers-strategy=framework")
|
||||
properties = "server.forward-headers-strategy=native")
|
||||
class XForwardHeaderTest {
|
||||
|
||||
@LocalServerPort
|
||||
|
|
Loading…
Reference in New Issue