You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Enrico Olivelli <eo...@gmail.com> on 2017/11/03 12:18:53 UTC

HttpServletRequest in AsyncContext does not handle X-Forwarded-For (RemoteIpValve)

Hi,
I am running a servlet and I get strange result for
HttpServletRequest#getRemoteAddr().

I have configured RemoteIpValve which handles the X-Forwarded-For header
and replaces the original IP address with the value contains in such header.

I have an HttpServlet which dispacts the execution to a custom threadpool
and uses request.startAsync()

It seems that if I call getRemoteAddr on the original HttpServletRequest
the value for getRemoteAddr() is correct, it contains the value of
X-Forwarded-For header.
When I call getRemoteAddr after calling startAsync() the result is the
original IP address of the request.

A workaround is to capture the IP Address early but I wonder if I am
missing something, if it is an expected behavior or if I should file an
issue.

I am using tomcat 8.5.15


Thanks
Enrico