Skip to content

Content-Language Header is not added to http2 response #2146

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

Closed
11rx4f opened this issue Nov 19, 2021 · 0 comments · Fixed by #2147
Closed

Content-Language Header is not added to http2 response #2146

11rx4f opened this issue Nov 19, 2021 · 0 comments · Fixed by #2147

Comments

@11rx4f
Copy link
Contributor

11rx4f commented Nov 19, 2021

Problem Description

Content-Language Header is not added to http2 response despite using ServletResponse#setlocale().

setlocale.zip

  • Servlet App:
@WebServlet(urlPatterns = {"/sample"})
public class App extends HttpServlet {
  public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException {
    res.setLocale(Locale.ENGLISH);
    res.getWriter().println("Hello, World!");
  }
}
  • request via http2, the response does not have the Content-Language header:
# curl --http2 -s -k -i -X GET "http://localhost:8080/setlocale/sample"
HTTP/1.1 101 Switching Protocols
Server: Eclipse GlassFish  6.2.3 
X-Powered-By: Servlet/5.0 JSP/3.0(Eclipse GlassFish  6.2.3  Java/Eclipse Foundation/11)
Connection: Upgrade
Upgrade: h2c

HTTP/2 200 

Hello, World!

ServletResponse#setlocale() is described in the servlet spec as bellow(*), so I think it is a bug.:

In the case of HTTP, the locale is communicated via the Content-Language header, the character encoding as part of the Content-Type header for text media types.

(*) When accessed via http1.1, Content-Language Header is added to response as below:

# curl --http1.1 -s -k -i -X GET "http://localhost:8080/setlocale/sample"
HTTP/1.1 200 OK
Server: Eclipse GlassFish  6.2.3 
X-Powered-By: Servlet/5.0 JSP/3.0(Eclipse GlassFish  6.2.3  Java/Eclipse Foundation/11)
Content-Language: en
Content-Length: 14

Hello, World!

Environment

  • Server
    GlassFish (using grizzly-3.0.1 )
  • JDK
# java -version
openjdk version "11.0.12" 2021-07-20
OpenJDK Runtime Environment Temurin-11.0.12+7 (build 11.0.12+7)
OpenJDK 64-Bit Server VM Temurin-11.0.12+7 (build 11.0.12+7, mixed mode)
  • OS
    CentOS Linux release 7

Steps to reproduce by glassfish

  1. start-domain
  2. deploy app setlocale.war
# asadmin deploy setlocale.war
  1. Access app by follwing command.
#curl --http2 -s -k -i -X GET "http://localhost:8080/setlocale/sample"

Impact of issue

This is violation of the API spec.
https://javadoc.io/doc/jakarta.servlet/jakarta.servlet-api/latest/jakarta/servlet/ServletResponse.html#setLocale-java.util.Locale-

arjantijms added a commit that referenced this issue Mar 26, 2022
Fix #2146 Content-Language Header is not added to http2 response
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

Successfully merging a pull request may close this issue.

1 participant