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

netty is adding content-length=0 header in 204 response #13069

Closed
BrahmKauntey opened this issue Dec 20, 2022 · 2 comments
Closed

netty is adding content-length=0 header in 204 response #13069

BrahmKauntey opened this issue Dec 20, 2022 · 2 comments

Comments

@BrahmKauntey
Copy link

Expected behavior

A server MUST NOT send a Content-Length header field in any response
with a status code of 1xx (Informational) or 204 (No Content). A
server MUST NOT send a Content-Length header field in any 2xx
(Successful) response to a CONNECT request

Actual behavior

netty is adding content-length=0 header in 204 response

Steps to reproduce

Run a http request/response with response code 204.

Minimal yet complete reproducer code (or URL to code)

    @Override
    @RequestMapping("/**")
    public ResponseEntity<?> handleReq(RequestEntity<byte[]> reqEntity,
                    @RequestHeader HttpHeaders reqHeaders) {
            HttpHeaders responseHeaderMap = new HttpHeaders();
            responseHeaderMap.set("abc11", "xyz11");
            responseHeaderMap.set("abc12", "xyz12");
            responseHeaderMap.set("abc13", "xyz13");
            responseHeaderMap.set("abc14", "xyz14");

            return (new ResponseEntity<byte[]>(responseHeaderMap, HttpStatus.NO_CONTENT));
    }

Netty version

4.1.82

JVM version (e.g. java -version)

jdk:17.0.5

OS version (e.g. uname -a)

Linux 4.14.35-1818.3.3.el7uek.x86_64

@hyperxpro
Copy link
Contributor

Is Netty doing that or Spring?

@normanmaurer
Copy link
Member

Sorry but we need more info here. I suspect its spring that is doing this as need does not add this kind of headers automatically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants