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

Content-length set to -1 when it is not sent from the server #4965

Closed
kjezek opened this issue Jan 17, 2022 · 0 comments
Closed

Content-length set to -1 when it is not sent from the server #4965

kjezek opened this issue Jan 17, 2022 · 0 comments

Comments

@kjezek
Copy link
Contributor

kjezek commented Jan 17, 2022

When a request is triggered to a server endpoint, which does not provide Content-length, the ApacheConnector adds Content-length with the value equals to -1.

The problematic code is here:

if (headers.get(HttpHeaders.CONTENT_LENGTH) == null) {
headers.add(HttpHeaders.CONTENT_LENGTH, String.valueOf(entity.getContentLength()));
}

It should probably be:

                if (headers.get(HttpHeaders.CONTENT_LENGTH) == null && entity.getContentLength() > 0) {
                    headers.add(HttpHeaders.CONTENT_LENGTH, String.valueOf(entity.getContentLength()));
                }

The main problem is that the ApacheConnector generates the header value, which is against the specification, i.e. when the content length is not know, this header should not be provided at all, not provided with a negative value.

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

1 participant