Uploaded image for project: 'Undertow'
  1. Undertow
  2. UNDERTOW-1280

HttpServletRequest.getLocalAddr and HttpServletRequest.getLocalName may return different results

XMLWordPrintable

      As described here, the HttpServletRequest.getLocalAddr and HttpServletRequest.getLocalName may return different results in case that Forwarded header is present in the HTTP request.

      Header value in request:

      Forwarded=for=192.121.210.60:455;proto=https;by=203.0.113.43:777

      What particular methods return in case of handler usage:

      HttpServerExchange.getSourceAddress() = /192.121.210.60:455
      HttpServerExchange.getRequestScheme() = https
      HttpServerExchange.getDestinationAddress() = /203.0.113.43:777

      Those are correct.

      Servlet case:

      HttpServletRequest.getRemoteAddr() = 192.121.210.60
      HttpServletRequest.getRemoteHost() = 192.121.210.60
      HttpServletRequest.getRemotePort() = 455
      HttpServletRequest.getScheme() = https
      HttpServletRequest.getLocalName() = 203.0.113.43
      HttpServletRequest.getLocalAddr() = 127.0.0.1
      HttpServletRequest.getLocalPort() = 8080

      Values of getLocalName() and getLocalAddr() should be the same, IMHO.

            sdouglas1@redhat.com Stuart Douglas
            jstourac@redhat.com Jan Stourac
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: