use of org.apache.tapestry5.http.services.RequestHandler in project tapestry-5 by apache.
the class StaticFilesFilterTest method existing_file.
@Test
public void existing_file() throws Exception {
URL url = new URL("file://.");
String path = "/cell.gif";
Request request = newRequest(path);
Response response = mockResponse();
RequestHandler handler = mockRequestHandler();
Context context = mockContext();
train_getResource(context, path, url);
replay();
RequestFilter filter = new StaticFilesFilter(context);
assertFalse(filter.service(request, response, handler));
verify();
}
use of org.apache.tapestry5.http.services.RequestHandler in project tapestry-5 by apache.
the class StaticFilesFilterTest method colon_in_path_prevents_static_file_check.
/**
* TAPESTRY-2606
*/
@Test
public void colon_in_path_prevents_static_file_check() throws Exception {
String path = "/start.update:anevent";
Request request = newRequest(path);
Response response = mockResponse();
RequestHandler handler = mockRequestHandler();
Context context = mockContext();
train_service(handler, request, response, true);
replay();
RequestFilter filter = new StaticFilesFilter(context);
assertTrue(filter.service(request, response, handler));
verify();
}
use of org.apache.tapestry5.http.services.RequestHandler in project tapestry-5 by apache.
the class StaticFilesFilterTest method existing_template_file_case_insenitive.
@Test
public void existing_template_file_case_insenitive() throws Exception {
URL url = new URL("file://.");
String path = "/cell.TML";
Request request = newRequest(path);
Response response = mockResponse();
RequestHandler handler = mockRequestHandler();
Context context = mockContext();
train_getResource(context, path, url);
response.sendError(HttpServletResponse.SC_FORBIDDEN, "URI /cell.TML may not be accessed remotely.");
replay();
RequestFilter filter = new StaticFilesFilter(context);
assertTrue(filter.service(request, response, handler));
verify();
}
use of org.apache.tapestry5.http.services.RequestHandler in project tapestry-5 by apache.
the class StaticFilesFilterTest method request_for_favicon.
@Test
public void request_for_favicon() throws IOException {
Request request = newRequest("/favicon.ico");
Response response = mockResponse();
RequestHandler handler = mockRequestHandler();
Context context = mockContext();
replay();
RequestFilter filter = new StaticFilesFilter(context);
assertFalse(filter.service(request, response, handler));
verify();
}
use of org.apache.tapestry5.http.services.RequestHandler in project tapestry-5 by apache.
the class TapestryModule method contributeRequestHandler.
/**
* Continues a number of filters into the RequestHandler service:
* <dl>
* <dt>StaticFiles</dt>
* <dd>Checks to see if the request is for an actual file, if so, returns true to let the servlet container process
* the request</dd>
* <dt>CheckForUpdates</dt>
* <dd>Periodically fires events that checks to see if the file system sources for any cached data has changed (see
* {@link org.apache.tapestry5.internal.services.CheckForUpdatesFilter}). Starting in 5.3, this filter will be null
* in production mode (it will only be active in development mode).
* <dt>ErrorFilter</dt>
* <dd>Catches request errors and lets the {@link org.apache.tapestry5.services.RequestExceptionHandler} handle them
* </dd>
* <dt>StoreIntoGlobals</dt>
* <dd>Stores the request and response into the {@link org.apache.tapestry5.http.services.RequestGlobals} service (this
* is repeated at the end of the pipeline, in case any filter substitutes the request or response).
* <dt>EndOfRequest</dt>
* <dd>Notifies internal services that the request has ended</dd>
* </dl>
*/
public void contributeRequestHandler(OrderedConfiguration<RequestFilter> configuration, Context context, @Symbol(TapestryHttpSymbolConstants.PRODUCTION_MODE) boolean productionMode) {
RequestFilter staticFilesFilter = new StaticFilesFilter(context);
RequestFilter storeIntoGlobals = new RequestFilter() {
public boolean service(Request request, Response response, RequestHandler handler) throws IOException {
requestGlobals.storeRequestResponse(request, response);
return handler.service(request, response);
}
};
RequestFilter fireEndOfRequestEvent = new RequestFilter() {
public boolean service(Request request, Response response, RequestHandler handler) throws IOException {
try {
return handler.service(request, response);
} finally {
endOfRequestEventHub.fire();
}
}
};
if (productionMode) {
configuration.add("CheckForUpdates", null, "before:*");
} else {
configuration.addInstance("CheckForUpdates", CheckForUpdatesFilter.class, "before:*");
}
configuration.add("StaticFiles", staticFilesFilter);
configuration.add("StoreIntoGlobals", storeIntoGlobals);
configuration.add("EndOfRequest", fireEndOfRequestEvent);
configuration.addInstance("ErrorFilter", RequestErrorFilter.class);
}
Aggregations