/** * Flush the buffer by looping until the {@link ByteBuffer} is empty * @param channel {@link SelectableChannel} * @param bb the ByteBuffer to write. * @return * @throws java.io.IOException */ public static long flushChannel(SelectableChannel channel, ByteBuffer bb) throws IOException{ return flushChannel(channel,bb,defaultWriteTimeout); }
int timeout = Integer.parseInt( System.getProperty(WRITE_TIMEOUT)); OutputWriter.setDefaultWriteTimeout(timeout); } catch (NumberFormatException ex){ SelectorThread.logger().log(Level.WARNING,
int timeout = Integer.parseInt( System.getProperty(WRITE_TIMEOUT)); OutputWriter.setDefaultWriteTimeout(timeout); } catch (NumberFormatException ex){ SelectorThread.logger().log(Level.WARNING,
/** * Flush the buffer by looping until the {@link ByteBuffer} is empty * @param socketChannel {@link SocketChannel} * @param bb the ByteBuffer to write. * @return * @throws java.io.IOException */ public static long flushChannel(SocketChannel socketChannel, ByteBuffer[] bb) throws IOException{ return flushChannel(socketChannel,bb,defaultWriteTimeout); }
/** * Flush the buffer by looping until the {@link ByteBuffer} is empty * @param channel {@link SelectableChannel} * @param bb the ByteBuffer to write. * @return * @throws java.io.IOException */ public static long flushChannel(SelectableChannel channel, ByteBuffer bb) throws IOException{ return flushChannel(channel,bb,defaultWriteTimeout); }
/** * Flush the buffer by looping until the {@link ByteBuffer} is empty * @param socketChannel {@link SocketChannel} * @param bb the ByteBuffer to write. * @return * @throws java.io.IOException */ public static long flushChannel(SocketChannel socketChannel, ByteBuffer[] bb) throws IOException{ return flushChannel(socketChannel,bb,defaultWriteTimeout); }
/** * Flush the buffer by looping until the {@link ByteBuffer} is empty * @param channel {@link SelectableChannel} * @param bb the ByteBuffer to write. * @return * @throws java.io.IOException */ public static long flushChannel(SelectableChannel channel, ByteBuffer bb) throws IOException{ return flushChannel(channel,bb,defaultWriteTimeout); }
/** * Flush the buffer by looping until the {@link ByteBuffer} is empty * @param socketChannel {@link SocketChannel} * @param bb the ByteBuffer to write. * @return * @throws java.io.IOException */ public static long flushChannel(SocketChannel socketChannel, ByteBuffer[] bb) throws IOException{ return flushChannel(socketChannel,bb,defaultWriteTimeout); }
/** * Flush the buffer by looping until the {@link ByteBuffer} is empty * @param datagramChannel * @param socketAddress * @param bb the ByteBuffer to write. * @return * @throws java.io.IOException */ public static long flushChannel(DatagramChannel datagramChannel, SocketAddress socketAddress, ByteBuffer bb) throws IOException{ return flushChannel(datagramChannel,socketAddress,bb,defaultWriteTimeout); }
/** * Flush the buffer by looping until the {@link ByteBuffer} is empty * @param datagramChannel * @param socketAddress * @param bb the ByteBuffer to write. * @return * @throws java.io.IOException */ public static long flushChannel(DatagramChannel datagramChannel, SocketAddress socketAddress, ByteBuffer bb) throws IOException{ return flushChannel(datagramChannel,socketAddress,bb,defaultWriteTimeout); }
/** * Flush the buffer by looping until the {@link ByteBuffer} is empty * @param datagramChannel * @param socketAddress * @param bb the ByteBuffer to write. * @return * @throws java.io.IOException */ public static long flushChannel(DatagramChannel datagramChannel, SocketAddress socketAddress, ByteBuffer bb) throws IOException{ return flushChannel(datagramChannel,socketAddress,bb,defaultWriteTimeout); }
/** * Flush the buffer by looping until the {@link ByteBuffer} is empty * @param bb the ByteBuffer to write. */ public void flushChannel(ByteBuffer bb) throws IOException{ OutputWriter.flushChannel(socketChannel, bb); bb.clear(); }
/** * Send the cached resource. */ protected void sendCache(SocketChannel socketChannel, FileCacheEntry entry, boolean keepAlive) throws IOException{ OutputWriter.flushChannel(socketChannel, entry.headerBuffer.slice()); ByteBuffer keepAliveBuf = keepAlive ? connectionKaBB.slice(): connectionCloseBB.slice(); OutputWriter.flushChannel(socketChannel, keepAliveBuf); OutputWriter.flushChannel(socketChannel, entry.bb.slice()); }
/** * Redirect a secure request (http) 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 redirect(Context context, PUProtocolRequest protocolRequest, String httpHeaders) throws IOException{ OutputWriter.flushChannel(protocolRequest.getChannel(), SC_FOUND.slice()); OutputWriter.flushChannel(protocolRequest.getChannel(), ByteBuffer.wrap((httpHeaders + context.getAttribute(HttpProtocolFinder.HTTP_REQUEST_URL) + headers).getBytes())); }
/** * Redirect a secure request (http) to http or https. * @param context {@link Context} of the current * {@link java.nio.channels.SelectionKey} event * @param httpHeaders HTTP headers, which will be sent with response */ private static void redirect(Context context, String httpHeaders) throws IOException{ final SocketChannel channel = (SocketChannel) context.getSelectionKey().channel(); final ByteBuffer[] byteBuffers = new ByteBuffer[2]; final ByteBuffer statusLineBuffer = SC_FOUND.slice(); final ByteBuffer headersBuffer = ByteBuffer.wrap((httpHeaders + new String((byte[]) context.getAttribute(HttpProtocolFinder.HTTP_REQUEST_URL)) + headers).getBytes()); byteBuffers[0] = statusLineBuffer; byteBuffers[1] = headersBuffer; OutputWriter.flushChannel(channel, byteBuffers); }
@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(); }
OutputWriter.flushChannel(((SocketChannel) channel), bb); bb.clear(); } else if (asyncQueueWriter != null) {
nWrite += OutputWriter.flushChannel(channel,outputBB);