Search in sources :

Example 11 with ServletRequestWrapper

use of javax.servlet.ServletRequestWrapper in project undertow by undertow-io.

the class HttpServletRequestImpl method startAsync.

@Override
public AsyncContext startAsync(final ServletRequest servletRequest, final ServletResponse servletResponse) throws IllegalStateException {
    final ServletRequestContext servletRequestContext = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY);
    if (!servletContext.getDeployment().getDeploymentInfo().isAllowNonStandardWrappers()) {
        if (servletRequestContext.getOriginalRequest() != servletRequest) {
            if (!(servletRequest instanceof ServletRequestWrapper)) {
                throw UndertowServletMessages.MESSAGES.requestWasNotOriginalOrWrapper(servletRequest);
            }
        }
        if (servletRequestContext.getOriginalResponse() != servletResponse) {
            if (!(servletResponse instanceof ServletResponseWrapper)) {
                throw UndertowServletMessages.MESSAGES.responseWasNotOriginalOrWrapper(servletResponse);
            }
        }
    }
    if (!isAsyncSupported()) {
        throw UndertowServletMessages.MESSAGES.startAsyncNotAllowed();
    } else if (asyncStarted) {
        throw UndertowServletMessages.MESSAGES.asyncAlreadyStarted();
    }
    asyncStarted = true;
    return asyncContext = new AsyncContextImpl(exchange, servletRequest, servletResponse, servletRequestContext, true, asyncContext);
}
Also used : ServletRequestWrapper(javax.servlet.ServletRequestWrapper) ServletRequestContext(io.undertow.servlet.handlers.ServletRequestContext) ServletResponseWrapper(javax.servlet.ServletResponseWrapper)

Aggregations

ServletRequestWrapper (javax.servlet.ServletRequestWrapper)11 ServletRequest (javax.servlet.ServletRequest)10 HttpServletRequest (javax.servlet.http.HttpServletRequest)10 ServletResponseWrapper (javax.servlet.ServletResponseWrapper)6 ServletException (javax.servlet.ServletException)5 ServletResponse (javax.servlet.ServletResponse)5 HttpServletResponse (javax.servlet.http.HttpServletResponse)5 IOException (java.io.IOException)4 HttpServletRequestWrapper (javax.servlet.http.HttpServletRequestWrapper)4 PrivilegedActionException (java.security.PrivilegedActionException)3 Deque (java.util.Deque)3 PrintWriter (java.io.PrintWriter)2 Request (org.apache.catalina.connector.Request)2 Test (org.junit.Test)2 ServletRequestContext (io.undertow.servlet.handlers.ServletRequestContext)1 BufferedWriter (java.io.BufferedWriter)1 File (java.io.File)1 OutputStream (java.io.OutputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1 Reader (java.io.Reader)1