HttpServletRequest and getHeader (): how to properly handle case sensitive headers?

Since I found the HTTP headers to be intuitive as per RFCs, I was wondering how I can access the case-insensitive HTTP headers using Servlets. There is a #getHeader (String) method to get the header, but it turns out that this method handles sensitive header fields.

Is there a case insensitive way to get header fields? Or do I have to iterate over all the title fields to find the title field I was looking for?

+2


source to share


2 answers


What servlet container are you using? docs forgetHeader(String)

:

The header name is case insensitive.



so this sounds like a bug in the container you are using.

+8


source


tomcat 8.0.24 impl of getHeader delegates to "org.apache.tomcat.util.http.MimeHeaders", which ultimately calls this method, which in turn checks case insensitively.



 313  public  MessageBytes getValue ( String ) {
+1


source







All Articles