Class RemoteIpFilter.XForwardedRequest
java.lang.Object
jakarta.servlet.ServletRequestWrapper
jakarta.servlet.http.HttpServletRequestWrapper
org.apache.catalina.filters.RemoteIpFilter.XForwardedRequest
- All Implemented Interfaces:
HttpServletRequest, ServletRequest
- Enclosing class:
RemoteIpFilter
Wrapper for
HttpServletRequest that allows modification of headers, remote address,
scheme, and other properties used by the RemoteIpFilter.-
Field Summary
FieldsModifier and TypeFieldDescriptionMap of header names to their values.protected StringThe local name of the server.protected intThe local port of the server.protected StringThe remote address of the client.protected StringThe remote host of the client.protected StringThe scheme of the request.protected StringThe server name.protected intThe server port.Fields inherited from interface HttpServletRequest
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH -
Constructor Summary
ConstructorsConstructorDescriptionXForwardedRequest(HttpServletRequest request) Create a new XForwardedRequest wrapper. -
Method Summary
Modifier and TypeMethodDescriptionlonggetDateHeader(String name) The default behavior of this method is to return getDateHeader(String name) on the wrapped request object.The default behavior of this method is to return getHeader(String name) on the wrapped request object.getHeaderEntry(String name) Find the header entry for the given name (case-insensitive).The default behavior of this method is to return getHeaderNames() on the wrapped request object.getHeaders(String name) The default behavior of this method is to return getHeaders(String name) on the wrapped request object.intgetIntHeader(String name) The default behavior of this method is to return getIntHeader(String name) on the wrapped request object.The default behavior of this method is to return getLocalName() on the wrapped request object.intThe default behavior of this method is to return getLocalPort() on the wrapped request object.The default behavior of this method is to return getRemoteAddr() on the wrapped request object.The default behavior of this method is to return getRemoteHost() on the wrapped request object.The default behavior of this method is to return getRequestURL() on the wrapped request object.The default behavior of this method is to return getScheme() on the wrapped request object.The default behavior of this method is to return getServerName() on the wrapped request object.intThe default behavior of this method is to return getServerPort() on the wrapped request object.voidremoveHeader(String name) Remove a header by name.voidSet a header value.voidsetLocalName(String localName) Set the local name.voidsetLocalPort(int localPort) Set the local port.voidsetRemoteAddr(String remoteAddr) Set the remote address.voidsetRemoteHost(String remoteHost) Set the remote host.voidSet the scheme.voidsetSecure(boolean secure) Set whether the request is secure.voidsetServerName(String serverName) Set the server name.voidsetServerPort(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, isRequestedSessionIdValid, isTrailerFieldsReady, isUserInRole, login, logout, newPushBuilder, upgradeMethods inherited from class ServletRequestWrapper
getAsyncContext, getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentLengthLong, getContentType, getDispatcherType, getInputStream, getLocalAddr, getLocale, getLocales, getParameter, getParameterMap, getParameterNames, getParameterValues, getProtocol, getProtocolRequestId, getReader, getRemotePort, getRequest, getRequestDispatcher, getRequestId, getServletConnection, getServletContext, isAsyncStarted, isAsyncSupported, isSecure, isWrapperFor, isWrapperFor, removeAttribute, setAttribute, setCharacterEncoding, setCharacterEncoding, setRequest, startAsync, startAsyncMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ServletRequest
getAsyncContext, getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentLengthLong, getContentType, getDispatcherType, getInputStream, getLocalAddr, getLocale, getLocales, getParameter, getParameterMap, getParameterNames, getParameterValues, getProtocol, getProtocolRequestId, getReader, getRemotePort, getRequestDispatcher, getRequestId, getServletConnection, getServletContext, isAsyncStarted, isAsyncSupported, isSecure, removeAttribute, setAttribute, setCharacterEncoding, setCharacterEncoding, startAsync, startAsync
-
Field Details
-
headers
-
localName
The local name of the server. -
localPort
protected int localPortThe local port of the server. -
remoteAddr
The remote address of the client. -
remoteHost
The remote host of the client. -
scheme
The scheme of the request. -
serverName
The server name. -
serverPort
protected int serverPortThe server port.
-
-
Constructor Details
-
XForwardedRequest
Create a new XForwardedRequest wrapper.- Parameters:
request- the request to wrap
-
-
Method Details
-
getDateHeader
Description copied from class:jakarta.servlet.http.HttpServletRequestWrapperThe default behavior of this method is to return getDateHeader(String name) on the wrapped request object.- Specified by:
getDateHeaderin interfaceHttpServletRequest- Overrides:
getDateHeaderin classHttpServletRequestWrapper- Parameters:
name- aStringspecifying the name of the header- Returns:
- a
longvalue 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
Description copied from class:jakarta.servlet.http.HttpServletRequestWrapperThe default behavior of this method is to return getHeader(String name) on the wrapped request object.- Specified by:
getHeaderin interfaceHttpServletRequest- Overrides:
getHeaderin classHttpServletRequestWrapper- Parameters:
name- aStringspecifying the header name- Returns:
- a
Stringcontaining the value of the requested header, ornullif the request does not have a header of that name
-
getHeaderEntry
-
getHeaderNames
Description copied from class:jakarta.servlet.http.HttpServletRequestWrapperThe default behavior of this method is to return getHeaderNames() on the wrapped request object.- Specified by:
getHeaderNamesin interfaceHttpServletRequest- Overrides:
getHeaderNamesin classHttpServletRequestWrapper- 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
Description copied from class:jakarta.servlet.http.HttpServletRequestWrapperThe default behavior of this method is to return getHeaders(String name) on the wrapped request object.- Specified by:
getHeadersin interfaceHttpServletRequest- Overrides:
getHeadersin classHttpServletRequestWrapper- Parameters:
name- aStringspecifying the header name- Returns:
- an
Enumerationcontaining 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
Description copied from class:jakarta.servlet.http.HttpServletRequestWrapperThe default behavior of this method is to return getIntHeader(String name) on the wrapped request object.- Specified by:
getIntHeaderin interfaceHttpServletRequest- Overrides:
getIntHeaderin classHttpServletRequestWrapper- Parameters:
name- aStringspecifying 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
Description copied from class:jakarta.servlet.ServletRequestWrapperThe default behavior of this method is to return getLocalName() on the wrapped request object.- Specified by:
getLocalNamein interfaceServletRequest- Overrides:
getLocalNamein classServletRequestWrapper- Returns:
- a
Stringcontaining the host name of the IP on which the request was received.
-
getLocalPort
public int getLocalPort()Description copied from class:jakarta.servlet.ServletRequestWrapperThe default behavior of this method is to return getLocalPort() on the wrapped request object.- Specified by:
getLocalPortin interfaceServletRequest- Overrides:
getLocalPortin classServletRequestWrapper- Returns:
- an integer specifying the port number
-
getRemoteAddr
Description copied from class:jakarta.servlet.ServletRequestWrapperThe default behavior of this method is to return getRemoteAddr() on the wrapped request object.- Specified by:
getRemoteAddrin interfaceServletRequest- Overrides:
getRemoteAddrin classServletRequestWrapper- Returns:
- a
Stringcontaining the IP address of the client that sent the request
-
getRemoteHost
Description copied from class:jakarta.servlet.ServletRequestWrapperThe default behavior of this method is to return getRemoteHost() on the wrapped request object.- Specified by:
getRemoteHostin interfaceServletRequest- Overrides:
getRemoteHostin classServletRequestWrapper- Returns:
- a
Stringcontaining the fully qualified name of the client
-
getScheme
Description copied from class:jakarta.servlet.ServletRequestWrapperThe default behavior of this method is to return getScheme() on the wrapped request object.- Specified by:
getSchemein interfaceServletRequest- Overrides:
getSchemein classServletRequestWrapper- Returns:
- a
Stringcontaining the name of the scheme used to make this request
-
getServerName
Description copied from class:jakarta.servlet.ServletRequestWrapperThe default behavior of this method is to return getServerName() on the wrapped request object.- Specified by:
getServerNamein interfaceServletRequest- Overrides:
getServerNamein classServletRequestWrapper- Returns:
- a
Stringcontaining the name of the server
-
getServerPort
public int getServerPort()Description copied from class:jakarta.servlet.ServletRequestWrapperThe default behavior of this method is to return getServerPort() on the wrapped request object.- Specified by:
getServerPortin interfaceServletRequest- Overrides:
getServerPortin classServletRequestWrapper- Returns:
- an integer specifying the port number
-
removeHeader
Remove a header by name.- Parameters:
name- the header name to remove
-
setHeader
-
setLocalName
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
Set the remote address.- Parameters:
remoteAddr- the remote address
-
setRemoteHost
Set the remote host.- Parameters:
remoteHost- the remote host
-
setScheme
-
setSecure
public void setSecure(boolean secure) Set whether the request is secure.- Parameters:
secure- whether the request is secure
-
setServerName
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
Description copied from class:jakarta.servlet.http.HttpServletRequestWrapperThe default behavior of this method is to return getRequestURL() on the wrapped request object.- Specified by:
getRequestURLin interfaceHttpServletRequest- Overrides:
getRequestURLin classHttpServletRequestWrapper- Returns:
- a
StringBufferobject containing the reconstructed URL
-