RemoteIpFilter.XForwardedRequest (Apache Tomcat 9.0.120 API Documentation)
Description: declaration: package: org.apache.catalina.filters, class: RemoteIpFilter, class: XForwardedRequest

# Class RemoteIpFilter.XForwardedRequest

java.lang.Object
javax.servlet.ServletRequestWrapper
javax.servlet.http.HttpServletRequestWrapper
org.apache.catalina.filters.RemoteIpFilter.XForwardedRequest

All Implemented Interfaces:
  `HttpServletRequest, ServletRequest`

Enclosing class:
  `RemoteIpFilter`

public static class RemoteIpFilter.XForwardedRequest extends HttpServletRequestWrapper
Wrapper for `HttpServletRequest` that allows modification of headers, remote address, scheme, and other properties used by the RemoteIpFilter.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected final Map<String, List<String>>`
  `headers`
  Map of header names to their values.
  `protected String`
  `localName`
  The local name of the server.
  `protected int`
  `localPort`
  The local port of the server.
  `protected String`
  `remoteAddr`
  The remote address of the client.
  `protected String`
  `remoteHost`
  The remote host of the client.
  `protected String`
  `scheme`
  The scheme of the request.
  `protected String`
  `serverName`
  The server name.
  `protected int`
  `serverPort`
  The server port.

  ### Fields inherited from interface HttpServletRequest

  `BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `XForwardedRequest(HttpServletRequest request)`
  Create a new XForwardedRequest wrapper.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `long`
  `getDateHeader(String name)`
  The default behavior of this method is to return getDateHeader(String name) on the wrapped request object.
  `String`
  `getHeader(String name)`
  The default behavior of this method is to return getHeader(String name) on the wrapped request object.
  `protected Map.Entry<String, List<String>>`
  `getHeaderEntry(String name)`
  Find the header entry for the given name (case-insensitive).
  `Enumeration<String>`
  `getHeaderNames()`
  The default behavior of this method is to return getHeaderNames() on the wrapped request object.
  `Enumeration<String>`
  `getHeaders(String name)`
  The default behavior of this method is to return getHeaders(String name) on the wrapped request object.
  `int`
  `getIntHeader(String name)`
  The default behavior of this method is to return getIntHeader(String name) on the wrapped request object.
  `String`
  `getLocalName()`
  The default behavior of this method is to return getLocalName() on the wrapped request object.
  `int`
  `getLocalPort()`
  The default behavior of this method is to return getLocalPort() on the wrapped request object.
  `String`
  `getRemoteAddr()`
  The default behavior of this method is to return getRemoteAddr() on the wrapped request object.
  `String`
  `getRemoteHost()`
  The default behavior of this method is to return getRemoteHost() on the wrapped request object.
  `StringBuffer`
  `getRequestURL()`
  The default behavior of this method is to return getRequestURL() on the wrapped request object.
  `String`
  `getScheme()`
  The default behavior of this method is to return getScheme() on the wrapped request object.
  `String`
  `getServerName()`
  The default behavior of this method is to return getServerName() on the wrapped request object.
  `int`
  `getServerPort()`
  The default behavior of this method is to return getServerPort() on the wrapped request object.
  `PushBuilder`
  `newPushBuilder()`
  Obtain a builder for generating push requests.
  `void`
  `removeHeader(String name)`
  Remove a header by name.
  `void`
  `setHeader(String name, String value)`
  Set a header value.
  `void`
  `setLocalName(String localName)`
  Set the local name.
  `void`
  `setLocalPort(int localPort)`
  Set the local port.
  `void`
  `setRemoteAddr(String remoteAddr)`
  Set the remote address.
  `void`
  `setRemoteHost(String remoteHost)`
  Set the remote host.
  `void`
  `setScheme(String scheme)`
  Set the scheme.
  `void`
  `setSecure(boolean secure)`
  Set whether the request is secure.
  `void`
  `setServerName(String serverName)`
  Set the server name.
  `void`
  `setServerPort(int serverPort)`
  Set the server port.

  ### Methods inherited from class HttpServletRequestWrapper

  `authenticate, changeSessionId, getAuthType, getContextPath, getCookies, getHttpServletMapping, getMethod, getPart, getParts, getPathInfo, getPathTranslated, getQueryString, getRemoteUser, getRequestedSessionId, getRequestURI, getServletPath, getSession, getSession, getTrailerFields, getUserPrincipal, isRequestedSessionIdFromCookie, isRequestedSessionIdFromUrl, isRequestedSessionIdFromURL, isRequestedSessionIdValid, isTrailerFieldsReady, isUserInRole, login, logout, upgrade`

  ### Methods inherited from class ServletRequestWrapper

  `getAsyncContext, getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentLengthLong, getContentType, getDispatcherType, getInputStream, getLocalAddr, getLocale, getLocales, getParameter, getParameterMap, getParameterNames, getParameterValues, getProtocol, getReader, getRealPath, getRemotePort, getRequest, getRequestDispatcher, getServletContext, isAsyncStarted, isAsyncSupported, isSecure, isWrapperFor, isWrapperFor, removeAttribute, setAttribute, setCharacterEncoding, setRequest, startAsync, startAsync`

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface ServletRequest

  `getAsyncContext, getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentLengthLong, getContentType, getDispatcherType, getInputStream, getLocalAddr, getLocale, getLocales, getParameter, getParameterMap, getParameterNames, getParameterValues, getProtocol, getReader, getRealPath, getRemotePort, getRequestDispatcher, getServletContext, isAsyncStarted, isAsyncSupported, isSecure, removeAttribute, setAttribute, setCharacterEncoding, startAsync, startAsync`

- ## Field Details

  - ### headers

    protected final Map<String, List<String>> headers
    Map of header names to their values.

  - ### localName

    protected String localName
    The local name of the server.

  - ### localPort

    protected int localPort
    The local port of the server.

  - ### remoteAddr

    protected String remoteAddr
    The remote address of the client.

  - ### remoteHost

    protected String remoteHost
    The remote host of the client.

  - ### scheme

    protected String scheme
    The scheme of the request.

  - ### serverName

    protected String serverName
    The server name.

  - ### serverPort

    protected int serverPort
    The server port.

- ## Constructor Details

  - ### XForwardedRequest

    public XForwardedRequest(HttpServletRequest request)
    Create a new XForwardedRequest wrapper.
    Parameters:
      `request` - the request to wrap

- ## Method Details

  - ### getDateHeader

    public long getDateHeader(String name)
    Description copied from class: `javax.servlet.http.HttpServletRequestWrapper`
    The default behavior of this method is to return getDateHeader(String name) on the wrapped request object.
    Specified by:
      `getDateHeader` in interface `HttpServletRequest`
    Overrides:
      `getDateHeader` in class `HttpServletRequestWrapper`
    Parameters:
      `name` - a `String` specifying the name of the header
    Returns:
      a `long` value representing the date specified in the header expressed as the number of milliseconds since January 1, 1970 GMT, or -1 if the named header was not included with the request

  - ### getHeader

    public String getHeader(String name)
    Description copied from class: `javax.servlet.http.HttpServletRequestWrapper`
    The default behavior of this method is to return getHeader(String name) on the wrapped request object.
    Specified by:
      `getHeader` in interface `HttpServletRequest`
    Overrides:
      `getHeader` in class `HttpServletRequestWrapper`
    Parameters:
      `name` - a `String` specifying the header name
    Returns:
      a `String` containing the value of the requested header, or `null` if the request does not have a header of that name

  - ### getHeaderEntry

    protected Map.Entry<String, List<String>> getHeaderEntry(String name)
    Find the header entry for the given name (case-insensitive).
    Parameters:
      `name` - the header name to look up
    Returns:
      the header entry, or `null` if not found

  - ### getHeaderNames

    public Enumeration<String> getHeaderNames()
    Description copied from class: `javax.servlet.http.HttpServletRequestWrapper`
    The default behavior of this method is to return getHeaderNames() on the wrapped request object.
    Specified by:
      `getHeaderNames` in interface `HttpServletRequest`
    Overrides:
      `getHeaderNames` in class `HttpServletRequestWrapper`
    Returns:
      an enumeration of all the header names sent with this request; if the request has no headers, an empty enumeration; if the servlet container does not allow servlets to use this method, `null`

  - ### getHeaders

    public Enumeration<String> getHeaders(String name)
    Description copied from class: `javax.servlet.http.HttpServletRequestWrapper`
    The default behavior of this method is to return getHeaders(String name) on the wrapped request object.
    Specified by:
      `getHeaders` in interface `HttpServletRequest`
    Overrides:
      `getHeaders` in class `HttpServletRequestWrapper`
    Parameters:
      `name` - a `String` specifying the header name
    Returns:
      an `Enumeration` containing the values of the requested header. If the request does not have any headers of that name return an empty enumeration. If the container does not allow access to header information, return null

  - ### getIntHeader

    public int getIntHeader(String name)
    Description copied from class: `javax.servlet.http.HttpServletRequestWrapper`
    The default behavior of this method is to return getIntHeader(String name) on the wrapped request object.
    Specified by:
      `getIntHeader` in interface `HttpServletRequest`
    Overrides:
      `getIntHeader` in class `HttpServletRequestWrapper`
    Parameters:
      `name` - a `String` specifying the name of a request header
    Returns:
      an integer expressing the value of the request header or -1 if the request doesn't have a header of this name

  - ### getLocalName

    public String getLocalName()
    Description copied from class: `javax.servlet.ServletRequestWrapper`
    The default behavior of this method is to return getLocalName() on the wrapped request object.
    Specified by:
      `getLocalName` in interface `ServletRequest`
    Overrides:
      `getLocalName` in class `ServletRequestWrapper`
    Returns:
      a `String` containing the host name of the IP on which the request was received.

  - ### getLocalPort

    public int getLocalPort()
    Description copied from class: `javax.servlet.ServletRequestWrapper`
    The default behavior of this method is to return getLocalPort() on the wrapped request object.
    Specified by:
      `getLocalPort` in interface `ServletRequest`
    Overrides:
      `getLocalPort` in class `ServletRequestWrapper`
    Returns:
      an integer specifying the port number

  - ### getRemoteAddr

    public String getRemoteAddr()
    Description copied from class: `javax.servlet.ServletRequestWrapper`
    The default behavior of this method is to return getRemoteAddr() on the wrapped request object.
    Specified by:
      `getRemoteAddr` in interface `ServletRequest`
    Overrides:
      `getRemoteAddr` in class `ServletRequestWrapper`
    Returns:
      a `String` containing the IP address of the client that sent the request

  - ### getRemoteHost

    public String getRemoteHost()
    Description copied from class: `javax.servlet.ServletRequestWrapper`
    The default behavior of this method is to return getRemoteHost() on the wrapped request object.
    Specified by:
      `getRemoteHost` in interface `ServletRequest`
    Overrides:
      `getRemoteHost` in class `ServletRequestWrapper`
    Returns:
      a `String` containing the fully qualified name of the client

  - ### getScheme

    public String getScheme()
    Description copied from class: `javax.servlet.ServletRequestWrapper`
    The default behavior of this method is to return getScheme() on the wrapped request object.
    Specified by:
      `getScheme` in interface `ServletRequest`
    Overrides:
      `getScheme` in class `ServletRequestWrapper`
    Returns:
      a `String` containing the name of the scheme used to make this request

  - ### getServerName

    public String getServerName()
    Description copied from class: `javax.servlet.ServletRequestWrapper`
    The default behavior of this method is to return getServerName() on the wrapped request object.
    Specified by:
      `getServerName` in interface `ServletRequest`
    Overrides:
      `getServerName` in class `ServletRequestWrapper`
    Returns:
      a `String` containing the name of the server

  - ### getServerPort

    public int getServerPort()
    Description copied from class: `javax.servlet.ServletRequestWrapper`
    The default behavior of this method is to return getServerPort() on the wrapped request object.
    Specified by:
      `getServerPort` in interface `ServletRequest`
    Overrides:
      `getServerPort` in class `ServletRequestWrapper`
    Returns:
      an integer specifying the port number

  - ### removeHeader

    public void removeHeader(String name)
    Remove a header by name.
    Parameters:
      `name` - the header name to remove

  - ### setHeader

    public void setHeader(String name, String value)
    Set a header value.
    Parameters:
      `name` - the header name
      `value` - the header value

  - ### setLocalName

    public void setLocalName(String localName)
    Set the local name.
    Parameters:
      `localName` - the local name

  - ### setLocalPort

    public void setLocalPort(int localPort)
    Set the local port.
    Parameters:
      `localPort` - the local port

  - ### setRemoteAddr

    public void setRemoteAddr(String remoteAddr)
    Set the remote address.
    Parameters:
      `remoteAddr` - the remote address

  - ### setRemoteHost

    public void setRemoteHost(String remoteHost)
    Set the remote host.
    Parameters:
      `remoteHost` - the remote host

  - ### setScheme

    public void setScheme(String scheme)
    Set the scheme.
    Parameters:
      `scheme` - the scheme

  - ### setSecure

    public void setSecure(boolean secure)
    Set whether the request is secure.
    Parameters:
      `secure` - whether the request is secure

  - ### setServerName

    public void setServerName(String serverName)
    Set the server name.
    Parameters:
      `serverName` - the server name

  - ### setServerPort

    public void setServerPort(int serverPort)
    Set the server port.
    Parameters:
      `serverPort` - the server port

  - ### getRequestURL

    public StringBuffer getRequestURL()
    Description copied from class: `javax.servlet.http.HttpServletRequestWrapper`
    The default behavior of this method is to return getRequestURL() on the wrapped request object.
    Specified by:
      `getRequestURL` in interface `HttpServletRequest`
    Overrides:
      `getRequestURL` in class `HttpServletRequestWrapper`
    Returns:
      a `StringBuffer` object containing the reconstructed URL

  - ### newPushBuilder

    public PushBuilder newPushBuilder()
    Description copied from class: `javax.servlet.http.HttpServletRequestWrapper`
    Obtain a builder for generating push requests. `PushBuilder` documents how this request will be used as the basis for a push request. Each call to this method will return a new instance, independent of any previous instance obtained.

    The default behavior of this method is to return `HttpServletRequest.newPushBuilder()` on the wrapped request object.

    Specified by:
      `newPushBuilder` in interface `HttpServletRequest`
    Overrides:
      `newPushBuilder` in class `HttpServletRequestWrapper`
    Returns:
      A builder that can be used to generate push requests based on this request or `null` if push is not supported. Note that even if a PushBuilder instance is returned, by the time that `PushBuilder.push()` is called, it may no longer be valid to push a request and the push request will be ignored.