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

Closed
cowwoc opened this issue Dec 13, 2024 · 0 comments · Fixed by #12773
Closed
Assignees
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
@sbordet sbordet self-assigned this Feb 5, 2025
sbordet added a commit that referenced this issue Feb 6, 2025
… HttpConnection.normalizeRequest()

Fixed javadocs.

Signed-off-by: Simone Bordet <[email protected]>
@sbordet sbordet moved this to 🏗 In progress in Jetty 12.0.17 - FROZEN Feb 6, 2025
@sbordet sbordet closed this as completed in 46c7b59 Feb 6, 2025
@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in Jetty 12.0.17 - FROZEN Feb 6, 2025
sbordet added a commit that referenced this issue Feb 9, 2025
… HttpConnection.normalizeRequest() (#12773)

Fixed javadocs.

Signed-off-by: Simone Bordet <[email protected]>
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
No open projects
Status: ✅ Done
2 participants