Skip to content

Change to when 'Content-Length: 0' is automatically added to a request #3603

@alzimmermsft

Description

@alzimmermsft

As part of an upgrade from Reactor Netty 1.0.48 to 1.2.1 we found a slight behavioral change to when Reactor Netty adds Content-Length: 0.

Using this simple reproduction:

public class ReactorNettyContentLength {
    public static void main(String[] args) {
        DisposableServer server = HttpServer.create().host("localhost").handle((request, response) -> {
            request.requestHeaders().forEach(header -> System.out.println(header.getKey() + ": " + header.getValue()));
            return response.status(200).send();
        }).bindNow();

        HttpClient httpClient = HttpClient.create();
        httpClient.request(HttpMethod.GET)
            .uri(server.host() + ":" + server.port())
            .send((request, outbound) -> {
                request.requestHeaders().set("Accept", "application/json");
                return outbound;
            })
            .response()
            .block();
    }
}

We found the headers logged by the HTTP server changed slightly.

1.0.48

user-agent: ReactorNetty/1.0.48
host: 127.0.0.1:58149
Accept: application/json

1.2.1

user-agent: ReactorNetty/1.2.1
host: 127.0.0.1:58062
Accept: application/json
content-length: 0

I don't hold a strong opinion on the correct behavior here and more so wanted to share this information in case this causes a problem for anyone else.

Metadata

Metadata

Assignees

Labels

type/bugA general bugwarn/regressionA regression from a previous release

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions