/** * Flush the buffer by looping until the {@link ByteBuffer} is empty * using {@link SSLOutputBuffer} * @param bb the ByteBuffer to write. */ @Override public void flushChannel(ByteBuffer bb) throws IOException{ SSLOutputWriter.flushChannel(socketChannel, bb, outputBB, sslEngine); }
/** * Flush the buffer by looping until the {@link ByteBuffer} is empty * using {@link SSLOutputBuffer} * @param bb the ByteBuffer to write. */ @Override public void flushChannel(ByteBuffer bb) throws IOException{ SSLOutputWriter.flushChannel((SocketChannel)channel, bb, outputBB, sslEngine); }
/** * Flush the buffer by looping until the {@link ByteBuffer} is empty * using {@link SSLOutputBuffer} * @param bb the ByteBuffer to write. */ @Override public void flushChannel(ByteBuffer bb) throws IOException{ SSLOutputWriter.flushChannel(socketChannel, bb); }
public int write(ByteBuffer src) throws IOException { int nWrite = src.limit(); SSLOutputWriter.flushChannel(getSocketChannel(), src); return nWrite; } };
@Override protected void sendCache(SocketChannel socketChannel, FileCacheEntry entry, boolean keepAlive) throws IOException{ SSLOutputWriter.flushChannel(socketChannel, entry.headerBuffer.slice()); ByteBuffer keepAliveBuf = keepAlive ? connectionKaBB.slice(): connectionCloseBB.slice(); SSLOutputWriter.flushChannel(socketChannel, keepAliveBuf); SSLOutputWriter.flushChannel(socketChannel, entry.bb.slice()); } };
/** * Encrypt the response and flush it using {@link OutputWriter} * @param channel {@link SelectableChannel} to flush * @param bb {@link ByteBuffer} * @return number of bytes written * @throws java.io.IOException */ public static long flushChannel(SelectableChannel channel, ByteBuffer bb) throws IOException{ WorkerThread workerThread = (WorkerThread)Thread.currentThread(); SSLEngine sslEngine = workerThread.getSSLEngine(); ByteBuffer outputBB = workerThread.getOutputBB(); return flushChannel(channel,bb,outputBB,sslEngine); }
public boolean execute(Context ctx) throws IOException { final WorkerThread workerThread = ((WorkerThread)Thread.currentThread()); ByteBuffer buffer = workerThread.getByteBuffer(); buffer.flip(); if (buffer.hasRemaining()) { // Store incoming data in byte[] byte[] data = new byte[buffer.remaining()]; int position = buffer.position(); buffer.get(data); buffer.position(position); SelectableChannel channel = ctx.getSelectionKey().channel(); try { SSLOutputWriter.flushChannel(channel, buffer); } catch (IOException ex) { throw ex; } } buffer.clear(); return false; }
/** * Encrypt the response and flush it using {@link OutputWriter} * @param channel {@link SelectableChannel} to flush * @param bb {@link ByteBuffer} * @return number of bytes written * @throws java.io.IOException */ public static long flushChannel(SelectableChannel channel, ByteBuffer bb) throws IOException{ WorkerThread workerThread = (WorkerThread)Thread.currentThread(); SSLEngine sslEngine = workerThread.getSSLEngine(); ByteBuffer outputBB = workerThread.getOutputBB(); return flushChannel(channel,bb,outputBB,sslEngine); }
/** * Encrypt the response and flush it using {@link OutputWriter} * @param channel {@link SelectableChannel} to flush * @param bb {@link ByteBuffer} * @return number of bytes written * @throws java.io.IOException */ public static long flushChannel(SelectableChannel channel, ByteBuffer bb) throws IOException{ WorkerThread workerThread = (WorkerThread)Thread.currentThread(); SSLEngine sslEngine = workerThread.getSSLEngine(); ByteBuffer outputBB = workerThread.getOutputBB(); return flushChannel(channel,bb,outputBB,sslEngine); }
singleBuffer.flip(); SSLOutputWriter.flushChannel(channel, singleBuffer, outputBB,
@Override public void writeResponseHead(Response response) throws IOException { final ByteArrayOutputStream headStream = new ByteArrayOutputStream(8192); writeResponseHead(response, headStream); final ByteBuffer buffer = ByteBuffer.wrap(headStream.toByteArray()); if (isConfidential()) { SSLOutputWriter.flushChannel(getSocketChannel(), buffer); } else { OutputWriter.flushChannel(getSocketChannel(), buffer); } buffer.clear(); }
long nWrite = SSLOutputWriter.flushChannel(socketChannel, byteBuffer, securedOutputBuffer, sslEngine);
/** * Redirect a secure request (https) to http or https. * @param context {@link Context} of the occured * {@link SelectionKey} event * @param protocolRequest PortUnification protocol request information * @param httpHeaders HTTP headers, which will be sent with response */ private static final void redirectSSL(Context context, PUProtocolRequest protocolRequest, String httpHeaders) throws IOException { SSLOutputWriter.flushChannel(protocolRequest.getChannel(), SC_FOUND.slice(), protocolRequest.getSecuredOutputByteBuffer(), protocolRequest.getSSLEngine()); SSLOutputWriter.flushChannel(protocolRequest.getChannel(), ByteBuffer.wrap((httpHeaders + context.getAttribute(HttpProtocolFinder.HTTP_REQUEST_URL) + headers).getBytes()), protocolRequest.getSecuredOutputByteBuffer(), protocolRequest.getSSLEngine()); }
SSLOutputWriter.flushChannel((SocketChannel) channel, bb, securedBB, sslEngine); if (!isBufferAssociated) { // If secured ByteBuffer is not associated with the current thread - try to return in to the pool bufferPool.offer(securedBB);
@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()); } } }