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 HTTPRequest
s.- 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 newHTTP1RequestReceiver
with the default maximum message size.HTTP1RequestReceiver
(int maxHeaderSize, boolean secure) Creates a newHTTP1RequestReceiver
. -
Method Summary
Modifier and TypeMethodDescriptionget()
Returns theHTTPMessage
after successfully receiving it (HTTP1MessageReceiver.receive(byte[], int)
returns a non-negative integer).<T extends HTTPRequest>
Tget
(HTTPRequestSupplier<T> supplier) Returns theHTTPRequest
after successfully receiving it.protected void
receiveHeader
(String key, String value) Called when a HTTP header is received.protected void
receiveStartLine
(String[] startLine) Called when a HTTP/1 start line is received.void
reset()
Resets thisHTTP1MessageReceiver
to allow receipt of additionalHTTPMessage
s.Methods inherited from class org.omegazero.http.h1.HTTP1MessageReceiver
getHeaderSize, getVersion, isStartLineReceived, msgInit, receive, receiveVersion
-
Constructor Details
-
HTTP1RequestReceiver
public HTTP1RequestReceiver(boolean secure) Creates a newHTTP1RequestReceiver
with 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:HTTP1MessageReceiver
Called when a HTTP/1 start line is received.- Specified by:
receiveStartLine
in classHTTP1MessageReceiver
- Parameters:
startLine
- The start line components- Throws:
InvalidHTTPMessageException
- If the start line is malformed
-
receiveHeader
Description copied from class:HTTP1MessageReceiver
Called when a HTTP header is received.- Overrides:
receiveHeader
in classHTTP1MessageReceiver
- Parameters:
key
- The header namevalue
- The header value- Throws:
InvalidHTTPMessageException
- If the header has an invalid value or otherwise invalid
-
get
Returns theHTTPMessage
after 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
HTTPMessage
instance.- Specified by:
get
in classHTTP1MessageReceiver
- Returns:
- The
HTTPMessage
- See Also:
-
get
Returns theHTTPRequest
after successfully receiving it. Seeget()
.- Type Parameters:
T
- The specificHTTPRequest
type this method creates- Parameters:
supplier
- AHTTPRequestSupplier
for creating theHTTPRequest
- Returns:
- The
HTTPRequest
- Throws:
IllegalStateException
- If noHTTPMessage
was received yet
-
reset
public void reset()Description copied from class:HTTP1MessageReceiver
Resets thisHTTP1MessageReceiver
to allow receipt of additionalHTTPMessage
s.- Overrides:
reset
in classHTTP1MessageReceiver
-