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

Why is the Connection header missing in the WebFlux netty-server response? #24270

Closed
ldwqh0 opened this issue Dec 27, 2019 · 1 comment
Closed
Assignees
Labels
for: external-project Needs a fix in external project in: web Issues in web modules (web, webmvc, webflux, websocket)

Comments

@ldwqh0
Copy link

ldwqh0 commented Dec 27, 2019

I have a very simple application with WebFlux.

package com.example.demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import reactor.core.publisher.Mono;

@RestController
@SpringBootApplication
public class DemoNettyApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoNettyApplication.class, args);
    }

    @GetMapping("/hello")
    public Mono<String> test() {
        return Mono.<String>just("hello");
    }
}

When I test the request with Chrome, I found that the response lost the Connect header. There are only 2 headers in my response header.

HTTP/1.1 200 OK
Content-Type: text/html;charset=UTF-8
Content-Length: 5

When I test the same application with Undertow as the server, there are 4 headers.

HTTP/1.1 200 OK
Connection: keep-alive
Content-Type: text/html;charset=UTF-8
Content-Length: 5
Date: Fri, 27 Dec 2019 12:18:57 GMT

It looks like it lost the Connection header. The Connection header is very important.

Why is the Connection header present in the response when using Undertow but not when using Netty?

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Dec 27, 2019
@ldwqh0 ldwqh0 changed the title There is no connection in webflux netty-server response. There is no Connection header in webflux netty-server response. Dec 27, 2019
@sbrannen sbrannen added the in: web Issues in web modules (web, webmvc, webflux, websocket) label Dec 27, 2019
@sbrannen sbrannen changed the title There is no Connection header in webflux netty-server response. Why is the Connection header missing in the webflux netty-server response? Dec 27, 2019
@sbrannen sbrannen changed the title Why is the Connection header missing in the webflux netty-server response? Why is the Connection header missing in the WebFlux netty-server response? Dec 27, 2019
@rstoyanchev rstoyanchev self-assigned this Jan 3, 2020
@rstoyanchev
Copy link
Contributor

I suspect this is related to the lack of support for HTTP 1.0 in Reactor netty, see reactor/reactor-netty#21. In 1.0 "Connection: keep-alive" must be set for persistent connections, but in 1.1 it is assumed by default.

In any case this isn't something related to WebFlux itself. If you have a specific issue please discuss under the Reactor Netty ticket.

@rstoyanchev rstoyanchev added for: external-project Needs a fix in external project and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jan 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: external-project Needs a fix in external project in: web Issues in web modules (web, webmvc, webflux, websocket)
Projects
None yet
Development

No branches or pull requests

4 participants