spring-cloud-gateway
spring-cloud-gateway copied to clipboard
remove-hop-by-hop header case sensitivity
I wanted to remove a custom header from forwarded requests in spring-cloud-gateway
The header name - MyCustomHeader
I've tried to configure this header removal using remove-hop-by-hop filter:
spring.cloud:
gateway:
filter:
remove-hop-by-hop:
headers:
- MyCustomHeader
But it doesn't work
This config also doesn't work
spring.cloud:
gateway:
filter:
remove-hop-by-hop:
headers:
- myCustomHeader
The only way to actually make the remove-hop-by-hop filter work is to provide the header name fully in lowercase:
spring.cloud:
gateway:
filter:
remove-hop-by-hop:
headers:
- mycustomheader
There is no exception/warning when you provide header name with uppercase letters, so you cannot even catch this behavior if you don't have any specific tests for this filter. According to RFC 7230 HTTP header names are case-insensitive so I couldn't understand the reasons behind this unexpected behavior.
Probably it will be better to treat all header names as case-insensitive in remove-hop-by-hop filter, this will be more transparent for the developers and more in line with general standards.
Tested on version: spring-cloud-gateway 3.1.3
I agree, currently its confusing +1
Sorry for the long delay.