Package one.nio.http
Class HttpSession
- java.lang.Object
-
- one.nio.net.Session
-
- one.nio.http.HttpSession
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class HttpSession extends Session
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class one.nio.net.Session
Session.ArrayQueueItem, Session.QueueItem
-
-
Field Summary
Fields Modifier and Type Field Description protected static RequestFINprotected byte[]fragmentprotected intfragmentLengthprotected Requesthandlingprivate static intHTTP_VERSION_LENGTHprivate static intMAX_FRAGMENT_LENGTHprivate static intMAX_HEADERSprivate static intMAX_PIPELINE_LENGTHprivate static intMAX_REQUEST_BODY_LENGTHprotected Requestparsingprotected java.util.LinkedList<Request>pipelineprotected intrequestBodyOffsetprotected HttpServerserver-
Fields inherited from class one.nio.net.Session
ACTIVE, closing, CLOSING, EVENT_MASK, events, eventsToListen, IDLE, lastAccessTime, log, queueHead, READABLE, selector, slot, socket, SSL, STALE, wasSelected, WRITEABLE
-
-
Constructor Summary
Constructors Constructor Description HttpSession(Socket socket, HttpServer server)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcheckStatus(long currentTime, long keepAlive)protected intgetMaxRequestBodyLength()protected voidhandleParsedRequest()protected voidhandleSocketClosed()protected RequestparseRequest(byte[] buffer, int start, int length)protected intprocessHttpBuffer(byte[] buffer, int length)protected voidprocessRead(byte[] buffer)voidsendError(java.lang.String code, java.lang.String message)voidsendResponse(Response response)protected intstartParsingRequestBody(java.lang.String contentLengthHeader, byte[] buffer, int offset, int remaining)protected voidwriteResponse(Response response, boolean includeBody)-
Methods inherited from class one.nio.net.Session
close, getQueueStats, getRemoteHost, handleException, isSsl, lastAccessTime, listen, process, processWrite, read, readRaw, scheduleClose, socket, write, write, write
-
-
-
-
Field Detail
-
MAX_HEADERS
private static final int MAX_HEADERS
- See Also:
- Constant Field Values
-
MAX_FRAGMENT_LENGTH
private static final int MAX_FRAGMENT_LENGTH
- See Also:
- Constant Field Values
-
MAX_PIPELINE_LENGTH
private static final int MAX_PIPELINE_LENGTH
- See Also:
- Constant Field Values
-
MAX_REQUEST_BODY_LENGTH
private static final int MAX_REQUEST_BODY_LENGTH
- See Also:
- Constant Field Values
-
HTTP_VERSION_LENGTH
private static final int HTTP_VERSION_LENGTH
- See Also:
- Constant Field Values
-
FIN
protected static final Request FIN
-
server
protected final HttpServer server
-
pipeline
protected final java.util.LinkedList<Request> pipeline
-
fragment
protected final byte[] fragment
-
fragmentLength
protected int fragmentLength
-
requestBodyOffset
protected int requestBodyOffset
-
parsing
protected Request parsing
-
handling
protected volatile Request handling
-
-
Constructor Detail
-
HttpSession
public HttpSession(Socket socket, HttpServer server)
-
-
Method Detail
-
checkStatus
public int checkStatus(long currentTime, long keepAlive)- Overrides:
checkStatusin classSession
-
processRead
protected void processRead(byte[] buffer) throws java.io.IOException- Overrides:
processReadin classSession- Throws:
java.io.IOException
-
handleSocketClosed
protected void handleSocketClosed()
-
getMaxRequestBodyLength
protected int getMaxRequestBodyLength()
-
startParsingRequestBody
protected int startParsingRequestBody(java.lang.String contentLengthHeader, byte[] buffer, int offset, int remaining) throws java.io.IOException, HttpException- Throws:
java.io.IOExceptionHttpException
-
handleParsedRequest
protected void handleParsedRequest() throws java.io.IOException- Throws:
java.io.IOException
-
processHttpBuffer
protected int processHttpBuffer(byte[] buffer, int length) throws java.io.IOException, HttpException- Throws:
java.io.IOExceptionHttpException
-
parseRequest
protected Request parseRequest(byte[] buffer, int start, int length) throws HttpException
- Throws:
HttpException
-
sendResponse
public void sendResponse(Response response) throws java.io.IOException
- Throws:
java.io.IOException
-
sendError
public void sendError(java.lang.String code, java.lang.String message) throws java.io.IOException- Throws:
java.io.IOException
-
writeResponse
protected void writeResponse(Response response, boolean includeBody) throws java.io.IOException
- Throws:
java.io.IOException
-
-