Class WebRequest
- java.lang.Object
-
- jakarta.servlet.ServletRequestWrapper
-
- jakarta.servlet.http.HttpServletRequestWrapper
-
- eu.webtoolkit.jwt.servlet.WebRequest
-
- All Implemented Interfaces:
jakarta.servlet.http.HttpServletRequest,jakarta.servlet.ServletRequest
public class WebRequest extends jakarta.servlet.http.HttpServletRequestWrapperA WebRequest which wraps the HttpServletRequest to add support for file uploads and testing.WebRequest is used instead of HttpServletRequest inside JWt's request handling, and also in
WResource.handleRequest(WebRequest request, WebResponse response). It handles files being POST'ed, and treats parameters in the URL or within the request body in the same way.- See Also:
WebResponse
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceWebRequest.ProgressListenerProgress listener interface.static classWebRequest.ReadEventEnumeration for a WebSocket read event (not yet implemented).static classWebRequest.ResponseTypeThe type of response that this request will need.
-
Constructor Summary
Constructors Constructor Description WebRequest(jakarta.servlet.http.HttpServletRequest request, WebRequest.ProgressListener progressListener, Configuration configuration)Creates a WebRequest by wrapping an HttpServletRequestWebRequest(java.util.Map<java.lang.String,java.lang.String[]> parameters, java.util.Map<java.lang.String,java.util.List<eu.webtoolkit.jwt.servlet.UploadedFile>> files)Creates a mock WebRequest given list of parameters and a list of POST'ed files.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.StringcomputePathInfo(jakarta.servlet.http.HttpServletRequest request, Configuration configuration)static java.lang.StringcomputePathInfo(jakarta.servlet.http.HttpServletRequest request, java.lang.String scriptName, Configuration configuration)static java.lang.StringcomputeScriptName(jakarta.servlet.http.HttpServletRequest request, Configuration configuration)java.lang.StringgetClientAddress(Configuration conf)java.lang.StringgetHeaderValue(java.lang.String header)Returns a header value.java.lang.StringgetHostName(Configuration conf)java.lang.StringgetParameter(java.lang.String name)Returns the parameter value for a parameter's name.java.util.Map<java.lang.String,java.lang.String[]>getParameterMap()Returns the parameter map.java.lang.String[]getParameterValues(java.lang.String name)Returns the parameter values for a parameter.java.lang.StringgetPathInfo()Returns the internal path information.java.lang.StringgetRequestMethod()Returns the request method.java.lang.StringgetScriptName()Returns the script name.java.util.Map<java.lang.String,java.util.List<eu.webtoolkit.jwt.servlet.UploadedFile>>getUploadedFiles()Returns the list of uploaded files.java.lang.StringgetUrlScheme(Configuration conf)java.lang.StringgetUserAgent()Accesses to specific header fields (calls getHeaderValue()).booleanisWebSocketMessage()Returns whether this request is a WebSocket message.booleanisWebSocketRequest()Returns whether this request is a WebSocket request.protected voidreadParameters(byte[] buf)Read and store query parameters-
Methods inherited from class jakarta.servlet.http.HttpServletRequestWrapper
authenticate, changeSessionId, getAuthType, getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getHttpServletMapping, getIntHeader, getMethod, getPart, getParts, getPathTranslated, getQueryString, getRemoteUser, getRequestedSessionId, getRequestURI, getRequestURL, getServletPath, getSession, getSession, getTrailerFields, getUserPrincipal, isRequestedSessionIdFromCookie, isRequestedSessionIdFromURL, isRequestedSessionIdValid, isTrailerFieldsReady, isUserInRole, login, logout, newPushBuilder, upgrade
-
Methods inherited from class jakarta.servlet.ServletRequestWrapper
getAsyncContext, getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentLengthLong, getContentType, getDispatcherType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameterNames, getProtocol, getProtocolRequestId, getReader, getRemoteAddr, getRemoteHost, getRemotePort, getRequest, getRequestDispatcher, getRequestId, getScheme, getServerName, getServerPort, getServletConnection, getServletContext, isAsyncStarted, isAsyncSupported, isSecure, isWrapperFor, isWrapperFor, removeAttribute, setAttribute, setCharacterEncoding, setCharacterEncoding, setRequest, startAsync, startAsync
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jakarta.servlet.ServletRequest
getAsyncContext, getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentLengthLong, getContentType, getDispatcherType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameterNames, getProtocol, getProtocolRequestId, getReader, getRemoteAddr, getRemoteHost, getRemotePort, getRequestDispatcher, getRequestId, getScheme, getServerName, getServerPort, getServletConnection, getServletContext, isAsyncStarted, isAsyncSupported, isSecure, removeAttribute, setAttribute, setCharacterEncoding, setCharacterEncoding, startAsync, startAsync
-
-
-
-
Constructor Detail
-
WebRequest
public WebRequest(jakarta.servlet.http.HttpServletRequest request, WebRequest.ProgressListener progressListener, Configuration configuration)Creates a WebRequest by wrapping an HttpServletRequest- Parameters:
request- The request to be wrapped.progressListener- a progress listener implementationconfiguration-
-
WebRequest
public WebRequest(java.util.Map<java.lang.String,java.lang.String[]> parameters, java.util.Map<java.lang.String,java.util.List<eu.webtoolkit.jwt.servlet.UploadedFile>> files)Creates a mock WebRequest given list of parameters and a list of POST'ed files.- Parameters:
parameters- a list of request parametersfiles- a list of POST'ed files
-
-
Method Detail
-
computeScriptName
public static java.lang.String computeScriptName(jakarta.servlet.http.HttpServletRequest request, Configuration configuration)
-
computePathInfo
public static java.lang.String computePathInfo(jakarta.servlet.http.HttpServletRequest request, Configuration configuration)
-
computePathInfo
public static java.lang.String computePathInfo(jakarta.servlet.http.HttpServletRequest request, java.lang.String scriptName, Configuration configuration)
-
getRequestMethod
public java.lang.String getRequestMethod()
Returns the request method.
-
getScriptName
public java.lang.String getScriptName()
Returns the script name.This returns in principle
HttpServletRequestWrapper.getContextPath()+HttpServletRequestWrapper.getServletPath(), but with workaround code for corner cases and container workarounds.- Returns:
- the url at which the application is deployed
-
getHeaderValue
public java.lang.String getHeaderValue(java.lang.String header)
Returns a header value.Returns the corresponding header value, using
HttpServletRequestWrapper.getHeader(String)ornullif the header value is not present- Parameters:
header- the header name- Returns:
- the header value, or
null.
-
getUserAgent
public java.lang.String getUserAgent()
Accesses to specific header fields (calls getHeaderValue()).
-
getPathInfo
public java.lang.String getPathInfo()
Returns the internal path information.Returns the
HttpServletRequestWrapper.getPathInfo()or the empty string if there is no internal path in the request. This method also uses workarounds for corner cases for some servlet containers.- Specified by:
getPathInfoin interfacejakarta.servlet.http.HttpServletRequest- Overrides:
getPathInfoin classjakarta.servlet.http.HttpServletRequestWrapper- Returns:
- the internal path information, or an empty string if there is no internal path.
-
readParameters
protected void readParameters(byte[] buf)
Read and store query parameters- Parameters:
buf- UTF-8 encoded byte array with the URI query part
-
getUploadedFiles
public java.util.Map<java.lang.String,java.util.List<eu.webtoolkit.jwt.servlet.UploadedFile>> getUploadedFiles()
Returns the list of uploaded files.- Returns:
- the list of uploaded files.
-
getParameterMap
public java.util.Map<java.lang.String,java.lang.String[]> getParameterMap()
Returns the parameter map.The parameter map includes both the parameters from the query string, as well as parameters posted in the body.
- Specified by:
getParameterMapin interfacejakarta.servlet.ServletRequest- Overrides:
getParameterMapin classjakarta.servlet.ServletRequestWrapper
-
getParameterValues
public java.lang.String[] getParameterValues(java.lang.String name)
Returns the parameter values for a parameter.Returns an array of parameters values given for a particular parameter. When no parameter value was assigned to the parameter, an empty array is returned.
- Specified by:
getParameterValuesin interfacejakarta.servlet.ServletRequest- Overrides:
getParameterValuesin classjakarta.servlet.ServletRequestWrapper- See Also:
getParameterMap()
-
getParameter
public java.lang.String getParameter(java.lang.String name)
Returns the parameter value for a parameter's name.- Specified by:
getParameterin interfacejakarta.servlet.ServletRequest- Overrides:
getParameterin classjakarta.servlet.ServletRequestWrapper- See Also:
ServletRequestWrapper.getParameter(java.lang.String)
-
isWebSocketRequest
public boolean isWebSocketRequest()
Returns whether this request is a WebSocket request. This is an internal JWt method.
-
isWebSocketMessage
public boolean isWebSocketMessage()
Returns whether this request is a WebSocket message. This is an internal JWt method.
-
getClientAddress
public java.lang.String getClientAddress(Configuration conf)
-
getHostName
public java.lang.String getHostName(Configuration conf)
-
getUrlScheme
public java.lang.String getUrlScheme(Configuration conf)
-
-