/** * Writes the specified file directly to the response. * <p>This method commits the response.</p> * * @param file */ public void file(File file) { try { contentLength(file.length()); file(file.getName(), new FileInputStream(file)); } catch (FileNotFoundException e) { throw new PippoRuntimeException(e); } }
protected void handleDirectoryRequest(RouteContext routeContext, File dir) throws MalformedURLException { File index = getIndexFile(dir); if (index != null) { routeContext.getResponse().contentLength(index.length()); URL url = index.toURI().toURL(); streamResource(url, routeContext); return; } sendDirectoryListing(routeContext, dir); }
private void commit(CharSequence content) { checkCommitted(); finalizeResponse(); // content type to TEXT_HTML if it's not set if (getContentType() == null) { contentType(HttpConstants.ContentType.TEXT_HTML); } try { if (content != null) { contentLength(content.toString().getBytes().length); httpServletResponse.getWriter().append(content); } log.trace("Response committed"); if (chunked) { httpServletResponse.flushBuffer(); } finishGZip(); } catch (IOException e) { throw new PippoRuntimeException(e); } }
if (file.exists()) { if (file.isFile()) { routeContext.getResponse().contentLength(file.length()); URL url = requestedPath.toUri().toURL(); switch (routeContext.getRequestMethod()) {
context.getResponse().ok().contentType(TEXT_XML).contentLength(result.length); try (OutputStream output = context.getResponse().getOutputStream()) { output.write(result);
context.getResponse().ok().contentType(TEXT_XML).contentLength(result.length); try (OutputStream output = context.getResponse().getOutputStream()) { output.write(result);