|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.grizzly.http.algorithms.StreamAlgorithmBase
com.sun.grizzly.http.algorithms.ContentLengthAlgorithm
public class ContentLengthAlgorithm
Predict if the NIO channel has been fully read or not. This lagorithm will first search for the content-length header, and use that value to determine if the bytes has been fully read or not. If the content-length isn't included, it will search for the end of the HTTP stream, which is a '\r\n' Note: the parsing algorithm is an adaptation of: org.apache.coyote.http11.InternalInputBuffer written by Remy Maucherat
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.sun.grizzly.http.algorithms.StreamAlgorithmBase |
---|
StreamAlgorithmBase.DummyHandler |
Field Summary | |
---|---|
byte[] |
ascbuf
Pointer to the US-ASCII header buffer. |
protected static byte[] |
CL_HEADER
|
protected boolean |
isFound
Is the content-length fully read. |
protected int |
lastValid
Last valid byte. |
int |
lengthReq
The request bytes length |
protected int |
pos
Position in the buffer. |
protected static byte[] |
POST_METHOD
|
protected static byte[] |
PUT_METHOD
|
protected boolean |
requestLineParsed
Is the request line parsed? |
int |
startReq
The request bytes position. |
Fields inherited from class com.sun.grizzly.http.algorithms.StreamAlgorithmBase |
---|
contentLength, curLimit, curPosition, handler, headerLength, lastStatePosition, primaryByteBuffer, socketChannel, state, useByteBufferView, useDirectByteBuffer |
Constructor Summary | |
---|---|
ContentLengthAlgorithm()
|
Method Summary | |
---|---|
protected int |
findBytes(byte[] buff,
int start,
int end,
byte[] b)
Compare two bytes array and return > 0 if true. |
Interceptor |
getHandler()
Return the Interceptor used by this algorithm. |
boolean |
parse(ByteBuffer byteBuffer)
Parse the ByteBuffer and try to determine if the bytes
stream has been fully read from the SocketChannel . |
protected boolean |
parseHeader(ByteBuffer byteBuffer)
Parse the headers, looking for content-length header and value. |
protected boolean |
parseRequestLine(ByteBuffer byteBuffer)
Parse the request line, looking for a POST method. |
void |
recycle()
Recylce this object. |
Methods inherited from class com.sun.grizzly.http.algorithms.StreamAlgorithmBase |
---|
allocate, contentLength, dump, getPort, headerLength, postParse, preParse, rollbackParseState, setPort, setSocketChannel |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final byte[] POST_METHOD
protected static final byte[] PUT_METHOD
protected static final byte[] CL_HEADER
public byte[] ascbuf
protected int lastValid
protected int pos
protected boolean isFound
protected boolean requestLineParsed
public int startReq
public int lengthReq
Constructor Detail |
---|
public ContentLengthAlgorithm()
Method Detail |
---|
public boolean parse(ByteBuffer byteBuffer)
ByteBuffer
and try to determine if the bytes
stream has been fully read from the SocketChannel
.
Drain the SocketChannel
and determine if the request bytes
has been fully read. For POST method, parse the bytes and seek for the
content-type header to determine the length of the request bytes.
parse
in interface StreamAlgorithm
parse
in class StreamAlgorithmBase
byteBuffer
- the bytes read.
SelectorThread
This occurs when the stream doesn't contains all the
request bytes.
false if the stream contains all request bytes.protected boolean parseRequestLine(ByteBuffer byteBuffer)
protected boolean parseHeader(ByteBuffer byteBuffer)
protected int findBytes(byte[] buff, int start, int end, byte[] b)
public void recycle()
recycle
in interface StreamAlgorithm
recycle
in class StreamAlgorithmBase
public Interceptor getHandler()
Interceptor
used by this algorithm.
Interceptor
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |