@Override public void transferFrom(FileChannel channel, IoCallback callback) { // Transfer never caches delegate.transferFrom(channel, callback); }
@Override public void transferFrom(FileChannel channel, IoCallback callback) { // Transfer never caches delegate.transferFrom(channel, callback); }
@Override public void transferFrom(FileChannel channel, IoCallback callback) { // Transfer never caches delegate.transferFrom(channel, callback); }
public void sendFile(File file, IoCallback callback) { if (file == null || !file.exists()) { throw new RuntimeException("Invalid file"); } try { String fileExtension = getFileExtension(file.getName()); MediaType mimeForFile = MediaType.getMimeForFile(fileExtension); setResponseMediaType(mimeForFile); HeaderValues contentDisposition = exchange.getResponseHeaders().get(Headers.CONTENT_DISPOSITION); if (contentDisposition == null || contentDisposition.isEmpty()) { exchange.getResponseHeaders().add(Headers.CONTENT_DISPOSITION, "filename=" + file.getName()); } exchange.getResponseHeaders().add(Headers.CONTENT_LENGTH, file.length()); exchange.getResponseSender().transferFrom(FileChannel.open(file.toPath()), callback); } catch (IOException e) { throw new RuntimeException(e); } }
public void sendFile(File file, IoCallback callback) { if (file == null || !file.exists()) { throw new RuntimeException("Invalid file"); } try { String fileExtension = getFileExtension(file.getName()); MediaType mimeForFile = MediaType.getMimeForFile(fileExtension); setResponseMediaType(mimeForFile); HeaderValues contentDisposition = exchange.getResponseHeaders().get(Headers.CONTENT_DISPOSITION); if (contentDisposition == null || contentDisposition.isEmpty()) { exchange.getResponseHeaders().add(Headers.CONTENT_DISPOSITION, "filename=" + file.getName()); } exchange.getResponseHeaders().add(Headers.CONTENT_LENGTH, file.length()); exchange.getResponseSender().transferFrom(FileChannel.open(file.toPath()), callback); } catch (IOException e) { throw new RuntimeException(e); } }
@Override public UndertowResponse send(File file) { try { final FileChannel channel = FileChannel.open(file.toPath(), StandardOpenOption.READ); hse.setResponseContentLength(channel.size()); sender().transferFrom(channel, new IoCallback() { @Override public void onComplete(HttpServerExchange exchange, Sender sender) { IO.close(channel); IoCallback.END_EXCHANGE.onComplete(exchange, sender); } @Override public void onException(HttpServerExchange exchange, Sender sender, IOException exception) { IO.close(channel); IoCallback.END_EXCHANGE.onException(exchange, sender, exception); } }); endAsync = !blocking(); afterWritingContent(); } catch (IOException e) { endAsync = false; afterWritingContent(); throw E.ioException(e); } return me(); }
@Override public UndertowResponse send(File file) { try { final FileChannel channel = FileChannel.open(file.toPath(), StandardOpenOption.READ); hse.setResponseContentLength(channel.size()); sender().transferFrom(channel, new IoCallback() { @Override public void onComplete(HttpServerExchange exchange, Sender sender) { IO.close(channel); IoCallback.END_EXCHANGE.onComplete(exchange, sender); } @Override public void onException(HttpServerExchange exchange, Sender sender, IOException exception) { IO.close(channel); IoCallback.END_EXCHANGE.onException(exchange, sender, exception); } }); endAsync = !blocking(); afterWritingContent(); } catch (IOException e) { endAsync = false; afterWritingContent(); throw E.ioException(e); } return me(); }
sender.transferFrom(fc, new CloseFileChannelIoCallback(fc)); } else { sender.send(injectWebsocketScript(new String(Files.readAllBytes(p), UTF_8)), UTF_8);