https://bz.apache.org/bugzilla/show_bug.cgi?id=61916
Bug ID: 61916
Summary: AddDefaultCharsetFilter wouldn't work when setting
response header through response.setHeader()
Product: Tomcat 8
Version: 8.5.23
Hardware: PC
Status: NEW
Severity: normal
Priority: P2
Component: Catalina
Assignee: [email protected]
Reporter: [email protected]
Target Milestone: ----
Overview:
AddDefaultCharsetFilter wouldn't work if one set response header 'content-type'
through setHeader() instead of setContentType().
I tried to debug the webapp by adding a breakpoint in be beginning of method
AddDefaultCharsetFilter.ResponseWrapper#setContentType(String), while the CXF
framework did't invoke setContentType().
So I think that cxf may set response header Content-Type by invoking
setHeader() but there is not a overridden method setHeader() in class
AddDefaultCharsetFilter.ResponseWrapper
Steps to Reproduce:
1) Adding a maven dependecy in pom.xml
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-catalina</artifactId>
<version>8.5.23</version>
<scope>provided</scope>
</dependency>
2) Adding a filter registeration in web.xml
<filter>
<filter-name>AddDefaultCharset</filter-name>
<filter-class>org.apache.catalina.filters.AddDefaultCharsetFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>AddDefaultCharset</filter-name>
<servlet-name>cxf</servlet-name>
</filter-mapping>
3) Adding a method in cxf jax-rs service bean UserResource.java
@Path("hello")
@Produces(MediaType.TEXT_PLAIN)
public Response hello(){
return Response.ok("hello").build();
}
4) request the hello service
Actual Results:
Content-Type: text/plain
Expected Results:
Content-Type: text/plain;charset=UTF-8
Build Date & Hardware:
Additional Builds and Platforms:
Additional Information:
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]