Package org.omegazero.http.h1
Class HTTP1RequestReceiver
java.lang.Object
org.omegazero.http.h1.HTTP1MessageReceiver
org.omegazero.http.h1.HTTP1RequestReceiver
A special
HTTP1MessageReceiver used for receiving HTTPRequests.- Since:
- 1.2.1
-
Field Summary
Fields inherited from class org.omegazero.http.h1.HTTP1MessageReceiver
DEFAULT_MAX_HEADER_SIZE, lHeaders -
Constructor Summary
ConstructorsConstructorDescriptionHTTP1RequestReceiver(boolean secure) Creates a newHTTP1RequestReceiverwith the default maximum message size.HTTP1RequestReceiver(int maxHeaderSize, boolean secure) Creates a newHTTP1RequestReceiver. -
Method Summary
Modifier and TypeMethodDescriptionget()Returns theHTTPMessageafter successfully receiving it (HTTP1MessageReceiver.receive(byte[], int)returns a non-negative integer).<T extends HTTPRequest>
Tget(HTTPRequestSupplier<T> supplier) Returns theHTTPRequestafter successfully receiving it.protected voidreceiveHeader(String key, String value) Called when a HTTP header is received.protected voidreceiveStartLine(String[] startLine) Called when a HTTP/1 start line is received.voidreset()Resets thisHTTP1MessageReceiverto allow receipt of additionalHTTPMessages.Methods inherited from class org.omegazero.http.h1.HTTP1MessageReceiver
getHeaderSize, getVersion, isStartLineReceived, msgInit, receive, receiveVersion
-
Constructor Details
-
HTTP1RequestReceiver
public HTTP1RequestReceiver(boolean secure) Creates a newHTTP1RequestReceiverwith the default maximum message size.- Parameters:
secure- Whether the data is being received over a secure channel. This determines whether the scheme attribute of requests will be set to http or https
-
HTTP1RequestReceiver
public HTTP1RequestReceiver(int maxHeaderSize, boolean secure) Creates a newHTTP1RequestReceiver.- Parameters:
maxHeaderSize- The maximum size in bytes of a single HTTP messagesecure- Whether the data is being received over a secure channel. This determines whether the scheme attribute of requests will be set to http or https
-
-
Method Details
-
receiveStartLine
Description copied from class:HTTP1MessageReceiverCalled when a HTTP/1 start line is received.- Specified by:
receiveStartLinein classHTTP1MessageReceiver- Parameters:
startLine- The start line components- Throws:
InvalidHTTPMessageException- If the start line is malformed
-
receiveHeader
Description copied from class:HTTP1MessageReceiverCalled when a HTTP header is received.- Overrides:
receiveHeaderin classHTTP1MessageReceiver- Parameters:
key- The header namevalue- The header value- Throws:
InvalidHTTPMessageException- If the header has an invalid value or otherwise invalid
-
get
Returns theHTTPMessageafter successfully receiving it (HTTP1MessageReceiver.receive(byte[], int)returns a non-negative integer).A call to this method should be followed by a call to
HTTP1MessageReceiver.reset()to allow the next HTTP message to be received.It is unspecified whether multiple calls to this method return the same
HTTPMessageinstance.- Specified by:
getin classHTTP1MessageReceiver- Returns:
- The
HTTPMessage - See Also:
-
get
Returns theHTTPRequestafter successfully receiving it. Seeget().- Type Parameters:
T- The specificHTTPRequesttype this method creates- Parameters:
supplier- AHTTPRequestSupplierfor creating theHTTPRequest- Returns:
- The
HTTPRequest - Throws:
IllegalStateException- If noHTTPMessagewas received yet
-
reset
public void reset()Description copied from class:HTTP1MessageReceiverResets thisHTTP1MessageReceiverto allow receipt of additionalHTTPMessages.- Overrides:
resetin classHTTP1MessageReceiver
-