Class AbstractConnectionHandler
- java.lang.Object
-
- com.github.toolarium.network.server.handler.impl.AbstractConnectionHandler
-
- All Implemented Interfaces:
IHttpConnectionHandler,java.lang.Runnable
- Direct Known Subclasses:
HttpConnectionHandlerImpl
public abstract class AbstractConnectionHandler extends java.lang.Object implements IHttpConnectionHandler
Implements the abstract base class forIHttpConnectionHandler.
-
-
Constructor Summary
Constructors Constructor Description AbstractConnectionHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected IHttpResponsecreateHttpResponse(IHttpRequest request)create a http responseprotected java.lang.StringgetBodyAsByteArray(IHttpResponse response)Get the body as byte arrayprotected java.lang.StringgetStatusLineAndHeaders(IHttpResponse response)Get the status line and headersprotected java.lang.StringreadInBody(java.io.BufferedReader reader, int contentLength)Read in the bodyprotected java.lang.StringreadInFirstLine(java.io.BufferedReader br, HttpRequest request)Read the first line-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.github.toolarium.network.server.handler.IHttpConnectionHandler
init
-
-
-
-
Method Detail
-
readInFirstLine
protected java.lang.String readInFirstLine(java.io.BufferedReader br, HttpRequest request) throws java.io.IOExceptionRead the first line- Parameters:
br- the readerrequest- the request- Returns:
- the first line
- Throws:
java.io.IOException- In case of an I/O error
-
readInBody
protected java.lang.String readInBody(java.io.BufferedReader reader, int contentLength) throws java.io.IOExceptionRead in the body- Parameters:
reader- the readercontentLength- the content length- Returns:
- the body
- Throws:
java.io.IOException- In case of an I/O error
-
createHttpResponse
protected IHttpResponse createHttpResponse(IHttpRequest request)
create a http response- Parameters:
request- the reuqest- Returns:
- the response object
-
getStatusLineAndHeaders
protected java.lang.String getStatusLineAndHeaders(IHttpResponse response)
Get the status line and headers- Parameters:
response- the http response- Returns:
- the status line and headers
-
getBodyAsByteArray
protected java.lang.String getBodyAsByteArray(IHttpResponse response)
Get the body as byte array- Parameters:
response- the http response- Returns:
- the body as byte array
-
-