Package de.xima.fc.http
Class MultipartPreservingRequest
- java.lang.Object
-
- javax.servlet.ServletRequestWrapper
-
- javax.servlet.http.HttpServletRequestWrapper
-
- de.xima.fc.http.MultipartPreservingRequest
-
- All Implemented Interfaces:
javax.servlet.http.HttpServletRequest
,javax.servlet.ServletRequest
public class MultipartPreservingRequest extends javax.servlet.http.HttpServletRequestWrapper
A wrapper formultipart
HttpServletRequest
s that preserve theirmulitpart
parts, meaning the parts can be accessed multiple times during the entire request scope and performs immediate malware scanning upon parts parsing.- Since:
- 8.0.0
- Author:
- XIMA MEDIA GmbH, Dresden
-
-
Constructor Summary
Constructors Constructor Description MultipartPreservingRequest(javax.servlet.http.HttpServletRequest request)
Constructor for the request wrapper.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static MultipartPreservingRequest
getCurrent(IRequestContext requestCtx)
Gets the current instance ofMultipartPreservingRequest
of this request context if it exists.static MultipartPreservingRequest
getCurrent(javax.servlet.http.HttpServletRequest request)
Gets the current instance ofMultipartPreservingRequest
of this request if it exists.List<org.apache.commons.fileupload.FileItem>
getFileItems()
Returns the file items of thismultipart
content request.String
getParameter(String name)
Map<String,String[]>
getParameterMap()
Enumeration<String>
getParameterNames()
String[]
getParameterValues(String name)
javax.servlet.http.Part
getPart(String name)
Collection<javax.servlet.http.Part>
getParts()
static javax.servlet.http.HttpServletRequest
wrap(javax.servlet.http.HttpServletRequest request)
Wraps the request if it is amultipart
contentPOST
request and not already aMultipartPreservingRequest
.-
Methods inherited from class javax.servlet.http.HttpServletRequestWrapper
authenticate, changeSessionId, getAuthType, getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getHttpServletMapping, getIntHeader, getMethod, getPathInfo, 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, 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, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequestDispatcher, getScheme, getServerName, getServerPort, getServletContext, isAsyncStarted, isAsyncSupported, isSecure, removeAttribute, setAttribute, setCharacterEncoding, startAsync, startAsync
-
-
-
-
Constructor Detail
-
MultipartPreservingRequest
public MultipartPreservingRequest(javax.servlet.http.HttpServletRequest request)
Constructor for the request wrapper.- Parameters:
request
- to be wrapped.- Throws:
IllegalArgumentException
- if the request is not amultipart
POST request.
-
-
Method Detail
-
wrap
public static javax.servlet.http.HttpServletRequest wrap(javax.servlet.http.HttpServletRequest request)
Wraps the request if it is amultipart
contentPOST
request and not already aMultipartPreservingRequest
.- Parameters:
request
- to wrap.- Returns:
- the wrapped request or the initial request if it is no
multipart
contentPOST
request.
-
getCurrent
public static MultipartPreservingRequest getCurrent(javax.servlet.http.HttpServletRequest request)
Gets the current instance ofMultipartPreservingRequest
of this request if it exists.- Parameters:
request
- to get the current instance ofMultipartPreservingRequest
for.- Returns:
- the current instance of
MultipartPreservingRequest
ornull
if it does not exist.
-
getCurrent
public static MultipartPreservingRequest getCurrent(IRequestContext requestCtx)
Gets the current instance ofMultipartPreservingRequest
of this request context if it exists.- Parameters:
requestCtx
- to get the current instance ofMultipartPreservingRequest
for.- Returns:
- the current instance of
MultipartPreservingRequest
ornull
if it does not exist.
-
getParts
public Collection<javax.servlet.http.Part> getParts() throws IOException, javax.servlet.ServletException
- Specified by:
getParts
in interfacejavax.servlet.http.HttpServletRequest
- Overrides:
getParts
in classjavax.servlet.http.HttpServletRequestWrapper
- Throws:
IOException
javax.servlet.ServletException
-
getPart
public javax.servlet.http.Part getPart(String name) throws IOException, javax.servlet.ServletException
- Specified by:
getPart
in interfacejavax.servlet.http.HttpServletRequest
- Overrides:
getPart
in classjavax.servlet.http.HttpServletRequestWrapper
- Throws:
IOException
javax.servlet.ServletException
-
getParameterMap
public Map<String,String[]> getParameterMap()
- Specified by:
getParameterMap
in interfacejavax.servlet.ServletRequest
- Overrides:
getParameterMap
in classjavax.servlet.ServletRequestWrapper
-
getParameterNames
public Enumeration<String> getParameterNames()
- Specified by:
getParameterNames
in interfacejavax.servlet.ServletRequest
- Overrides:
getParameterNames
in classjavax.servlet.ServletRequestWrapper
-
getParameterValues
public String[] getParameterValues(String name)
- Specified by:
getParameterValues
in interfacejavax.servlet.ServletRequest
- Overrides:
getParameterValues
in classjavax.servlet.ServletRequestWrapper
-
getParameter
public String getParameter(String name)
- Specified by:
getParameter
in interfacejavax.servlet.ServletRequest
- Overrides:
getParameter
in classjavax.servlet.ServletRequestWrapper
-
getFileItems
public List<org.apache.commons.fileupload.FileItem> getFileItems()
Returns the file items of thismultipart
content request.- Returns:
- parsed file items of this request.
-
-