Package one.nio.http
Class HttpSession
- java.lang.Object
-
- one.nio.net.Session
-
- one.nio.http.HttpSession
-
- All Implemented Interfaces:
Closeable,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 Requesthandlingprotected Requestparsingprotected 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(String code, String message)voidsendResponse(Response response)protected intstartParsingRequestBody(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
-
FIN
protected static final Request FIN
-
server
protected final HttpServer server
-
pipeline
protected final 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 IOException- Overrides:
processReadin classSession- Throws:
IOException
-
handleSocketClosed
protected void handleSocketClosed()
-
getMaxRequestBodyLength
protected int getMaxRequestBodyLength()
-
startParsingRequestBody
protected int startParsingRequestBody(String contentLengthHeader, byte[] buffer, int offset, int remaining) throws IOException, HttpException
- Throws:
IOExceptionHttpException
-
handleParsedRequest
protected void handleParsedRequest() throws IOException- Throws:
IOException
-
processHttpBuffer
protected int processHttpBuffer(byte[] buffer, int length) throws IOException, HttpException- Throws:
IOExceptionHttpException
-
parseRequest
protected Request parseRequest(byte[] buffer, int start, int length) throws HttpException
- Throws:
HttpException
-
sendResponse
public void sendResponse(Response response) throws IOException
- Throws:
IOException
-
sendError
public void sendError(String code, String message) throws IOException
- Throws:
IOException
-
writeResponse
protected void writeResponse(Response response, boolean includeBody) throws IOException
- Throws:
IOException
-
-