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
  • Constructor Details

    • ServerlessHttpServletRequest

      public ServerlessHttpServletRequest(jakarta.servlet.ServletContext servletContext, String method, String requestURI)
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • 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:
      getServletContext in interface jakarta.servlet.ServletRequest
    • getAttribute

      public Object getAttribute(String name)
      Specified by:
      getAttribute in interface jakarta.servlet.ServletRequest
    • getAttributeNames

      public Enumeration<String> getAttributeNames()
      Specified by:
      getAttributeNames in interface jakarta.servlet.ServletRequest
    • getCharacterEncoding

      @Nullable public String getCharacterEncoding()
      Specified by:
      getCharacterEncoding in interface jakarta.servlet.ServletRequest
    • setCharacterEncoding

      public void setCharacterEncoding(@Nullable String characterEncoding)
      Specified by:
      setCharacterEncoding in interface jakarta.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 encoding should 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, 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:
    • getContentLength

      public int getContentLength()
      Specified by:
      getContentLength in interface jakarta.servlet.ServletRequest
    • getContentLengthLong

      public long getContentLengthLong()
      Specified by:
      getContentLengthLong in interface jakarta.servlet.ServletRequest
    • setContentType

      public void setContentType(@Nullable String contentType)
    • getContentType

      @Nullable public String getContentType()
      Specified by:
      getContentType in interface jakarta.servlet.ServletRequest
    • getInputStream

      public jakarta.servlet.ServletInputStream getInputStream()
      Specified by:
      getInputStream in interface jakarta.servlet.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 jakarta.servlet.ServletRequest
    • getParameterNames

      public Enumeration<String> getParameterNames()
      Specified by:
      getParameterNames in interface jakarta.servlet.ServletRequest
    • getParameterValues

      public String[] getParameterValues(String name)
      Specified by:
      getParameterValues in interface jakarta.servlet.ServletRequest
    • getParameterMap

      public Map<String,String[]> getParameterMap()
      Specified by:
      getParameterMap in interface jakarta.servlet.ServletRequest
    • getProtocol

      public String getProtocol()
      Specified by:
      getProtocol in interface jakarta.servlet.ServletRequest
    • getScheme

      public String getScheme()
      Specified by:
      getScheme in interface jakarta.servlet.ServletRequest
    • setServerName

      public void setServerName(String serverName)
    • getServerName

      public String getServerName()
      Specified by:
      getServerName in interface jakarta.servlet.ServletRequest
    • setServerPort

      public void setServerPort(int serverPort)
    • getServerPort

      public int getServerPort()
      Specified by:
      getServerPort in interface jakarta.servlet.ServletRequest
    • getReader

      public BufferedReader getReader() throws UnsupportedEncodingException
      Specified by:
      getReader in interface jakarta.servlet.ServletRequest
      Throws:
      UnsupportedEncodingException
    • setRemoteAddr

      public void setRemoteAddr(String remoteAddr)
    • getRemoteAddr

      public String getRemoteAddr()
      Specified by:
      getRemoteAddr in interface jakarta.servlet.ServletRequest
    • setRemoteHost

      public void setRemoteHost(String remoteHost)
    • getRemoteHost

      public String getRemoteHost()
      Specified by:
      getRemoteHost in interface jakarta.servlet.ServletRequest
    • setAttribute

      public void setAttribute(String name, @Nullable Object value)
      Specified by:
      setAttribute in interface jakarta.servlet.ServletRequest
    • removeAttribute

      public void removeAttribute(String name)
      Specified by:
      removeAttribute in interface jakarta.servlet.ServletRequest
    • clearAttributes

      public void clearAttributes()
      Clear all of this request's attributes.
    • 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 jakarta.servlet.ServletRequest
      See Also:
      • invalid reference
        javax.servlet.ServletRequest#getLocale()
      • invalid reference
        #addPreferredLocale(Locale)
      • invalid reference
        #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 jakarta.servlet.ServletRequest
      See Also:
      • invalid reference
        javax.servlet.ServletRequest#getLocales()
      • invalid reference
        #addPreferredLocale(Locale)
      • invalid reference
        #setPreferredLocales(List)
    • isSecure

      public boolean isSecure()
      Return true if the
      invalid reference
      secure
      flag has been set to true or if the scheme is https.
      Specified by:
      isSecure in interface jakarta.servlet.ServletRequest
      See Also:
      • invalid reference
        javax.servlet.ServletRequest#isSecure()
    • getRequestDispatcher

      public jakarta.servlet.RequestDispatcher getRequestDispatcher(String path)
      Specified by:
      getRequestDispatcher in interface jakarta.servlet.ServletRequest
    • setRemotePort

      public void setRemotePort(int remotePort)
    • getRemotePort

      public int getRemotePort()
      Specified by:
      getRemotePort in interface jakarta.servlet.ServletRequest
    • setLocalName

      public void setLocalName(String localName)
    • getLocalName

      public String getLocalName()
      Specified by:
      getLocalName in interface jakarta.servlet.ServletRequest
    • setLocalAddr

      public void setLocalAddr(String localAddr)
    • getLocalAddr

      public String getLocalAddr()
      Specified by:
      getLocalAddr in interface jakarta.servlet.ServletRequest
    • setLocalPort

      public void setLocalPort(int localPort)
    • getLocalPort

      public int getLocalPort()
      Specified by:
      getLocalPort in interface jakarta.servlet.ServletRequest
    • startAsync

      public jakarta.servlet.AsyncContext startAsync()
      Specified by:
      startAsync in interface jakarta.servlet.ServletRequest
    • startAsync

      public jakarta.servlet.AsyncContext startAsync(jakarta.servlet.ServletRequest request, @Nullable jakarta.servlet.ServletResponse response)
      Specified by:
      startAsync in interface jakarta.servlet.ServletRequest
    • setAsyncStarted

      public void setAsyncStarted(boolean asyncStarted)
    • isAsyncStarted

      public boolean isAsyncStarted()
      Specified by:
      isAsyncStarted in interface jakarta.servlet.ServletRequest
    • setAsyncSupported

      public void setAsyncSupported(boolean asyncSupported)
    • isAsyncSupported

      public boolean isAsyncSupported()
      Specified by:
      isAsyncSupported in interface jakarta.servlet.ServletRequest
    • setAsyncContext

      public void setAsyncContext(@Nullable jakarta.servlet.AsyncContext asyncContext)
    • getAsyncContext

      @Nullable public jakarta.servlet.AsyncContext getAsyncContext()
      Specified by:
      getAsyncContext in interface jakarta.servlet.ServletRequest
    • setDispatcherType

      public void setDispatcherType(jakarta.servlet.DispatcherType dispatcherType)
    • getDispatcherType

      public jakarta.servlet.DispatcherType getDispatcherType()
      Specified by:
      getDispatcherType in interface jakarta.servlet.ServletRequest
    • setAuthType

      public void setAuthType(@Nullable String authType)
    • getAuthType

      @Nullable public String getAuthType()
      Specified by:
      getAuthType in interface jakarta.servlet.http.HttpServletRequest
    • getCookies

      @Nullable public jakarta.servlet.http.Cookie[] getCookies()
      Specified by:
      getCookies in interface jakarta.servlet.http.HttpServletRequest
    • getHeader

      @Nullable public String getHeader(String name)
      Specified by:
      getHeader in interface jakarta.servlet.http.HttpServletRequest
    • getHeaders

      public Enumeration<String> getHeaders(String name)
      Specified by:
      getHeaders in interface jakarta.servlet.http.HttpServletRequest
    • getHeaderNames

      public Enumeration<String> getHeaderNames()
      Specified by:
      getHeaderNames in interface jakarta.servlet.http.HttpServletRequest
    • setHeader

      public void setHeader(String name, @Nullable String value)
    • addHeader

      public void addHeader(String name, @Nullable String value)
    • addHeaders

      public void addHeaders(org.springframework.util.MultiValueMap<String,String> headers)
    • setHeaders

      public void setHeaders(org.springframework.util.MultiValueMap<String,String> headers)
    • getIntHeader

      public int getIntHeader(String name)
      Specified by:
      getIntHeader in interface jakarta.servlet.http.HttpServletRequest
    • getDateHeader

      public long getDateHeader(String name)
      Specified by:
      getDateHeader in interface jakarta.servlet.http.HttpServletRequest
    • setMethod

      public void setMethod(@Nullable String method)
    • getMethod

      @Nullable public String getMethod()
      Specified by:
      getMethod in interface jakarta.servlet.http.HttpServletRequest
    • setPathInfo

      public void setPathInfo(@Nullable String pathInfo)
    • getPathInfo

      @Nullable public String getPathInfo()
      Specified by:
      getPathInfo in interface jakarta.servlet.http.HttpServletRequest
    • getPathTranslated

      @Nullable public String getPathTranslated()
      Specified by:
      getPathTranslated in interface jakarta.servlet.http.HttpServletRequest
    • setContextPath

      public void setContextPath(String contextPath)
    • getContextPath

      public String getContextPath()
      Specified by:
      getContextPath in interface jakarta.servlet.http.HttpServletRequest
    • setQueryString

      public void setQueryString(@Nullable String queryString)
    • getQueryString

      @Nullable public String getQueryString()
      Specified by:
      getQueryString in interface jakarta.servlet.http.HttpServletRequest
    • setRemoteUser

      public void setRemoteUser(@Nullable String remoteUser)
    • getRemoteUser

      @Nullable public String getRemoteUser()
      Specified by:
      getRemoteUser in interface jakarta.servlet.http.HttpServletRequest
    • addUserRole

      public void addUserRole(String role)
    • isUserInRole

      public boolean isUserInRole(String role)
      Specified by:
      isUserInRole in interface jakarta.servlet.http.HttpServletRequest
    • setUserPrincipal

      public void setUserPrincipal(@Nullable Principal userPrincipal)
    • getUserPrincipal

      @Nullable public Principal getUserPrincipal()
      Specified by:
      getUserPrincipal in interface jakarta.servlet.http.HttpServletRequest
    • setRequestedSessionId

      public void setRequestedSessionId(@Nullable String requestedSessionId)
    • getRequestedSessionId

      @Nullable public String getRequestedSessionId()
      Specified by:
      getRequestedSessionId in interface jakarta.servlet.http.HttpServletRequest
    • setRequestURI

      public void setRequestURI(@Nullable String requestURI)
    • getRequestURI

      @Nullable public String getRequestURI()
      Specified by:
      getRequestURI in interface jakarta.servlet.http.HttpServletRequest
    • getRequestURL

      public StringBuffer getRequestURL()
      Specified by:
      getRequestURL in interface jakarta.servlet.http.HttpServletRequest
    • setServletPath

      public void setServletPath(String servletPath)
    • getServletPath

      public String getServletPath()
      Specified by:
      getServletPath in interface jakarta.servlet.http.HttpServletRequest
    • setSession

      public void setSession(jakarta.servlet.http.HttpSession session)
    • getSession

      @Nullable public jakarta.servlet.http.HttpSession getSession(boolean create)
      Specified by:
      getSession in interface jakarta.servlet.http.HttpServletRequest
    • getSession

      @Nullable public jakarta.servlet.http.HttpSession getSession()
      Specified by:
      getSession in interface jakarta.servlet.http.HttpServletRequest
    • changeSessionId

      public String changeSessionId()
      Specified by:
      changeSessionId in interface jakarta.servlet.http.HttpServletRequest
    • setRequestedSessionIdValid

      public void setRequestedSessionIdValid(boolean requestedSessionIdValid)
    • isRequestedSessionIdValid

      public boolean isRequestedSessionIdValid()
      Specified by:
      isRequestedSessionIdValid in interface jakarta.servlet.http.HttpServletRequest
    • setRequestedSessionIdFromCookie

      public void setRequestedSessionIdFromCookie(boolean requestedSessionIdFromCookie)
    • isRequestedSessionIdFromCookie

      public boolean isRequestedSessionIdFromCookie()
      Specified by:
      isRequestedSessionIdFromCookie in interface jakarta.servlet.http.HttpServletRequest
    • setRequestedSessionIdFromURL

      public void setRequestedSessionIdFromURL(boolean requestedSessionIdFromURL)
    • isRequestedSessionIdFromURL

      public boolean isRequestedSessionIdFromURL()
      Specified by:
      isRequestedSessionIdFromURL in interface jakarta.servlet.http.HttpServletRequest
    • authenticate

      public boolean authenticate(jakarta.servlet.http.HttpServletResponse response) throws IOException, jakarta.servlet.ServletException
      Specified by:
      authenticate in interface jakarta.servlet.http.HttpServletRequest
      Throws:
      IOException
      jakarta.servlet.ServletException
    • login

      public void login(String username, String password) throws jakarta.servlet.ServletException
      Specified by:
      login in interface jakarta.servlet.http.HttpServletRequest
      Throws:
      jakarta.servlet.ServletException
    • logout

      public void logout() throws jakarta.servlet.ServletException
      Specified by:
      logout in interface jakarta.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:
      getPart in interface jakarta.servlet.http.HttpServletRequest
      Throws:
      IOException
      jakarta.servlet.ServletException
    • getParts

      public Collection<jakarta.servlet.http.Part> getParts() throws IOException, jakarta.servlet.ServletException
      Specified by:
      getParts in interface jakarta.servlet.http.HttpServletRequest
      Throws:
      IOException
      jakarta.servlet.ServletException
    • upgrade

      public <T extends jakarta.servlet.http.HttpUpgradeHandler> T upgrade(Class<T> handlerClass) throws IOException, jakarta.servlet.ServletException
      Specified by:
      upgrade in interface jakarta.servlet.http.HttpServletRequest
      Throws:
      IOException
      jakarta.servlet.ServletException
    • getRequestId

      public String getRequestId()
      Specified by:
      getRequestId in interface jakarta.servlet.ServletRequest
    • getProtocolRequestId

      public String getProtocolRequestId()
      Specified by:
      getProtocolRequestId in interface jakarta.servlet.ServletRequest
    • getServletConnection

      public jakarta.servlet.ServletConnection getServletConnection()
      Specified by:
      getServletConnection in interface jakarta.servlet.ServletRequest