0

For example, I want to get the authorization header from the request. What's the difference between the following two calls except the return type?

import org.apache.catalina.connector.Request;
request.getCoyoteRequest().getMimeHeaders().getValue("Authorization");
request.getHeader("Authorization");

Thanks!

wero
  • 32,544
  • 3
  • 59
  • 84
snowery
  • 468
  • 1
  • 6
  • 18

1 Answers1

1

There is no difference between those two calls (except the return type).

wero
  • 32,544
  • 3
  • 59
  • 84
  • Thanks for you reply. They are doing the same job, right? Could you please explain more about under what situation should I use getMimeHeaders instead of getHeader? – snowery Feb 03 '16 at 22:03
  • 1
    @snowery the one allows you to use a `MessageBytes` object the other the `MessageBytes` converted to a string. Tomcat tries to postpone conversion of the header bytes to a string (maybe it is never used!). So if you don't need the string value use the `MessageBytes` API to save some CPU cycles. – wero Feb 03 '16 at 22:16
  • Thank you so much for the explanation! – snowery Feb 04 '16 at 00:27