/** * {@inheritDoc} */ public boolean isSupportFileSend() { final boolean hasChannel = (response.getChannel() != null); if (lastActiveFilter == -1) { return hasChannel; } else if (lastActiveFilter == 0 && activeFilters[0].getEncodingName().equals("identity")) { return hasChannel; } return false; }
@Override protected void sendCache(Request request, FileCacheEntry entry) throws IOException { boolean flushBody = checkIfHeaders(request, entry); request.getResponse().sendHeaders(); if (flushBody) { SSLOutputWriter.flushChannel(request.getResponse().getChannel(), entry.bb.slice()); } } }
/** * Send the cached resource. */ protected void sendCache(Request request, FileCacheEntry entry) throws IOException{ boolean flushBody = checkIfHeaders(request, entry); request.getResponse().setContentType(entry.contentType); request.getResponse().setContentLength(Integer.valueOf(entry.contentLength)); if (flushBody) { ByteBuffer sliced = entry.bb.slice(); ByteBuffer ob = ((SocketChannelOutputBuffer)request.getResponse() .getOutputBuffer()).getOutputByteBuffer(); int left = ob.remaining(); // It's better to execute a byte copy than two network operation. if (left > sliced.limit()){ request.getResponse().action(ActionCode.ACTION_COMMIT, null); ob.put(sliced); ((SocketChannelOutputBuffer)request.getResponse() .getOutputBuffer()).flushBuffer(); } else { request.getResponse().flush(); OutputWriter.flushChannel(request.getResponse().getChannel(),sliced); } } else { request.getResponse().flush(); } }
if (response.getChannel() != null) { response.getChannel().write(bb); } else { byte b[] = new byte[bb.limit()];