Skip to content
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

Http client Type of JDK gives "empty headers are not allowed" with webmvc.fn #34314

Open
wimdeblauwe-swmu opened this issue Jan 24, 2025 · 3 comments
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: feedback-reminder We've sent a reminder that we need additional information before we can continue status: waiting-for-feedback We need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged or decided on

Comments

@wimdeblauwe-swmu
Copy link

I created this issue in response to spring-cloud/spring-cloud-gateway#3525 (comment). 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.

@bclozel
Copy link
Member

bclozel commented Jan 24, 2025

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>

@bclozel bclozel added status: waiting-for-feedback We need additional information before we can continue in: web Issues in web modules (web, webmvc, webflux, websocket) labels Jan 24, 2025
@wimdeblauwe-swmu
Copy link
Author

@spencergibb Can you add your reproducer here please?

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Jan 27, 2025
@bclozel bclozel added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels Jan 27, 2025
@spring-projects-issues
Copy link
Collaborator

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

@spring-projects-issues spring-projects-issues added the status: feedback-reminder We've sent a reminder that we need additional information before we can continue label Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: feedback-reminder We've sent a reminder that we need additional information before we can continue status: waiting-for-feedback We need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged or decided on
Projects
None yet
Development

No branches or pull requests

3 participants