Class AwsHttpServletRequest
java.lang.Object
com.amazonaws.serverless.proxy.internal.servlet.AwsHttpServletRequest
- All Implemented Interfaces:
jakarta.servlet.http.HttpServletRequest,jakarta.servlet.ServletRequest
- Direct Known Subclasses:
AwsHttpApiV2ProxyHttpServletRequest,AwsProxyHttpServletRequest
public abstract class AwsHttpServletRequest
extends Object
implements jakarta.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 jakarta.servlet.ServletInputStreamprotected AwsHttpServletResponseFields inherited from interface jakarta.servlet.http.HttpServletRequest
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAwsHttpServletRequest(com.amazonaws.services.lambda.runtime.Context lambdaContext) Protected constructors for implementing classes. -
Method Summary
Modifier and TypeMethodDescriptionprotected jakarta.servlet.ServletInputStreambodyStringToInputStream(String body, boolean isBase64Encoded) static StringdecodeValueIfEncoded(String value) protected StringgenerateContextPath(ContainerConfig config, String apiStage) generateParameterMap(MultiValuedTreeMap<String, String> qs, ContainerConfig config) generateParameterMap(MultiValuedTreeMap<String, String> qs, ContainerConfig config, boolean decodeQueryParams) 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) protected CookieProcessorjakarta.servlet.DispatcherTypeprotected StringgetFirstQueryParamValue(MultiValuedTreeMap<String, String> queryString, String key, boolean isCaseSensitive) protected String[]intjakarta.servlet.http.PartCollection<jakarta.servlet.http.Part>getParts()protected String[]getQueryParamValues(MultiValuedTreeMap<String, String> qs, String key, boolean isCaseSensitive) getQueryParamValuesAsList(MultiValuedTreeMap<String, String> qs, String key, boolean isCaseSensitive) protected StringgetSchemeFromHeader(Headers headers) intjakarta.servlet.ServletContextjakarta.servlet.http.HttpSessionas per Servlet spec this method creates a session if none existsjakarta.servlet.http.HttpSessiongetSession(boolean b) booleanbooleanbooleanbooleanbooleanparseAcceptLanguageHeader(String headerValue) protected jakarta.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.protected LocaleparseLanguageTag(String languageTag) voidvoidsetAttribute(String s, Object o) voidsetContainerHandler(AwsLambdaServletContainerHandler containerHandler) voidsetResponse(AwsHttpServletResponse response) voidsetServletContext(jakarta.servlet.ServletContext context) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface jakarta.servlet.http.HttpServletRequest
authenticate, getAuthType, getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getHttpServletMapping, getIntHeader, getMethod, getPathInfo, getPathTranslated, getQueryString, getRemoteUser, getRequestURI, getRequestURL, getTrailerFields, getUserPrincipal, isTrailerFieldsReady, isUserInRole, login, logout, newPushBuilder, upgradeMethods inherited from interface jakarta.servlet.ServletRequest
getAsyncContext, getCharacterEncoding, getContentLength, getContentLengthLong, getContentType, getInputStream, getLocale, getLocales, getParameter, getParameterMap, getParameterNames, getParameterValues, getProtocol, getProtocolRequestId, getReader, getRemoteAddr, getRemoteHost, getRemotePort, getRequestDispatcher, getRequestId, getScheme, getServletConnection, isSecure, setCharacterEncoding, startAsync, startAsync
-
Field Details
-
response
-
containerHandler
-
requestInputStream
protected jakarta.servlet.ServletInputStream requestInputStream
-
-
Constructor Details
-
AwsHttpServletRequest
protected AwsHttpServletRequest(com.amazonaws.services.lambda.runtime.Context lambdaContext) Protected constructors for implementing classes. This should be called first with the context received from AWS Lambda- Parameters:
lambdaContext- The Lambda function context. This object is used for utility methods such as log
-
-
Method Details
-
getResponse
-
setResponse
-
setContainerHandler
-
getRequestedSessionId
- Specified by:
getRequestedSessionIdin interfacejakarta.servlet.http.HttpServletRequest
-
getSession
public jakarta.servlet.http.HttpSession getSession(boolean b) - Specified by:
getSessionin interfacejakarta.servlet.http.HttpServletRequest
-
getSession
public jakarta.servlet.http.HttpSession getSession()as per Servlet spec this method creates a session if none exists- Specified by:
getSessionin interfacejakarta.servlet.http.HttpServletRequest- Returns:
- exisiting or new http session
-
changeSessionId
- Specified by:
changeSessionIdin interfacejakarta.servlet.http.HttpServletRequest
-
isRequestedSessionIdValid
public boolean isRequestedSessionIdValid()- Specified by:
isRequestedSessionIdValidin interfacejakarta.servlet.http.HttpServletRequest
-
isRequestedSessionIdFromCookie
public boolean isRequestedSessionIdFromCookie()- Specified by:
isRequestedSessionIdFromCookiein interfacejakarta.servlet.http.HttpServletRequest
-
isRequestedSessionIdFromURL
public boolean isRequestedSessionIdFromURL()- Specified by:
isRequestedSessionIdFromURLin interfacejakarta.servlet.http.HttpServletRequest
-
getAttribute
- Specified by:
getAttributein interfacejakarta.servlet.ServletRequest
-
getAttributeNames
- Specified by:
getAttributeNamesin interfacejakarta.servlet.ServletRequest
-
getServerName
- Specified by:
getServerNamein interfacejakarta.servlet.ServletRequest
-
getServerPort
public int getServerPort()- Specified by:
getServerPortin interfacejakarta.servlet.ServletRequest
-
setAttribute
- Specified by:
setAttributein interfacejakarta.servlet.ServletRequest
-
removeAttribute
- Specified by:
removeAttributein interfacejakarta.servlet.ServletRequest
-
getLocalName
- Specified by:
getLocalNamein interfacejakarta.servlet.ServletRequest
-
getLocalAddr
- Specified by:
getLocalAddrin interfacejakarta.servlet.ServletRequest
-
getLocalPort
public int getLocalPort()- Specified by:
getLocalPortin interfacejakarta.servlet.ServletRequest
-
getServletContext
public jakarta.servlet.ServletContext getServletContext()- Specified by:
getServletContextin interfacejakarta.servlet.ServletRequest
-
isAsyncStarted
public boolean isAsyncStarted()- Specified by:
isAsyncStartedin interfacejakarta.servlet.ServletRequest
-
isAsyncSupported
public boolean isAsyncSupported()- Specified by:
isAsyncSupportedin interfacejakarta.servlet.ServletRequest
-
getDispatcherType
public jakarta.servlet.DispatcherType getDispatcherType()- Specified by:
getDispatcherTypein interfacejakarta.servlet.ServletRequest
-
getServletPath
- Specified by:
getServletPathin interfacejakarta.servlet.http.HttpServletRequest
-
setServletContext
public void setServletContext(jakarta.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 jakarta.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:
jakarta.servlet.ServletException
-
generateContextPath
-
generateRequestURL
-
bodyStringToInputStream
protected jakarta.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
-
getCookieProcessor
-
getParts
public Collection<jakarta.servlet.http.Part> getParts() throws IOException, jakarta.servlet.ServletException- Specified by:
getPartsin interfacejakarta.servlet.http.HttpServletRequest- Throws:
IOExceptionjakarta.servlet.ServletException
-
getPart
public jakarta.servlet.http.Part getPart(String s) throws IOException, jakarta.servlet.ServletException - Specified by:
getPartin interfacejakarta.servlet.http.HttpServletRequest- Throws:
IOExceptionjakarta.servlet.ServletException
-
getMultipartFormParametersMap
protected Map<String,List<jakarta.servlet.http.Part>> getMultipartFormParametersMap() throws IOException- Throws:
IOException
-
getQueryParamValues
protected String[] getQueryParamValues(MultiValuedTreeMap<String, String> qs, String key, boolean isCaseSensitive) -
getQueryParamValuesAsList
-
generateParameterMap
protected Map<String,String[]> generateParameterMap(MultiValuedTreeMap<String, String> qs, ContainerConfig config) -
generateParameterMap
protected Map<String,String[]> generateParameterMap(MultiValuedTreeMap<String, String> qs, ContainerConfig config, boolean decodeQueryParams) -
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.
-
parseAcceptLanguageHeader
-
parseLanguageTag
-
decodeValueIfEncoded
-