Class WebRequest
- All Implemented Interfaces:
javax.servlet.http.HttpServletRequest
,javax.servlet.ServletRequest
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:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Progress listener interface.static enum
Enumeration for a WebSocket read event (not yet implemented).static enum
The type of response that this request will need. -
Field Summary
Fields inherited from interface javax.servlet.http.HttpServletRequest
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH
-
Constructor Summary
ConstructorDescriptionWebRequest
(Map<String, String[]> parameters, Map<String, List<UploadedFile>> files) Creates a mock WebRequest given list of parameters and a list of POST'ed files.WebRequest
(javax.servlet.http.HttpServletRequest request, WebRequest.ProgressListener progressListener, Configuration configuration) Creates a WebRequest by wrapping an HttpServletRequest -
Method Summary
Modifier and TypeMethodDescriptionstatic String
computePathInfo
(javax.servlet.http.HttpServletRequest request, Configuration configuration) static String
computePathInfo
(javax.servlet.http.HttpServletRequest request, String scriptName, Configuration configuration) static String
computeScriptName
(javax.servlet.http.HttpServletRequest request, Configuration configuration) getHeaderValue
(String header) Returns a header value.getHostName
(Configuration conf) getParameter
(String name) Returns the parameter value for a parameter's name.Returns the parameter map.String[]
getParameterValues
(String name) Returns the parameter values for a parameter.Returns the internal path information.Returns the request method.Returns the script name.Returns the list of uploaded files.getUrlScheme
(Configuration conf) Accesses to specific header fields (calls getHeaderValue()).boolean
Returns whether this request is a WebSocket message.boolean
Returns whether this request is a WebSocket request.protected void
readParameters
(byte[] buf) Read and store query parametersMethods inherited from class javax.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, isRequestedSessionIdFromURL, isRequestedSessionIdValid, isTrailerFieldsReady, isUserInRole, login, logout, newPushBuilder, upgrade
Methods inherited from class javax.servlet.ServletRequestWrapper
getAsyncContext, getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentLengthLong, getContentType, getDispatcherType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameterNames, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequest, getRequestDispatcher, getScheme, getServerName, getServerPort, getServletContext, isAsyncStarted, isAsyncSupported, isSecure, isWrapperFor, isWrapperFor, removeAttribute, setAttribute, 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 javax.servlet.ServletRequest
getAsyncContext, getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentLengthLong, getContentType, getDispatcherType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameterNames, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequestDispatcher, getScheme, getServerName, getServerPort, getServletContext, isAsyncStarted, isAsyncSupported, isSecure, removeAttribute, setAttribute, setCharacterEncoding, startAsync, startAsync
-
Constructor Details
-
WebRequest
public WebRequest(javax.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
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 Details
-
computeScriptName
public static String computeScriptName(javax.servlet.http.HttpServletRequest request, Configuration configuration) -
computePathInfo
public static String computePathInfo(javax.servlet.http.HttpServletRequest request, Configuration configuration) -
computePathInfo
public static String computePathInfo(javax.servlet.http.HttpServletRequest request, String scriptName, Configuration configuration) -
getRequestMethod
Returns the request method. -
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
Returns a header value.Returns the corresponding header value, using
HttpServletRequestWrapper.getHeader(String)
ornull
if the header value is not present- Parameters:
header
- the header name- Returns:
- the header value, or
null
.
-
getUserAgent
Accesses to specific header fields (calls getHeaderValue()). -
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:
getPathInfo
in interfacejavax.servlet.http.HttpServletRequest
- Overrides:
getPathInfo
in classjavax.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
Returns the list of uploaded files.- Returns:
- the list of uploaded files.
-
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:
getParameterMap
in interfacejavax.servlet.ServletRequest
- Overrides:
getParameterMap
in classjavax.servlet.ServletRequestWrapper
-
getParameterValues
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:
getParameterValues
in interfacejavax.servlet.ServletRequest
- Overrides:
getParameterValues
in classjavax.servlet.ServletRequestWrapper
- See Also:
-
getParameter
Returns the parameter value for a parameter's name.- Specified by:
getParameter
in interfacejavax.servlet.ServletRequest
- Overrides:
getParameter
in classjavax.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
-
getHostName
-
getUrlScheme
-