Class AwsHttpServletRequest

java.lang.Object
com.amazonaws.serverless.proxy.internal.servlet.AwsHttpServletRequest
All Implemented Interfaces:
javax.servlet.http.HttpServletRequest, javax.servlet.ServletRequest
Direct Known Subclasses:
AwsHttpApiV2ProxyHttpServletRequest, AwsProxyHttpServletRequest

public abstract class AwsHttpServletRequest extends Object implements javax.servlet.http.HttpServletRequest
Base HttpServletRequest object. This object exposes some utility methods to work with request values such as headers and query string parameters. New implementations of HttpServletRequest can extend this class to reuse the utility methods
  • Field Details

  • Method Details

    • getResponse

      public AwsHttpServletResponse getResponse()
    • setResponse

      public void setResponse(AwsHttpServletResponse response)
    • setContainerHandler

      public void setContainerHandler(AwsLambdaServletContainerHandler containerHandler)
    • getRequestedSessionId

      public String getRequestedSessionId()
      Specified by:
      getRequestedSessionId in interface javax.servlet.http.HttpServletRequest
    • getSession

      public javax.servlet.http.HttpSession getSession(boolean b)
      Specified by:
      getSession in interface javax.servlet.http.HttpServletRequest
    • getSession

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

      public String changeSessionId()
      Specified by:
      changeSessionId in interface javax.servlet.http.HttpServletRequest
    • isRequestedSessionIdValid

      public boolean isRequestedSessionIdValid()
      Specified by:
      isRequestedSessionIdValid in interface javax.servlet.http.HttpServletRequest
    • isRequestedSessionIdFromCookie

      public boolean isRequestedSessionIdFromCookie()
      Specified by:
      isRequestedSessionIdFromCookie in interface javax.servlet.http.HttpServletRequest
    • isRequestedSessionIdFromURL

      public boolean isRequestedSessionIdFromURL()
      Specified by:
      isRequestedSessionIdFromURL in interface javax.servlet.http.HttpServletRequest
    • isRequestedSessionIdFromUrl

      @Deprecated public boolean isRequestedSessionIdFromUrl()
      Deprecated.
      Specified by:
      isRequestedSessionIdFromUrl in interface javax.servlet.http.HttpServletRequest
    • getAttribute

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

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

      public String getServerName()
      Specified by:
      getServerName in interface javax.servlet.ServletRequest
    • getServerPort

      public int getServerPort()
      Specified by:
      getServerPort in interface javax.servlet.ServletRequest
    • setAttribute

      public void setAttribute(String s, Object o)
      Specified by:
      setAttribute in interface javax.servlet.ServletRequest
    • removeAttribute

      public void removeAttribute(String s)
      Specified by:
      removeAttribute in interface javax.servlet.ServletRequest
    • getLocalName

      public String getLocalName()
      Specified by:
      getLocalName in interface javax.servlet.ServletRequest
    • getLocalAddr

      public String getLocalAddr()
      Specified by:
      getLocalAddr in interface javax.servlet.ServletRequest
    • getLocalPort

      public int getLocalPort()
      Specified by:
      getLocalPort in interface javax.servlet.ServletRequest
    • getServletContext

      public javax.servlet.ServletContext getServletContext()
      Specified by:
      getServletContext in interface javax.servlet.ServletRequest
    • isAsyncStarted

      public boolean isAsyncStarted()
      Specified by:
      isAsyncStarted in interface javax.servlet.ServletRequest
    • isAsyncSupported

      public boolean isAsyncSupported()
      Specified by:
      isAsyncSupported in interface javax.servlet.ServletRequest
    • getDispatcherType

      public javax.servlet.DispatcherType getDispatcherType()
      Specified by:
      getDispatcherType in interface javax.servlet.ServletRequest
    • getServletPath

      public String getServletPath()
      Specified by:
      getServletPath in interface javax.servlet.http.HttpServletRequest
    • setServletContext

      public void setServletContext(javax.servlet.ServletContext context)
    • parseCookieHeaderValue

      protected javax.servlet.http.Cookie[] parseCookieHeaderValue(String headerValue)
      Given the Cookie header value, parses it and creates a Cookie object
      Parameters:
      headerValue - The string value of the HTTP Cookie header
      Returns:
      An array of Cookie objects from the header
    • generateQueryString

      protected String generateQueryString(MultiValuedTreeMap<String,​String> parameters, boolean encode, String encodeCharset) throws javax.servlet.ServletException
      Given a map of key/values query string parameters from API Gateway, creates a query string as it would have been in the original url.
      Parameters:
      parameters - A Map<String, String> of query string parameters
      encode - Whether the key and values should be URL encoded
      encodeCharset - Charset to use for encoding the query string
      Returns:
      The generated query string for the URI
      Throws:
      javax.servlet.ServletException
    • generateContextPath

      protected String generateContextPath(ContainerConfig config, String apiStage)
    • generateRequestURL

      protected StringBuffer generateRequestURL(String requestPath)
    • parseCharacterEncoding

      protected String parseCharacterEncoding(String contentTypeHeader)
    • appendCharacterEncoding

      protected String appendCharacterEncoding(String currentContentType, String newEncoding)
    • bodyStringToInputStream

      protected javax.servlet.ServletInputStream bodyStringToInputStream(String body, boolean isBase64Encoded) throws IOException
      Throws:
      IOException
    • getFirstQueryParamValue

      protected String getFirstQueryParamValue(MultiValuedTreeMap<String,​String> queryString, String key, boolean isCaseSensitive)
    • getFormBodyParameterCaseInsensitive

      protected String[] getFormBodyParameterCaseInsensitive(String key)
    • getFormUrlEncodedParametersMap

      protected Map<String,​List<String>> getFormUrlEncodedParametersMap()
    • getMultipartFormParametersMap

      protected Map<String,​javax.servlet.http.Part> getMultipartFormParametersMap()
    • getQueryParamValues

      protected String[] getQueryParamValues(MultiValuedTreeMap<String,​String> qs, String key, boolean isCaseSensitive)
    • generateParameterMap

      protected Map<String,​String[]> generateParameterMap(MultiValuedTreeMap<String,​String> qs, ContainerConfig config)
    • getSchemeFromHeader

      protected String getSchemeFromHeader(Headers headers)
    • parseHeaderValue

      protected List<AwsHttpServletRequest.HeaderValue> parseHeaderValue(String headerValue)
      Prases a header value using the default value separator "," and qualifier separator ";".
      Parameters:
      headerValue - The value to be parsed
      Returns:
      A list of SimpleMapEntry objects with all of the possible values for the header.
    • parseHeaderValue

      protected List<AwsHttpServletRequest.HeaderValue> parseHeaderValue(String headerValue, String valueSeparator, String qualifierSeparator)
      Generic method to parse an HTTP header value and split it into a list of key/values for all its components. When the property in the header does not specify a key the key field in the output pair is null and only the value is populated. For example, The header Accept: application/json; application/xml will contain two key value pairs with key null and the value set to application/json and application/xml respectively.
      Parameters:
      headerValue - The string value for the HTTP header
      valueSeparator - The separator to be used for parsing header values
      Returns:
      A list of SimpleMapEntry objects with all of the possible values for the header.