Package org.springframework.mock.web

# Class MockHttpServletRequest

java.lang.Object
org.springframework.mock.web.MockHttpServletRequest

All Implemented Interfaces:
  `HttpServletRequest`, `ServletRequest`

Direct Known Subclasses:
  `MockMultipartHttpServletRequest`

public class MockHttpServletRequest extends Object implements HttpServletRequest
Mock implementation of the `HttpServletRequest` interface.

The default, preferred `Locale` for the server mocked by this request is `Locale.ENGLISH`. This value can be changed via `addPreferredLocale(java.util.Locale)` or `setPreferredLocales(java.util.List<java.util.Locale>)`.

As of Spring 6.0, this set of mocks is designed on a Servlet 6.0 baseline.

Since:
  1.0.2
Author:
  Juergen Hoeller, Rod Johnson, Rick Evans, Mark Fisher, Chris Beams, Sam Brannen, Brian Clozel

## Field Summary

Fields
Modifier and Type
Field
Description
`static final String`
`DEFAULT_PROTOCOL`
The default protocol: 'HTTP/1.1'.
`static final String`
`DEFAULT_REMOTE_ADDR`
The default remote address: '127.0.0.1'.
`static final String`
`DEFAULT_REMOTE_HOST`
The default remote host: 'localhost'.
`static final String`
`DEFAULT_SCHEME`
The default scheme: 'http'.
`static final String`
`DEFAULT_SERVER_ADDR`
The default server address: '127.0.0.1'.
`static final String`
`DEFAULT_SERVER_NAME`
The default server name: 'localhost'.
`static final int`
`DEFAULT_SERVER_PORT`
The default server port: '80'.

### Fields inherited from interface jakarta.servlet.http.HttpServletRequest

`BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH`

## Constructor Summary

Constructors
Constructor
Description
`MockHttpServletRequest()`
Create a new `MockHttpServletRequest` with a default `MockServletContext`.
`MockHttpServletRequest(ServletContext servletContext)`
Create a new `MockHttpServletRequest` with the supplied `ServletContext`.
`MockHttpServletRequest(ServletContext servletContext, String method, String requestURI)`
Create a new `MockHttpServletRequest` with the supplied `ServletContext`, `method`, and `requestURI`.
`MockHttpServletRequest(String method, String requestURI)`
Create a new `MockHttpServletRequest` with a default `MockServletContext`.

## Method Summary

Modifier and Type
Method
Description
`void`
`addHeader(String name, Object value)`
Add an HTTP header entry for the given name.
`void`
`addParameter(String name, String value)`
Add a single value for the specified HTTP parameter.
`void`
`addParameter(String name, String... values)`
Add an array of values for the specified HTTP parameter.
`void`
`addParameters(Map<String,?> params)`
Add all provided parameters without replacing any existing values.
`void`
`addPart(Part part)`
`void`
`addPreferredLocale(Locale locale)`
Add a new preferred locale, before any existing locales.
`void`
`addUserRole(String role)`
`boolean`
`authenticate(HttpServletResponse response)`
`String`
`changeSessionId()`
The implementation of this (Servlet 3.1+) method calls `MockHttpSession.changeSessionId()` if the session is a mock session.
`protected void`
`checkActive()`
Check whether this request is still active (that is, not completed yet), throwing an IllegalStateException if not active anymore.
`void`
`clearAttributes()`
Clear all of this request's attributes.
`void`
`close()`
Mark this request as completed, keeping its state.
`AsyncContext`
`getAsyncContext()`
`Object`
`getAttribute(String name)`
`Enumeration<String>`
`getAttributeNames()`
`String`
`getAuthType()`
`String`
`getCharacterEncoding()`
`byte[]`
`getContentAsByteArray()`
Get the content of the request body as a byte array.
`String`
`getContentAsString()`
Get the content of the request body as a `String`, using the configured character encoding.
`int`
`getContentLength()`
`long`
`getContentLengthLong()`
`String`
`getContentType()`
`String`
`getContextPath()`
`Cookie[]`
`getCookies()`
`long`
`getDateHeader(String name)`
Return the long timestamp for the date header with the given `name`.
`DispatcherType`
`getDispatcherType()`
`String`
`getHeader(String name)`
`Enumeration<String>`
`getHeaderNames()`
`Enumeration<String>`
`getHeaders(String name)`
`HttpServletMapping`
`getHttpServletMapping()`
`ServletInputStream`
`getInputStream()`
`int`
`getIntHeader(String name)`
`String`
`getLocalAddr()`
`Locale`
`getLocale()`
Return the first preferred locale configured in this mock request.
`Enumeration<Locale>`
`getLocales()`
Return an enumeration of the preferred locales configured in this mock request.
`String`
`getLocalName()`
`int`
`getLocalPort()`
`String`
`getMethod()`
`String`
`getParameter(String name)`
`Map<String,String[]>`
`getParameterMap()`
`Enumeration<String>`
`getParameterNames()`
`String[]`
`getParameterValues(String name)`
`Part`
`getPart(String name)`
`Collection<Part>`
`getParts()`
`String`
`getPathInfo()`
`String`
`getPathTranslated()`
`String`
`getProtocol()`
`String`
`getProtocolRequestId()`
`String`
`getQueryString()`
`BufferedReader`
`getReader()`
`String`
`getRemoteAddr()`
`String`
`getRemoteHost()`
`int`
`getRemotePort()`
`String`
`getRemoteUser()`
`RequestDispatcher`
`getRequestDispatcher(String path)`
`String`
`getRequestedSessionId()`
`String`
`getRequestId()`
`String`
`getRequestURI()`
`StringBuffer`
`getRequestURL()`
`String`
`getScheme()`
`String`
`getServerName()`
`int`
`getServerPort()`
`ServletConnection`
`getServletConnection()`
`ServletContext`
`getServletContext()`
Return the ServletContext that this request is associated with.
`String`
`getServletPath()`
`HttpSession`
`getSession()`
`HttpSession`
`getSession(boolean create)`
`String`
`getUriTemplate()`
Return the original URI template used to prepare the request, if any.
`Principal`
`getUserPrincipal()`
`void`
`invalidate()`
Invalidate this request, clearing its state.
`boolean`
`isActive()`
Return whether this request is still active (that is, not completed yet).
`boolean`
`isAsyncStarted()`
`boolean`
`isAsyncSupported()`
`boolean`
`isRequestedSessionIdFromCookie()`
`boolean`
`isRequestedSessionIdFromURL()`
`boolean`
`isRequestedSessionIdValid()`
`boolean`
`isSecure()`
Return `true` if the `secure` flag has been set to `true` or if the `scheme` is `https`.
`boolean`
`isUserInRole(String role)`
`void`
`login(String username, String password)`
`void`
`logout()`
`void`
`removeAllParameters()`
Remove all existing parameters.
`void`
`removeAttribute(String name)`
`void`
`removeHeader(String name)`
Remove already registered entries for the specified HTTP header, if any.
`void`
`removeParameter(String name)`
Remove already registered values for the specified HTTP parameter, if any.
`void`
`setAsyncContext(MockAsyncContext asyncContext)`
`void`
`setAsyncStarted(boolean asyncStarted)`
`void`
`setAsyncSupported(boolean asyncSupported)`
`void`
`setAttribute(String name, Object value)`
`void`
`setAuthType(String authType)`
`void`
`setCharacterEncoding(String characterEncoding)`
`void`
`setContent(byte[] content)`
Set the content of the request body as a byte array.
`void`
`setContentType(String contentType)`
`void`
`setContextPath(String contextPath)`
`void`
`setCookies(Cookie... cookies)`
`void`
`setDispatcherType(DispatcherType dispatcherType)`
`void`
`setHttpServletMapping(HttpServletMapping httpServletMapping)`
`void`
`setLocalAddr(String localAddr)`
`void`
`setLocalName(String localName)`
`void`
`setLocalPort(int localPort)`
`void`
`setMethod(String method)`
`void`
`setParameter(String name, String value)`
Set a single value for the specified HTTP parameter.
`void`
`setParameter(String name, String... values)`
Set an array of values for the specified HTTP parameter.
`void`
`setParameters(Map<String,?> params)`
Set all provided parameters replacing any existing values for the provided parameter names.
`void`
`setPathInfo(String pathInfo)`
`void`
`setPreferredLocales(List<Locale> locales)`
Set the list of preferred locales, in descending order, effectively replacing any existing locales.
`void`
`setProtocol(String protocol)`
`void`
`setQueryString(String queryString)`
`void`
`setRemoteAddr(String remoteAddr)`
`void`
`setRemoteHost(String remoteHost)`
`void`
`setRemotePort(int remotePort)`
`void`
`setRemoteUser(String remoteUser)`
`void`
`setRequestedSessionId(String requestedSessionId)`
`void`
`setRequestedSessionIdFromCookie(boolean requestedSessionIdFromCookie)`
`void`
`setRequestedSessionIdFromURL(boolean requestedSessionIdFromURL)`
`void`
`setRequestedSessionIdValid(boolean requestedSessionIdValid)`
`void`
`setRequestURI(String requestURI)`
`void`
`setScheme(String scheme)`
`void`
`setSecure(boolean secure)`
Set the boolean `secure` flag indicating whether the mock request was made using a secure channel, such as HTTPS.
`void`
`setServerName(String serverName)`
`void`
`setServerPort(int serverPort)`
`void`
`setServletPath(String servletPath)`
`void`
`setSession(HttpSession session)`
`void`
`setUriTemplate(String uriTemplate)`
Set the original URI template used to prepare the request, if any.
`void`
`setUserPrincipal(Principal userPrincipal)`
`AsyncContext`
`startAsync()`
`AsyncContext`
`startAsync(ServletRequest request, ServletResponse response)`
`<T extends HttpUpgradeHandler>
T`
`upgrade(Class<T> handlerClass)`

### Methods inherited from class java.lang.Object

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

### Methods inherited from interface jakarta.servlet.http.HttpServletRequest

`getTrailerFields, isTrailerFieldsReady, newPushBuilder`

## Field Details

### DEFAULT_PROTOCOL

public static final String DEFAULT_PROTOCOL
The default protocol: 'HTTP/1.1'.

Since:
  4.3.7
See Also:
  - Constant Field Values

### DEFAULT_SCHEME

public static final String DEFAULT_SCHEME
The default scheme: 'http'.

Since:
  4.3.7
See Also:
  - Constant Field Values

### DEFAULT_SERVER_ADDR

public static final String DEFAULT_SERVER_ADDR
The default server address: '127.0.0.1'.

See Also:
  - Constant Field Values

### DEFAULT_SERVER_NAME

public static final String DEFAULT_SERVER_NAME
The default server name: 'localhost'.

See Also:
  - Constant Field Values

### DEFAULT_SERVER_PORT

public static final int DEFAULT_SERVER_PORT
The default server port: '80'.

See Also:
  - Constant Field Values

### DEFAULT_REMOTE_ADDR

public static final String DEFAULT_REMOTE_ADDR
The default remote address: '127.0.0.1'.

See Also:
  - Constant Field Values

### DEFAULT_REMOTE_HOST

public static final String DEFAULT_REMOTE_HOST
The default remote host: 'localhost'.

See Also:
  - Constant Field Values

## Constructor Details

### MockHttpServletRequest

public MockHttpServletRequest()
Create a new `MockHttpServletRequest` with a default `MockServletContext`.

See Also:
  - `MockHttpServletRequest(ServletContext, String, String)`

### MockHttpServletRequest

public MockHttpServletRequest(@Nullable String method, @Nullable String requestURI)
Create a new `MockHttpServletRequest` with a default `MockServletContext`.

Parameters:
  `method` - the request method (may be `null`)
  `requestURI` - the request URI (may be `null`)
See Also:
  - `setMethod(java.lang.String)`
  - `setRequestURI(java.lang.String)`
  - `MockHttpServletRequest(ServletContext, String, String)`

### MockHttpServletRequest

public MockHttpServletRequest(@Nullable ServletContext servletContext)
Create a new `MockHttpServletRequest` with the supplied `ServletContext`.

Parameters:
  `servletContext` - the ServletContext that the request runs in (may be `null` to use a default `MockServletContext`)
See Also:
  - `MockHttpServletRequest(ServletContext, String, String)`

### MockHttpServletRequest

public MockHttpServletRequest(@Nullable ServletContext servletContext, @Nullable String method, @Nullable String requestURI)
Create a new `MockHttpServletRequest` with the supplied `ServletContext`, `method`, and `requestURI`.

The preferred locale will be set to `Locale.ENGLISH`.

Parameters:
  `servletContext` - the ServletContext that the request runs in (may be `null` to use a default `MockServletContext`)
  `method` - the request method (may be `null`)
  `requestURI` - the request URI (may be `null`)
See Also:
  - `setMethod(java.lang.String)`
  - `setRequestURI(java.lang.String)`
  - `setPreferredLocales(java.util.List<java.util.Locale>)`
  - `MockServletContext`

## Method Details

### getServletContext

public ServletContext getServletContext()
Return the ServletContext that this request is associated with. (Not available in the standard HttpServletRequest interface for some reason.)

Specified by:
  `getServletContext` in interface `ServletRequest`

### isActive

public boolean isActive()
Return whether this request is still active (that is, not completed yet).

### close

public void close()
Mark this request as completed, keeping its state.

### invalidate

public void invalidate()
Invalidate this request, clearing its state.

### checkActive

protected void checkActive() throws IllegalStateException
Check whether this request is still active (that is, not completed yet), throwing an IllegalStateException if not active anymore.

Throws:
  `IllegalStateException`

### getAttribute

@Nullable public Object getAttribute(String name)

Specified by:
  `getAttribute` in interface `ServletRequest`

### getAttributeNames

public Enumeration<String> getAttributeNames()

Specified by:
  `getAttributeNames` in interface `ServletRequest`

### getCharacterEncoding

@Nullable public String getCharacterEncoding()

Specified by:
  `getCharacterEncoding` in interface `ServletRequest`

### setCharacterEncoding

public void setCharacterEncoding(@Nullable String characterEncoding)

Specified by:
  `setCharacterEncoding` in interface `ServletRequest`

### setContent

public void setContent(@Nullable byte[] content)
Set the content of the request body as a byte array.

If the supplied byte array represents text such as XML or JSON, the `character encoding` should typically be set as well.

See Also:
  - `setCharacterEncoding(String)`
  - `getContentAsByteArray()`
  - `getContentAsString()`

### getContentAsByteArray

@Nullable public byte[] getContentAsByteArray()
Get the content of the request body as a byte array.

Returns:
  the content as a byte array (potentially `null`)
Since:
  5.0
See Also:
  - `setContent(byte[])`
  - `getContentAsString()`

### getContentAsString

@Nullable public String getContentAsString() throws IllegalStateException, UnsupportedEncodingException
Get the content of the request body as a `String`, using the configured character encoding.

Returns:
  the content as a `String`, potentially `null`
Throws:
  `IllegalStateException` - if the character encoding has not been set
  `UnsupportedEncodingException` - if the character encoding is not supported
Since:
  5.0
See Also:
  - `setContent(byte[])`
  - `setCharacterEncoding(String)`
  - `getContentAsByteArray()`

### getContentLength

public int getContentLength()

Specified by:
  `getContentLength` in interface `ServletRequest`

### getContentLengthLong

public long getContentLengthLong()

Specified by:
  `getContentLengthLong` in interface `ServletRequest`

### setContentType

public void setContentType(@Nullable String contentType)

### getContentType

@Nullable public String getContentType()

Specified by:
  `getContentType` in interface `ServletRequest`

### getInputStream

public ServletInputStream getInputStream()

Specified by:
  `getInputStream` in interface `ServletRequest`

### setParameter

public void setParameter(String name, String value)
Set a single value for the specified HTTP parameter.

If there are already one or more values registered for the given parameter name, they will be replaced.

### setParameter

public void setParameter(String name, String... values)
Set an array of values for the specified HTTP parameter.

If there are already one or more values registered for the given parameter name, they will be replaced.

### setParameters

public void setParameters(Map<String,?> params)
Set all provided parameters replacing any existing values for the provided parameter names. To add without replacing existing values, use `addParameters(java.util.Map)`.

### addParameter

public void addParameter(String name, @Nullable String value)
Add a single value for the specified HTTP parameter.

If there are already one or more values registered for the given parameter name, the given value will be added to the end of the list.

### addParameter

public void addParameter(String name, String... values)
Add an array of values for the specified HTTP parameter.

If there are already one or more values registered for the given parameter name, the given values will be added to the end of the list.

### addParameters

public void addParameters(Map<String,?> params)
Add all provided parameters without replacing any existing values. To replace existing values, use `setParameters(java.util.Map)`.

### removeParameter

public void removeParameter(String name)
Remove already registered values for the specified HTTP parameter, if any.

### removeAllParameters

public void removeAllParameters()
Remove all existing parameters.

### getParameter

@Nullable public String getParameter(String name)

Specified by:
  `getParameter` in interface `ServletRequest`

### getParameterNames

public Enumeration<String> getParameterNames()

Specified by:
  `getParameterNames` in interface `ServletRequest`

### getParameterValues

@Nullable public String[] getParameterValues(String name)

Specified by:
  `getParameterValues` in interface `ServletRequest`

### getParameterMap

public Map<String,String[]> getParameterMap()

Specified by:
  `getParameterMap` in interface `ServletRequest`

### setProtocol

public void setProtocol(String protocol)

### getProtocol

public String getProtocol()

Specified by:
  `getProtocol` in interface `ServletRequest`

### setScheme

public void setScheme(String scheme)

### getScheme

public String getScheme()

Specified by:
  `getScheme` in interface `ServletRequest`

### setServerName

public void setServerName(String serverName)

### getServerName

public String getServerName()

Specified by:
  `getServerName` in interface `ServletRequest`

### setServerPort

public void setServerPort(int serverPort)

### getServerPort

public int getServerPort()

Specified by:
  `getServerPort` in interface `ServletRequest`

### getReader

public BufferedReader getReader() throws UnsupportedEncodingException

Specified by:
  `getReader` in interface `ServletRequest`
Throws:
  `UnsupportedEncodingException`

### setRemoteAddr

public void setRemoteAddr(String remoteAddr)

### getRemoteAddr

public String getRemoteAddr()

Specified by:
  `getRemoteAddr` in interface `ServletRequest`

### setRemoteHost

public void setRemoteHost(String remoteHost)

### getRemoteHost

public String getRemoteHost()

Specified by:
  `getRemoteHost` in interface `ServletRequest`

### setAttribute

public void setAttribute(String name, @Nullable Object value)

Specified by:
  `setAttribute` in interface `ServletRequest`

### removeAttribute

public void removeAttribute(String name)

Specified by:
  `removeAttribute` in interface `ServletRequest`

### clearAttributes

public void clearAttributes()
Clear all of this request's attributes.

### addPreferredLocale

public void addPreferredLocale(Locale locale)
Add a new preferred locale, before any existing locales.

See Also:
  - `setPreferredLocales(java.util.List<java.util.Locale>)`

### setPreferredLocales

public void setPreferredLocales(List<Locale> locales)
Set the list of preferred locales, in descending order, effectively replacing any existing locales.

Since:
  3.2
See Also:
  - `addPreferredLocale(java.util.Locale)`

### getLocale

public Locale getLocale()
Return the first preferred locale configured in this mock request.

If no locales have been explicitly configured, the default, preferred `Locale` for the server mocked by this request is `Locale.ENGLISH`.

In contrast to the Servlet specification, this mock implementation does not take into consideration any locales specified via the `Accept-Language` header.

Specified by:
  `getLocale` in interface `ServletRequest`
See Also:
  - `ServletRequest.getLocale()`
  - `addPreferredLocale(Locale)`
  - `setPreferredLocales(List)`

### getLocales

public Enumeration<Locale> getLocales()
Return an enumeration of the preferred locales configured in this mock request.

If no locales have been explicitly configured, the default, preferred `Locale` for the server mocked by this request is `Locale.ENGLISH`.

In contrast to the Servlet specification, this mock implementation does not take into consideration any locales specified via the `Accept-Language` header.

Specified by:
  `getLocales` in interface `ServletRequest`
See Also:
  - `ServletRequest.getLocales()`
  - `addPreferredLocale(Locale)`
  - `setPreferredLocales(List)`

### setSecure

public void setSecure(boolean secure)
Set the boolean `secure` flag indicating whether the mock request was made using a secure channel, such as HTTPS.

See Also:
  - `isSecure()`
  - `getScheme()`
  - `setScheme(String)`

### isSecure

public boolean isSecure()
Return `true` if the `secure` flag has been set to `true` or if the `scheme` is `https`.

Specified by:
  `isSecure` in interface `ServletRequest`
See Also:
  - `ServletRequest.isSecure()`

### getRequestDispatcher

public RequestDispatcher getRequestDispatcher(String path)

Specified by:
  `getRequestDispatcher` in interface `ServletRequest`

### setRemotePort

public void setRemotePort(int remotePort)

### getRemotePort

public int getRemotePort()

Specified by:
  `getRemotePort` in interface `ServletRequest`

### setLocalName

public void setLocalName(String localName)

### getLocalName

public String getLocalName()

Specified by:
  `getLocalName` in interface `ServletRequest`

### setLocalAddr

public void setLocalAddr(String localAddr)

### getLocalAddr

public String getLocalAddr()

Specified by:
  `getLocalAddr` in interface `ServletRequest`

### setLocalPort

public void setLocalPort(int localPort)

### getLocalPort

public int getLocalPort()

Specified by:
  `getLocalPort` in interface `ServletRequest`

### startAsync

public AsyncContext startAsync()

Specified by:
  `startAsync` in interface `ServletRequest`

### startAsync

public AsyncContext startAsync(ServletRequest request, @Nullable ServletResponse response)

Specified by:
  `startAsync` in interface `ServletRequest`

### setAsyncStarted

public void setAsyncStarted(boolean asyncStarted)

### isAsyncStarted

public boolean isAsyncStarted()

Specified by:
  `isAsyncStarted` in interface `ServletRequest`

### setAsyncSupported

public void setAsyncSupported(boolean asyncSupported)

### isAsyncSupported

public boolean isAsyncSupported()

Specified by:
  `isAsyncSupported` in interface `ServletRequest`

### setAsyncContext

public void setAsyncContext(@Nullable MockAsyncContext asyncContext)

### getAsyncContext

@Nullable public AsyncContext getAsyncContext()

Specified by:
  `getAsyncContext` in interface `ServletRequest`

### setDispatcherType

public void setDispatcherType(DispatcherType dispatcherType)

### getDispatcherType

public DispatcherType getDispatcherType()

Specified by:
  `getDispatcherType` in interface `ServletRequest`

### getRequestId

public String getRequestId()

Specified by:
  `getRequestId` in interface `ServletRequest`

### getProtocolRequestId

public String getProtocolRequestId()

Specified by:
  `getProtocolRequestId` in interface `ServletRequest`

### getServletConnection

public ServletConnection getServletConnection()

Specified by:
  `getServletConnection` in interface `ServletRequest`

### setAuthType

public void setAuthType(@Nullable String authType)

### getAuthType

@Nullable public String getAuthType()

Specified by:
  `getAuthType` in interface `HttpServletRequest`

### setCookies

public void setCookies(@Nullable Cookie... cookies)

### getCookies

@Nullable public Cookie[] getCookies()

Specified by:
  `getCookies` in interface `HttpServletRequest`

### addHeader

public void addHeader(String name, Object value)
Add an HTTP header entry for the given name.

While this method can take any `Object` as a parameter, it is recommended to use the following types:

- String or any Object to be converted using `toString()`; see `getHeader(java.lang.String)`.
- String, Number, or Date for date headers; see `getDateHeader(java.lang.String)`.
- String or Number for integer headers; see `getIntHeader(java.lang.String)`.
- `String[]` or `Collection<String>` for multiple values; see `getHeaders(java.lang.String)`.

See Also:
  - `getHeaderNames()`
  - `getHeaders(java.lang.String)`
  - `getHeader(java.lang.String)`
  - `getDateHeader(java.lang.String)`

### removeHeader

public void removeHeader(String name)
Remove already registered entries for the specified HTTP header, if any.

Since:
  4.3.20

### getDateHeader

public long getDateHeader(String name)
Return the long timestamp for the date header with the given `name`.

If the internal value representation is a String, this method will try to parse it as a date using the supported date formats:

- "EEE, dd MMM yyyy HH:mm:ss zzz"
- "EEE, dd-MMM-yy HH:mm:ss zzz"
- "EEE MMM dd HH:mm:ss yyyy"

Specified by:
  `getDateHeader` in interface `HttpServletRequest`
Parameters:
  `name` - the header name
See Also:
  - Section 7.1.1.1 of RFC 7231

### getHeader

@Nullable public String getHeader(String name)

Specified by:
  `getHeader` in interface `HttpServletRequest`

### getHeaders

public Enumeration<String> getHeaders(String name)

Specified by:
  `getHeaders` in interface `HttpServletRequest`

### getHeaderNames

public Enumeration<String> getHeaderNames()

Specified by:
  `getHeaderNames` in interface `HttpServletRequest`

### getIntHeader

public int getIntHeader(String name)

Specified by:
  `getIntHeader` in interface `HttpServletRequest`

### setMethod

public void setMethod(@Nullable String method)

### getMethod

@Nullable public String getMethod()

Specified by:
  `getMethod` in interface `HttpServletRequest`

### setPathInfo

public void setPathInfo(@Nullable String pathInfo)

### getPathInfo

@Nullable public String getPathInfo()

Specified by:
  `getPathInfo` in interface `HttpServletRequest`

### getPathTranslated

@Nullable public String getPathTranslated()

Specified by:
  `getPathTranslated` in interface `HttpServletRequest`

### setContextPath

public void setContextPath(String contextPath)

### getContextPath

public String getContextPath()

Specified by:
  `getContextPath` in interface `HttpServletRequest`

### setQueryString

public void setQueryString(@Nullable String queryString)

### getQueryString

@Nullable public String getQueryString()

Specified by:
  `getQueryString` in interface `HttpServletRequest`

### setRemoteUser

public void setRemoteUser(@Nullable String remoteUser)

### getRemoteUser

@Nullable public String getRemoteUser()

Specified by:
  `getRemoteUser` in interface `HttpServletRequest`

### addUserRole

public void addUserRole(String role)

### isUserInRole

public boolean isUserInRole(String role)

Specified by:
  `isUserInRole` in interface `HttpServletRequest`

### setUserPrincipal

public void setUserPrincipal(@Nullable Principal userPrincipal)

### getUserPrincipal

@Nullable public Principal getUserPrincipal()

Specified by:
  `getUserPrincipal` in interface `HttpServletRequest`

### setRequestedSessionId

public void setRequestedSessionId(@Nullable String requestedSessionId)

### getRequestedSessionId

@Nullable public String getRequestedSessionId()

Specified by:
  `getRequestedSessionId` in interface `HttpServletRequest`

### setUriTemplate

public void setUriTemplate(@Nullable String uriTemplate)
Set the original URI template used to prepare the request, if any.

Parameters:
  `uriTemplate` - the URI template used to set up the request, if any
Since:
  6.2

### getUriTemplate

@Nullable public String getUriTemplate()
Return the original URI template used to prepare the request, if any.

Since:
  6.2

### setRequestURI

public void setRequestURI(@Nullable String requestURI)

### getRequestURI

@Nullable public String getRequestURI()

Specified by:
  `getRequestURI` in interface `HttpServletRequest`

### getRequestURL

public StringBuffer getRequestURL()

Specified by:
  `getRequestURL` in interface `HttpServletRequest`

### setServletPath

public void setServletPath(String servletPath)

### getServletPath

public String getServletPath()

Specified by:
  `getServletPath` in interface `HttpServletRequest`

### setSession

public void setSession(HttpSession session)

### getSession

@Nullable public HttpSession getSession(boolean create)

Specified by:
  `getSession` in interface `HttpServletRequest`

### getSession

@Nullable public HttpSession getSession()

Specified by:
  `getSession` in interface `HttpServletRequest`

### changeSessionId

public String changeSessionId()
The implementation of this (Servlet 3.1+) method calls `MockHttpSession.changeSessionId()` if the session is a mock session. Otherwise it simply returns the current session id.

Specified by:
  `changeSessionId` in interface `HttpServletRequest`
Since:
  4.0.3

### setRequestedSessionIdValid

public void setRequestedSessionIdValid(boolean requestedSessionIdValid)

### isRequestedSessionIdValid

public boolean isRequestedSessionIdValid()

Specified by:
  `isRequestedSessionIdValid` in interface `HttpServletRequest`

### setRequestedSessionIdFromCookie

public void setRequestedSessionIdFromCookie(boolean requestedSessionIdFromCookie)

### isRequestedSessionIdFromCookie

public boolean isRequestedSessionIdFromCookie()

Specified by:
  `isRequestedSessionIdFromCookie` in interface `HttpServletRequest`

### setRequestedSessionIdFromURL

public void setRequestedSessionIdFromURL(boolean requestedSessionIdFromURL)

### isRequestedSessionIdFromURL

public boolean isRequestedSessionIdFromURL()

Specified by:
  `isRequestedSessionIdFromURL` in interface `HttpServletRequest`

### authenticate

public boolean authenticate(HttpServletResponse response) throws IOException, ServletException

Specified by:
  `authenticate` in interface `HttpServletRequest`
Throws:
  `IOException`
  `ServletException`

### login

public void login(String username, String password) throws ServletException

Specified by:
  `login` in interface `HttpServletRequest`
Throws:
  `ServletException`

### logout

public void logout() throws ServletException

Specified by:
  `logout` in interface `HttpServletRequest`
Throws:
  `ServletException`

### addPart

public void addPart(Part part)

### getPart

@Nullable public Part getPart(String name) throws IOException, ServletException

Specified by:
  `getPart` in interface `HttpServletRequest`
Throws:
  `IOException`
  `ServletException`

### getParts

public Collection<Part> getParts() throws IOException, ServletException

Specified by:
  `getParts` in interface `HttpServletRequest`
Throws:
  `IOException`
  `ServletException`

### setHttpServletMapping

public void setHttpServletMapping(@Nullable HttpServletMapping httpServletMapping)

### getHttpServletMapping

public HttpServletMapping getHttpServletMapping()

Specified by:
  `getHttpServletMapping` in interface `HttpServletRequest`

### upgrade

public <T extends HttpUpgradeHandler> T upgrade(Class<T> handlerClass) throws IOException, ServletException

Specified by:
  `upgrade` in interface `HttpServletRequest`
Throws:
  `IOException`
  `ServletException`