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

Request.Content.getContentType()'s Javadoc contradicts HttpConnection.normalizeRequest() #12639

Open
cowwoc opened this issue Dec 13, 2024 · 0 comments
Labels
Bug For general bugs on Jetty side

Comments

@cowwoc
Copy link
Contributor

cowwoc commented Dec 13, 2024

Jetty version(s)
12.0.15

Jetty Environment
N/A

Java version/vendor (use: java -version)
N/A

OS type/version
N/A

Description
Request.Content.getContentType()'s Javadoc reads:

[...] or null if the {@code Content-Type} header must not be set

but then HttpConnection.normalizeRequest contains this code:

            if (!headers.contains(HttpHeader.CONTENT_TYPE))
            {
                String contentType = content.getContentType();
                if (contentType == null)
                    contentType = getHttpClient().getDefaultRequestContentType();
                if (contentType != null)
                    request.addHeader(new HttpField(HttpHeader.CONTENT_TYPE, contentType));
            }

Meaning, if content.getContentType() returns null, then getHttpClient().getDefaultRequestContentType() is used. Only if the latter is also null is the content-type left unset.

Please ensure that the documentation and implementation match in this case.

@cowwoc cowwoc added the Bug For general bugs on Jetty side label Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For general bugs on Jetty side
Projects
None yet
Development

No branches or pull requests

1 participant