public void sendError(int sc, String message) throws IOException { response.sendError(sc, message); }
public boolean dispatch(Request request, Response response) throws IOException { String path = request.getPath(); if (path.startsWith(requestPrefix)) { String extraPath = path.substring(requestPrefix.length()); Locale locale = request.getLocale(); if (!handleModuleRequest(locale, extraPath, response)) { response.sendError(HttpServletResponse.SC_NOT_FOUND, String.format("No module for path '%s'.", extraPath)); } return true; } return false; }
public void processResultValue(HttpError value) throws IOException { response.sendError(value.getStatusCode(), value.getMessage()); } }
response.sendError(HttpServletResponse.SC_NOT_FOUND, path);
public boolean streamResource(final Resource resource, final String providedChecksum, final Set<Options> options) throws IOException { if (!resource.exists()) { // TODO: Or should we just return false here and not send back a specific error with the (eventual) 404? response.sendError(HttpServletResponse.SC_NOT_FOUND, String.format("Unable to locate asset '%s' (the file does not exist).", resource)); return true; } final boolean compress = providedChecksum.startsWith("z"); return tracker.perform("Streaming " + resource + (compress ? " (compressed)" : ""), new IOOperation<Boolean>() { public Boolean perform() throws IOException { StreamableResourceProcessing processing = compress ? StreamableResourceProcessing.COMPRESSION_ENABLED : StreamableResourceProcessing.COMPRESSION_DISABLED; StreamableResource streamable = streamableResourceSource.getStreamableResource(resource, processing, resourceChangeTracker); return streamResource(resource, streamable, compress ? providedChecksum.substring(1) : providedChecksum, options); } }); }
response.sendError(HttpServletResponse.SC_FORBIDDEN, String.format("URI %s may not be accessed remotely.", path));
@Test public void existing_template_file() 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(); }
@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(); }