I created this issue in response to https://github.com/spring-cloud/spring-cloud-gateway/issues/3525#issuecomment-2611550292. See the linked issue for all the details. The main issue is that java.lang.IllegalArgumentException: empty headers are not allowed [] is returned when using IntelliJ's HTTP Client, or if you remove the default headers that httpie or curl uses.
@spencergibb can provide a reproducer if needed.
Comment From: bclozel
I think I'll need a reproducer.
I took your reproducer and changed the route with the following:
@Bean
public RouterFunction<ServerResponse> routerFunction() {
return RouterFunctions.route()
.GET("/test/**",request -> {
logger.info("Request headers: " + request.headers());
String body = RestClient.create().get()
.uri("https://httpbin.org/get")
.retrieve()
.body(String.class);
return ServerResponse.ok().contentType(MediaType.APPLICATION_JSON).body(body);
})
.GET("/httpbin/**", http("https://httpbin.org/"))
.before(stripPrefix(1))
.build();
}
This is logging:
INFO 93350 --- [issue-3525] [nio-8080-exec-1] c.e.issue_3525.Issue3525Application : Request headers: [user-agent:"IntelliJ HTTP Client/IntelliJ IDEA 2025.1 EAP", accept-encoding:"br, deflate, gzip, x-gzip", accept:"*/*", host:"localhost:8080"]
I can only reproduce the problem with the gateway route so I'm probably missing something. I'm also seeing the following on the CLI so this might be happening at the server level below Spring?
HTTP/1.1 400
Connection: close
Content-Language: en
Content-Length: 435
Content-Type: text/html;charset=utf-8
Date: Fri, 24 Jan 2025 16:23:34 GMT
<!doctype html><html lang="en"><head><title>HTTP Status 400 – Bad Request</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 400 – Bad Request</h1></body></html>