Search in sources :

Example 1 with HttpServletRequestFilter

use of org.apache.tapestry5.http.services.HttpServletRequestFilter 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 2 with HttpServletRequestFilter

use of org.apache.tapestry5.http.services.HttpServletRequestFilter 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 3 with HttpServletRequestFilter

use of org.apache.tapestry5.http.services.HttpServletRequestFilter 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)

Example 4 with HttpServletRequestFilter

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

the class IgnoredPathsFilterTest method no_match.

@Test
public void no_match() throws IOException {
    HttpServletRequest request = mockHttpServletRequest();
    HttpServletResponse response = mockHttpServletResponse();
    HttpServletRequestHandler handler = mockHttpServletRequestHandler();
    train_getServletPath(request, "/");
    train_getPathInfo(request, "barney");
    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)4 HttpServletResponse (javax.servlet.http.HttpServletResponse)4 HttpServletRequestFilter (org.apache.tapestry5.http.services.HttpServletRequestFilter)4 HttpServletRequestHandler (org.apache.tapestry5.http.services.HttpServletRequestHandler)4 Test (org.testng.annotations.Test)3