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-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classClass that represents a header value. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AwsLambdaServletContainerHandlerprotected javax.servlet.ServletInputStreamprotected AwsHttpServletResponseFields inherited from interface javax.servlet.http.HttpServletRequest
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH -
Method Summary
Modifier and TypeMethodDescriptionprotected StringappendCharacterEncoding(String currentContentType, String newEncoding)protected javax.servlet.ServletInputStreambodyStringToInputStream(String body, boolean isBase64Encoded)protected StringgenerateContextPath(ContainerConfig config, String apiStage)generateParameterMap(MultiValuedTreeMap<String,String> qs, ContainerConfig config)protected StringgenerateQueryString(MultiValuedTreeMap<String,String> parameters, boolean encode, String encodeCharset)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.protected StringBuffergenerateRequestURL(String requestPath)getAttribute(String s)javax.servlet.DispatcherTypeprotected StringgetFirstQueryParamValue(MultiValuedTreeMap<String,String> queryString, String key, boolean isCaseSensitive)protected String[]intprotected String[]getQueryParamValues(MultiValuedTreeMap<String,String> qs, String key, boolean isCaseSensitive)protected StringgetSchemeFromHeader(Headers headers)intjavax.servlet.ServletContextjavax.servlet.http.HttpSessionjavax.servlet.http.HttpSessiongetSession(boolean b)booleanbooleanbooleanbooleanDeprecated.booleanbooleanprotected StringparseCharacterEncoding(String contentTypeHeader)protected javax.servlet.http.Cookie[]parseCookieHeaderValue(String headerValue)Given the Cookie header value, parses it and creates a Cookie objectprotected List<AwsHttpServletRequest.HeaderValue>parseHeaderValue(String headerValue)Prases a header value using the default value separator "," and qualifier separator ";".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.voidvoidsetAttribute(String s, Object o)voidsetContainerHandler(AwsLambdaServletContainerHandler containerHandler)voidsetResponse(AwsHttpServletResponse response)voidsetServletContext(javax.servlet.ServletContext context)Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface javax.servlet.http.HttpServletRequest
authenticate, getAuthType, getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getIntHeader, getMethod, getPart, getParts, getPathInfo, getPathTranslated, getQueryString, getRemoteUser, getRequestURI, getRequestURL, getUserPrincipal, isUserInRole, login, logout, upgradeMethods inherited from interface javax.servlet.ServletRequest
getAsyncContext, getCharacterEncoding, getContentLength, getContentLengthLong, getContentType, getInputStream, getLocale, getLocales, getParameter, getParameterMap, getParameterNames, getParameterValues, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequestDispatcher, getScheme, isSecure, setCharacterEncoding, startAsync, startAsync
-
Field Details
-
response
-
containerHandler
-
requestInputStream
protected javax.servlet.ServletInputStream requestInputStream
-
-
Method Details
-
getResponse
-
setResponse
-
setContainerHandler
-
getRequestedSessionId
- Specified by:
getRequestedSessionIdin interfacejavax.servlet.http.HttpServletRequest
-
getSession
public javax.servlet.http.HttpSession getSession(boolean b)- Specified by:
getSessionin interfacejavax.servlet.http.HttpServletRequest
-
getSession
public javax.servlet.http.HttpSession getSession()- Specified by:
getSessionin interfacejavax.servlet.http.HttpServletRequest
-
changeSessionId
- Specified by:
changeSessionIdin interfacejavax.servlet.http.HttpServletRequest
-
isRequestedSessionIdValid
public boolean isRequestedSessionIdValid()- Specified by:
isRequestedSessionIdValidin interfacejavax.servlet.http.HttpServletRequest
-
isRequestedSessionIdFromCookie
public boolean isRequestedSessionIdFromCookie()- Specified by:
isRequestedSessionIdFromCookiein interfacejavax.servlet.http.HttpServletRequest
-
isRequestedSessionIdFromURL
public boolean isRequestedSessionIdFromURL()- Specified by:
isRequestedSessionIdFromURLin interfacejavax.servlet.http.HttpServletRequest
-
isRequestedSessionIdFromUrl
Deprecated.- Specified by:
isRequestedSessionIdFromUrlin interfacejavax.servlet.http.HttpServletRequest
-
getAttribute
- Specified by:
getAttributein interfacejavax.servlet.ServletRequest
-
getAttributeNames
- Specified by:
getAttributeNamesin interfacejavax.servlet.ServletRequest
-
getServerName
- Specified by:
getServerNamein interfacejavax.servlet.ServletRequest
-
getServerPort
public int getServerPort()- Specified by:
getServerPortin interfacejavax.servlet.ServletRequest
-
setAttribute
- Specified by:
setAttributein interfacejavax.servlet.ServletRequest
-
removeAttribute
- Specified by:
removeAttributein interfacejavax.servlet.ServletRequest
-
getLocalName
- Specified by:
getLocalNamein interfacejavax.servlet.ServletRequest
-
getLocalAddr
- Specified by:
getLocalAddrin interfacejavax.servlet.ServletRequest
-
getLocalPort
public int getLocalPort()- Specified by:
getLocalPortin interfacejavax.servlet.ServletRequest
-
getServletContext
public javax.servlet.ServletContext getServletContext()- Specified by:
getServletContextin interfacejavax.servlet.ServletRequest
-
isAsyncStarted
public boolean isAsyncStarted()- Specified by:
isAsyncStartedin interfacejavax.servlet.ServletRequest
-
isAsyncSupported
public boolean isAsyncSupported()- Specified by:
isAsyncSupportedin interfacejavax.servlet.ServletRequest
-
getDispatcherType
public javax.servlet.DispatcherType getDispatcherType()- Specified by:
getDispatcherTypein interfacejavax.servlet.ServletRequest
-
getServletPath
- Specified by:
getServletPathin interfacejavax.servlet.http.HttpServletRequest
-
setServletContext
public void setServletContext(javax.servlet.ServletContext context) -
parseCookieHeaderValue
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.ServletExceptionGiven 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 parametersencode- Whether the key and values should be URL encodedencodeCharset- Charset to use for encoding the query string- Returns:
- The generated query string for the URI
- Throws:
javax.servlet.ServletException
-
generateContextPath
-
generateRequestURL
-
parseCharacterEncoding
-
appendCharacterEncoding
-
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
-
getFormUrlEncodedParametersMap
-
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
-
parseHeaderValue
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 headerAccept: application/json; application/xmlwill 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 headervalueSeparator- The separator to be used for parsing header values- Returns:
- A list of SimpleMapEntry objects with all of the possible values for the header.
-