use of org.eclipse.jetty.server.HttpOutput in project ignite by apache.
the class ResourceHandler method handleRequest.
/**
* @param response Http response.
* @param type Type.
* @param path Path to file.
* @throws IOException If failed.
*/
private static void handleRequest(HttpServletResponse response, String type, String path) throws IOException {
Path path0 = Paths.get(path);
response.setContentType(type);
response.setHeader("Content-Disposition", "attachment; filename=\"" + path0.getFileName() + "\"");
try (HttpOutput out = (HttpOutput) response.getOutputStream()) {
out.sendContent(FileChannel.open(path0, StandardOpenOption.READ));
}
}
use of org.eclipse.jetty.server.HttpOutput in project ignite by apache.
the class ResourceHandler method handleRequest.
/**
* @param response Http response.
* @param type Type.
* @param stream Stream.
* @param attachmentName Attachment name.
* @throws IOException If failed.
*/
private static void handleRequest(HttpServletResponse response, String type, InputStream stream, String attachmentName) throws IOException {
response.setContentType(type);
response.setHeader("Content-Disposition", "attachment; filename=\"" + attachmentName + "\"");
try (HttpOutput out = (HttpOutput) response.getOutputStream()) {
out.sendContent(stream);
}
}
Aggregations