Search in sources :

Example 1 with HttpServletRequestHandler

use of org.apache.tapestry5.http.services.HttpServletRequestHandler in project flowlogix by flowlogix.

the class GwtCachingFilter method service.

@Override
public boolean service(HttpServletRequest request, HttpServletResponse response, HttpServletRequestHandler chainHandler) throws IOException {
    String path = request.getServletPath();
    boolean neverExpire = checkConfig(path, response);
    if (neverExpire == false) {
        return chainHandler.service(request, response);
    }
    log.finer("GwtCachingFilter: Processing " + path);
    Request rq = new RequestImpl(request, applicationCharset, sessionFactory);
    Response rsp = new ResponseImpl(request, response);
    rg.storeRequestResponse(rq, rsp);
    rsp.setDateHeader("Expires", new Date().getTime() + InternalConstants.TEN_YEARS);
    try {
        return carh.handleAssetRequest(rq, rsp, pathProcessor.removeAssetPathPart(path));
    } catch (Exception e) {
        return chainHandler.service(request, response);
    }
}
Also used : Response(org.apache.tapestry5.services.Response) HttpServletResponse(javax.servlet.http.HttpServletResponse) HttpServletRequest(javax.servlet.http.HttpServletRequest) Request(org.apache.tapestry5.services.Request) RequestImpl(org.apache.tapestry5.internal.services.RequestImpl) ResponseImpl(org.apache.tapestry5.internal.services.ResponseImpl) Date(java.util.Date) IOException(java.io.IOException)

Example 2 with HttpServletRequestHandler

use of org.apache.tapestry5.http.services.HttpServletRequestHandler in project tapestry-5 by apache.

the class MultipartServletRequestFilterTest method multipartRequestIsDecoded.

@Test
public void multipartRequestIsDecoded() throws Exception {
    MultipartDecoder decoder = newMock(MultipartDecoder.class);
    HttpServletRequest request = mockHttpServletRequest();
    HttpServletRequest decodedRequest = mockHttpServletRequest();
    HttpServletResponse response = mockHttpServletResponse();
    HttpServletRequestHandler handler = newMock(HttpServletRequestHandler.class);
    MultipartServletRequestFilter filter = new MultipartServletRequestFilter(decoder);
    expect(request.getMethod()).andReturn("post");
    expect(request.getContentType()).andReturn("multipart/form");
    expect(decoder.decode(request)).andReturn(decodedRequest);
    expect(handler.service(decodedRequest, response)).andReturn(true);
    replay();
    boolean isHandled = filter.service(request, response, handler);
    assertTrue(isHandled);
    verify();
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) MultipartDecoder(org.apache.tapestry5.upload.services.MultipartDecoder) HttpServletResponse(javax.servlet.http.HttpServletResponse) HttpServletRequestHandler(org.apache.tapestry5.http.services.HttpServletRequestHandler) Test(org.testng.annotations.Test)

Example 3 with HttpServletRequestHandler

use of org.apache.tapestry5.http.services.HttpServletRequestHandler in project tapestry-5 by apache.

the class TapestryHttpModule method contributeHttpServletRequestHandler.

/**
 * <dl>
 * <dt>StoreIntoGlobals</dt>
 * <dd>Stores the request and response into {@link org.apache.tapestry5.http.services.RequestGlobals} at the start of the
 * pipeline</dd>
 * <dt>IgnoredPaths</dt>
 * <dd>Identifies requests that are known (via the IgnoredPathsFilter service's configuration) to be mapped to other
 * applications</dd>
 * <dt>GZip</dt>
 * <dd>Handles GZIP compression of response streams (if supported by client)</dd>
 * </dl>
 */
public void contributeHttpServletRequestHandler(OrderedConfiguration<HttpServletRequestFilter> configuration, @Symbol(TapestryHttpSymbolConstants.GZIP_COMPRESSION_ENABLED) boolean gzipCompressionEnabled, @Autobuild GZipFilter gzipFilter) {
    HttpServletRequestFilter storeIntoGlobals = new HttpServletRequestFilter() {

        public boolean service(HttpServletRequest request, HttpServletResponse response, HttpServletRequestHandler handler) throws IOException {
            requestGlobals.storeServletRequestResponse(request, response);
            return handler.service(request, response);
        }
    };
    configuration.add("StoreIntoGlobals", storeIntoGlobals, "before:*");
    configuration.add("GZIP", gzipCompressionEnabled ? gzipFilter : null);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) HttpServletResponse(javax.servlet.http.HttpServletResponse) HttpServletRequestHandler(org.apache.tapestry5.http.services.HttpServletRequestHandler) HttpServletRequestFilter(org.apache.tapestry5.http.services.HttpServletRequestFilter)

Example 4 with HttpServletRequestHandler

use of org.apache.tapestry5.http.services.HttpServletRequestHandler in project tapestry-5 by apache.

the class IgnoredPathsFilterTest method path_excluded.

@Test
public void path_excluded() throws Exception {
    HttpServletRequest request = mockHttpServletRequest();
    HttpServletResponse response = mockHttpServletResponse();
    HttpServletRequestHandler handler = mockHttpServletRequestHandler();
    train_getServletPath(request, "/");
    train_getPathInfo(request, "barney/rubble");
    List<String> configuration = CollectionFactory.newList("/barney.*");
    replay();
    HttpServletRequestFilter filter = new IgnoredPathsFilter(configuration);
    assertFalse(filter.service(request, response, handler));
    verify();
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) HttpServletResponse(javax.servlet.http.HttpServletResponse) HttpServletRequestHandler(org.apache.tapestry5.http.services.HttpServletRequestHandler) HttpServletRequestFilter(org.apache.tapestry5.http.services.HttpServletRequestFilter) Test(org.testng.annotations.Test)

Example 5 with HttpServletRequestHandler

use of org.apache.tapestry5.http.services.HttpServletRequestHandler in project tapestry-5 by apache.

the class IgnoredPathsFilterTest method no_path_info.

@Test
public void no_path_info() throws Exception {
    HttpServletRequest request = mockHttpServletRequest();
    HttpServletResponse response = mockHttpServletResponse();
    HttpServletRequestHandler handler = mockHttpServletRequestHandler();
    train_getServletPath(request, "/");
    train_getPathInfo(request, null);
    train_service(handler, request, response, true);
    List<String> configuration = CollectionFactory.newList("/fred");
    replay();
    HttpServletRequestFilter filter = new IgnoredPathsFilter(configuration);
    assertTrue(filter.service(request, response, handler));
    verify();
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) HttpServletResponse(javax.servlet.http.HttpServletResponse) HttpServletRequestHandler(org.apache.tapestry5.http.services.HttpServletRequestHandler) HttpServletRequestFilter(org.apache.tapestry5.http.services.HttpServletRequestFilter) Test(org.testng.annotations.Test)

Aggregations

HttpServletRequest (javax.servlet.http.HttpServletRequest)7 HttpServletResponse (javax.servlet.http.HttpServletResponse)7 HttpServletRequestHandler (org.apache.tapestry5.http.services.HttpServletRequestHandler)7 Test (org.testng.annotations.Test)5 HttpServletRequestFilter (org.apache.tapestry5.http.services.HttpServletRequestFilter)4 MultipartDecoder (org.apache.tapestry5.upload.services.MultipartDecoder)2 IOException (java.io.IOException)1 Date (java.util.Date)1 ServletContext (javax.servlet.ServletContext)1 AsyncRequestService (org.apache.tapestry5.http.internal.AsyncRequestService)1 ServletContextSymbolProvider (org.apache.tapestry5.http.internal.ServletContextSymbolProvider)1 SingleKeySymbolProvider (org.apache.tapestry5.http.internal.SingleKeySymbolProvider)1 TapestryAppInitializer (org.apache.tapestry5.http.internal.TapestryAppInitializer)1 DelegatingSymbolProvider (org.apache.tapestry5.http.internal.util.DelegatingSymbolProvider)1 ServletApplicationInitializer (org.apache.tapestry5.http.services.ServletApplicationInitializer)1 RequestImpl (org.apache.tapestry5.internal.services.RequestImpl)1 ResponseImpl (org.apache.tapestry5.internal.services.ResponseImpl)1 SystemPropertiesSymbolProvider (org.apache.tapestry5.ioc.internal.services.SystemPropertiesSymbolProvider)1 SymbolProvider (org.apache.tapestry5.ioc.services.SymbolProvider)1 Request (org.apache.tapestry5.services.Request)1