Class ServerlessHttpServletRequest
java.lang.Object
org.springframework.cloud.function.serverless.web.ServerlessHttpServletRequest
- All Implemented Interfaces:
jakarta.servlet.http.HttpServletRequest, jakarta.servlet.ServletRequest
public class ServerlessHttpServletRequest
extends Object
implements jakarta.servlet.http.HttpServletRequest
- Author:
- Oleg Zhurakousky
-
Field Summary
Fields inherited from interface jakarta.servlet.http.HttpServletRequest
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH -
Constructor Summary
ConstructorsConstructorDescriptionServerlessHttpServletRequest(jakarta.servlet.ServletContext servletContext, String method, String requestURI) -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidaddHeaders(org.springframework.util.MultiValueMap<String, String> headers) voidaddParameter(String name, String value) Add a single value for the specified HTTP parameter.voidaddParameter(String name, String... values) Add an array of values for the specified HTTP parameter.voidaddParameters(Map<String, ?> params) Add all provided parameters without replacing any existing values.voidaddPart(jakarta.servlet.http.Part part) voidaddUserRole(String role) booleanauthenticate(jakarta.servlet.http.HttpServletResponse response) voidClear all of this request's attributes.jakarta.servlet.AsyncContextgetAttribute(String name) byte[]Get the content of the request body as a byte array.Get the content of the request body as aString, using the configured character encoding.intlongjakarta.servlet.http.Cookie[]longgetDateHeader(String name) jakarta.servlet.DispatcherTypegetHeaders(String name) jakarta.servlet.ServletInputStreamintgetIntHeader(String name) Return the first preferred locale configured in this mock request.Return an enumeration of the preferred locales configured in this mock request.intgetParameter(String name) String[]getParameterValues(String name) jakarta.servlet.http.PartCollection<jakarta.servlet.http.Part> getParts()intjakarta.servlet.RequestDispatchergetRequestDispatcher(String path) intjakarta.servlet.ServletConnectionjakarta.servlet.ServletContextReturn the ServletContext that this request is associated with.jakarta.servlet.http.HttpSessionjakarta.servlet.http.HttpSessiongetSession(boolean create) booleanbooleanbooleanbooleanbooleanbooleanisSecure()booleanisUserInRole(String role) voidvoidlogout()voidRemove all existing parameters.voidremoveAttribute(String name) voidremoveParameter(String name) Remove already registered values for the specified HTTP parameter, if any.voidsetAsyncContext(jakarta.servlet.AsyncContext asyncContext) voidsetAsyncStarted(boolean asyncStarted) voidsetAsyncSupported(boolean asyncSupported) voidsetAttribute(String name, Object value) voidsetAuthType(String authType) voidsetCharacterEncoding(String characterEncoding) voidsetContent(byte[] content) Set the content of the request body as a byte array.voidsetContentType(String contentType) voidsetContextPath(String contextPath) voidsetDispatcherType(jakarta.servlet.DispatcherType dispatcherType) voidvoidsetHeaders(org.springframework.util.MultiValueMap<String, String> headers) voidsetLocalAddr(String localAddr) voidsetLocalName(String localName) voidsetLocalPort(int localPort) voidvoidsetParameter(String name, String value) Set a single value for the specified HTTP parameter.voidsetParameter(String name, String... values) Set an array of values for the specified HTTP parameter.voidsetParameters(Map<String, ?> params) Set all provided parameters replacing any existing values for the provided parameter names.voidsetPathInfo(String pathInfo) voidsetQueryString(String queryString) voidsetRemoteAddr(String remoteAddr) voidsetRemoteHost(String remoteHost) voidsetRemotePort(int remotePort) voidsetRemoteUser(String remoteUser) voidsetRequestedSessionId(String requestedSessionId) voidsetRequestedSessionIdFromCookie(boolean requestedSessionIdFromCookie) voidsetRequestedSessionIdFromURL(boolean requestedSessionIdFromURL) voidsetRequestedSessionIdValid(boolean requestedSessionIdValid) voidsetRequestURI(String requestURI) voidsetServerName(String serverName) voidsetServerPort(int serverPort) voidsetServletPath(String servletPath) voidsetSession(jakarta.servlet.http.HttpSession session) voidsetUserPrincipal(Principal userPrincipal) jakarta.servlet.AsyncContextjakarta.servlet.AsyncContextstartAsync(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response) toString()<T extends jakarta.servlet.http.HttpUpgradeHandler>
TMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface jakarta.servlet.http.HttpServletRequest
getHttpServletMapping, getTrailerFields, isTrailerFieldsReady, newPushBuilderMethods inherited from interface jakarta.servlet.ServletRequest
setCharacterEncoding
-
Constructor Details
-
ServerlessHttpServletRequest
-
-
Method Details
-
toString
-
getServletContext
public jakarta.servlet.ServletContext getServletContext()Return the ServletContext that this request is associated with. (Not available in the standard HttpServletRequest interface for some reason.)- Specified by:
getServletContextin interfacejakarta.servlet.ServletRequest
-
getAttribute
-
getAttributeNames
- Specified by:
getAttributeNamesin interfacejakarta.servlet.ServletRequest
-
getCharacterEncoding
- Specified by:
getCharacterEncodingin interfacejakarta.servlet.ServletRequest
-
setCharacterEncoding
- Specified by:
setCharacterEncodingin interfacejakarta.servlet.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 encodingshould typically be set as well.- See Also:
-
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:
-
getContentAsString
@Nullable public String getContentAsString() throws IllegalStateException, UnsupportedEncodingExceptionGet the content of the request body as aString, using the configured character encoding.- Returns:
- the content as a
String, potentiallynull - Throws:
IllegalStateException- if the character encoding has not been setUnsupportedEncodingException- if the character encoding is not supported- Since:
- 5.0
- See Also:
-
getContentLength
public int getContentLength()- Specified by:
getContentLengthin interfacejakarta.servlet.ServletRequest
-
getContentLengthLong
public long getContentLengthLong()- Specified by:
getContentLengthLongin interfacejakarta.servlet.ServletRequest
-
setContentType
-
getContentType
- Specified by:
getContentTypein interfacejakarta.servlet.ServletRequest
-
getInputStream
public jakarta.servlet.ServletInputStream getInputStream()- Specified by:
getInputStreamin interfacejakarta.servlet.ServletRequest
-
setParameter
-
setParameter
-
setParameters
Set all provided parameters replacing any existing values for the provided parameter names. To add without replacing existing values, useaddParameters(java.util.Map). -
addParameter
-
addParameter
-
addParameters
Add all provided parameters without replacing any existing values. To replace existing values, usesetParameters(java.util.Map). -
removeParameter
Remove already registered values for the specified HTTP parameter, if any. -
removeAllParameters
public void removeAllParameters()Remove all existing parameters. -
getParameter
-
getParameterNames
- Specified by:
getParameterNamesin interfacejakarta.servlet.ServletRequest
-
getParameterValues
-
getParameterMap
-
getProtocol
- Specified by:
getProtocolin interfacejakarta.servlet.ServletRequest
-
getScheme
- Specified by:
getSchemein interfacejakarta.servlet.ServletRequest
-
setServerName
-
getServerName
- Specified by:
getServerNamein interfacejakarta.servlet.ServletRequest
-
setServerPort
public void setServerPort(int serverPort) -
getServerPort
public int getServerPort()- Specified by:
getServerPortin interfacejakarta.servlet.ServletRequest
-
getReader
- Specified by:
getReaderin interfacejakarta.servlet.ServletRequest- Throws:
UnsupportedEncodingException
-
setRemoteAddr
-
getRemoteAddr
- Specified by:
getRemoteAddrin interfacejakarta.servlet.ServletRequest
-
setRemoteHost
-
getRemoteHost
- Specified by:
getRemoteHostin interfacejakarta.servlet.ServletRequest
-
setAttribute
-
removeAttribute
- Specified by:
removeAttributein interfacejakarta.servlet.ServletRequest
-
clearAttributes
public void clearAttributes()Clear all of this request's attributes. -
getLocale
Return the first preferred locale configured in this mock request.If no locales have been explicitly configured, the default, preferred
Localefor the server mocked by this request isLocale.ENGLISH.In contrast to the Servlet specification, this mock implementation does not take into consideration any locales specified via the
Accept-Languageheader.- Specified by:
getLocalein interfacejakarta.servlet.ServletRequest- See Also:
-
getLocales
Return an enumeration of the preferred locales configured in this mock request.If no locales have been explicitly configured, the default, preferred
Localefor the server mocked by this request isLocale.ENGLISH.In contrast to the Servlet specification, this mock implementation does not take into consideration any locales specified via the
Accept-Languageheader.- Specified by:
getLocalesin interfacejakarta.servlet.ServletRequest- See Also:
-
isSecure
public boolean isSecure()- Specified by:
isSecurein interfacejakarta.servlet.ServletRequest- See Also:
-
getRequestDispatcher
- Specified by:
getRequestDispatcherin interfacejakarta.servlet.ServletRequest
-
setRemotePort
public void setRemotePort(int remotePort) -
getRemotePort
public int getRemotePort()- Specified by:
getRemotePortin interfacejakarta.servlet.ServletRequest
-
setLocalName
-
getLocalName
- Specified by:
getLocalNamein interfacejakarta.servlet.ServletRequest
-
setLocalAddr
-
getLocalAddr
- Specified by:
getLocalAddrin interfacejakarta.servlet.ServletRequest
-
setLocalPort
public void setLocalPort(int localPort) -
getLocalPort
public int getLocalPort()- Specified by:
getLocalPortin interfacejakarta.servlet.ServletRequest
-
startAsync
public jakarta.servlet.AsyncContext startAsync()- Specified by:
startAsyncin interfacejakarta.servlet.ServletRequest
-
startAsync
public jakarta.servlet.AsyncContext startAsync(jakarta.servlet.ServletRequest request, @Nullable jakarta.servlet.ServletResponse response) - Specified by:
startAsyncin interfacejakarta.servlet.ServletRequest
-
setAsyncStarted
public void setAsyncStarted(boolean asyncStarted) -
isAsyncStarted
public boolean isAsyncStarted()- Specified by:
isAsyncStartedin interfacejakarta.servlet.ServletRequest
-
setAsyncSupported
public void setAsyncSupported(boolean asyncSupported) -
isAsyncSupported
public boolean isAsyncSupported()- Specified by:
isAsyncSupportedin interfacejakarta.servlet.ServletRequest
-
setAsyncContext
public void setAsyncContext(@Nullable jakarta.servlet.AsyncContext asyncContext) -
getAsyncContext
@Nullable public jakarta.servlet.AsyncContext getAsyncContext()- Specified by:
getAsyncContextin interfacejakarta.servlet.ServletRequest
-
setDispatcherType
public void setDispatcherType(jakarta.servlet.DispatcherType dispatcherType) -
getDispatcherType
public jakarta.servlet.DispatcherType getDispatcherType()- Specified by:
getDispatcherTypein interfacejakarta.servlet.ServletRequest
-
setAuthType
-
getAuthType
- Specified by:
getAuthTypein interfacejakarta.servlet.http.HttpServletRequest
-
getCookies
@Nullable public jakarta.servlet.http.Cookie[] getCookies()- Specified by:
getCookiesin interfacejakarta.servlet.http.HttpServletRequest
-
getHeader
-
getHeaders
- Specified by:
getHeadersin interfacejakarta.servlet.http.HttpServletRequest
-
getHeaderNames
- Specified by:
getHeaderNamesin interfacejakarta.servlet.http.HttpServletRequest
-
setHeader
-
addHeader
-
addHeaders
-
setHeaders
-
getIntHeader
- Specified by:
getIntHeaderin interfacejakarta.servlet.http.HttpServletRequest
-
getDateHeader
- Specified by:
getDateHeaderin interfacejakarta.servlet.http.HttpServletRequest
-
setMethod
-
getMethod
- Specified by:
getMethodin interfacejakarta.servlet.http.HttpServletRequest
-
setPathInfo
-
getPathInfo
- Specified by:
getPathInfoin interfacejakarta.servlet.http.HttpServletRequest
-
getPathTranslated
- Specified by:
getPathTranslatedin interfacejakarta.servlet.http.HttpServletRequest
-
setContextPath
-
getContextPath
- Specified by:
getContextPathin interfacejakarta.servlet.http.HttpServletRequest
-
setQueryString
-
getQueryString
- Specified by:
getQueryStringin interfacejakarta.servlet.http.HttpServletRequest
-
setRemoteUser
-
getRemoteUser
- Specified by:
getRemoteUserin interfacejakarta.servlet.http.HttpServletRequest
-
addUserRole
-
isUserInRole
- Specified by:
isUserInRolein interfacejakarta.servlet.http.HttpServletRequest
-
setUserPrincipal
-
getUserPrincipal
- Specified by:
getUserPrincipalin interfacejakarta.servlet.http.HttpServletRequest
-
setRequestedSessionId
-
getRequestedSessionId
- Specified by:
getRequestedSessionIdin interfacejakarta.servlet.http.HttpServletRequest
-
setRequestURI
-
getRequestURI
- Specified by:
getRequestURIin interfacejakarta.servlet.http.HttpServletRequest
-
getRequestURL
- Specified by:
getRequestURLin interfacejakarta.servlet.http.HttpServletRequest
-
setServletPath
-
getServletPath
- Specified by:
getServletPathin interfacejakarta.servlet.http.HttpServletRequest
-
setSession
public void setSession(jakarta.servlet.http.HttpSession session) -
getSession
@Nullable public jakarta.servlet.http.HttpSession getSession(boolean create) - Specified by:
getSessionin interfacejakarta.servlet.http.HttpServletRequest
-
getSession
@Nullable public jakarta.servlet.http.HttpSession getSession()- Specified by:
getSessionin interfacejakarta.servlet.http.HttpServletRequest
-
changeSessionId
- Specified by:
changeSessionIdin interfacejakarta.servlet.http.HttpServletRequest
-
setRequestedSessionIdValid
public void setRequestedSessionIdValid(boolean requestedSessionIdValid) -
isRequestedSessionIdValid
public boolean isRequestedSessionIdValid()- Specified by:
isRequestedSessionIdValidin interfacejakarta.servlet.http.HttpServletRequest
-
setRequestedSessionIdFromCookie
public void setRequestedSessionIdFromCookie(boolean requestedSessionIdFromCookie) -
isRequestedSessionIdFromCookie
public boolean isRequestedSessionIdFromCookie()- Specified by:
isRequestedSessionIdFromCookiein interfacejakarta.servlet.http.HttpServletRequest
-
setRequestedSessionIdFromURL
public void setRequestedSessionIdFromURL(boolean requestedSessionIdFromURL) -
isRequestedSessionIdFromURL
public boolean isRequestedSessionIdFromURL()- Specified by:
isRequestedSessionIdFromURLin interfacejakarta.servlet.http.HttpServletRequest
-
authenticate
public boolean authenticate(jakarta.servlet.http.HttpServletResponse response) throws IOException, jakarta.servlet.ServletException - Specified by:
authenticatein interfacejakarta.servlet.http.HttpServletRequest- Throws:
IOExceptionjakarta.servlet.ServletException
-
login
-
logout
public void logout() throws jakarta.servlet.ServletException- Specified by:
logoutin interfacejakarta.servlet.http.HttpServletRequest- Throws:
jakarta.servlet.ServletException
-
addPart
public void addPart(jakarta.servlet.http.Part part) -
getPart
@Nullable public jakarta.servlet.http.Part getPart(String name) throws IOException, jakarta.servlet.ServletException - Specified by:
getPartin interfacejakarta.servlet.http.HttpServletRequest- Throws:
IOExceptionjakarta.servlet.ServletException
-
getParts
public Collection<jakarta.servlet.http.Part> getParts() throws IOException, jakarta.servlet.ServletException- Specified by:
getPartsin interfacejakarta.servlet.http.HttpServletRequest- Throws:
IOExceptionjakarta.servlet.ServletException
-
upgrade
public <T extends jakarta.servlet.http.HttpUpgradeHandler> T upgrade(Class<T> handlerClass) throws IOException, jakarta.servlet.ServletException - Specified by:
upgradein interfacejakarta.servlet.http.HttpServletRequest- Throws:
IOExceptionjakarta.servlet.ServletException
-
getRequestId
- Specified by:
getRequestIdin interfacejakarta.servlet.ServletRequest
-
getProtocolRequestId
- Specified by:
getProtocolRequestIdin interfacejakarta.servlet.ServletRequest
-
getServletConnection
public jakarta.servlet.ServletConnection getServletConnection()- Specified by:
getServletConnectionin interfacejakarta.servlet.ServletRequest
-