* We need to make sure client started to send payload before redirecting/closing
* the connection. Otherwise client can not receive "HTTP 302 redirect" response.
*/
ByteBuffer tmpBuffer = protocolInfo.byteBuffer;
tmpBuffer.clear();
ByteBufferInputStream is = new ByteBufferInputStream(tmpBuffer);
try {
is.setReadTimeout(2);
is.setSelectionKey(protocolInfo.key);
int count = 0;
while (tmpBuffer.hasRemaining() && count < DEFAULT_HTTP_HEADER_BUFFER_SIZE) {
tmpBuffer.position(tmpBuffer.limit());
int readBytes = is.read();
if (readBytes == -1) break;
count += readBytes;
}
} catch(IOException e) {
// ignore
} finally {
is.close();
}
//=========================================================
}