https://bz.apache.org/bugzilla/show_bug.cgi?id=69967

            Bug ID: 69967
           Summary: ServletResponse#getHeader does not check contentType
                    field
           Product: Tomcat 11
           Version: unspecified
          Hardware: PC
                OS: Mac OS X 10.1
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: -------

org.apache.catalina.connector.Response has special handling for the
"Content-Type" header that sets the contentType and charset fields instead of
the headers. 

On the access side there is similar handling in containsHeader, but not in
getHeader, which is inconsistent and not intuitive. 

A sequence of setHeader and getHeader calls would return null. A call to
containsHeader that returns true would be followed by getHeader that return
null.

There is nothing I could find in the Javadoc to mention this special behavior
or what to expect. I didn't find anything in the Servlet spec either that talks
about direct access to the Content-Type header vs the contentType/charset
properties. 

I think it would be most intuitive is to always keep the header and the
properties  in sync internally, so Servlet API users can use any. This is
already what setHeader and containsHeader do, and getHeader seems to the
outlier.

In the absence of that, we are forced to always check both the header and the
properties even if on Tomcat the properties are what holds the source of truth,
as we are going through the Servlet API, we can't rely that it's always Tomcat.

-- 
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]

Reply via email to