Class HttpSender
- Direct Known Subclasses:
HttpSenderOverFCGI
,HttpSenderOverHTTP
,HttpSenderOverHTTP2
HttpSender abstracts the algorithm to send HTTP requests, so that subclasses only
implement the transport-specific code to send requests over the wire, implementing
sendHeaders(HttpExchange, ByteBuffer, boolean, Callback)
and
sendContent(HttpExchange, ByteBuffer, boolean, Callback)
.
HttpSender governs the request state machines, which is updated as the various
steps of sending a request are executed, see RequestState
.
At any point in time, a user thread may abort the request, which may (if the request
has not been completely sent yet) move the request state machine to RequestState#FAILURE
.
The request state machine guarantees that the request steps are executed (by I/O threads)
only if the request has not been failed already.
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
abort
(HttpExchange exchange, Throwable failure, Promise<Boolean> promise) protected boolean
beginToHeaders
(HttpExchange exchange) protected void
dispose()
protected boolean
expects100Continue
(Request request) protected HttpChannel
protected HttpExchange
protected boolean
headersToCommit
(HttpExchange exchange) boolean
isFailed()
void
proceed
(HttpExchange exchange, Runnable proceedAction, Throwable failure) protected boolean
queuedToBegin
(HttpExchange exchange) protected String
relativize
(String path) protected void
reset()
void
send
(HttpExchange exchange) protected abstract void
sendContent
(HttpExchange exchange, ByteBuffer contentBuffer, boolean lastContent, Callback callback) Implementations should send the given HTTP content over the wire.protected abstract void
sendHeaders
(HttpExchange exchange, ByteBuffer contentBuffer, boolean lastContent, Callback callback) Implementations should send the HTTP headers over the wire, possibly with some content, in a single write, and notify the givencallback
of the result of this operation.protected boolean
someToContent
(HttpExchange exchange, ByteBuffer content) protected boolean
someToSuccess
(HttpExchange exchange) toString()
-
Constructor Details
-
HttpSender
-
-
Method Details
-
getHttpChannel
-
getHttpExchange
-
isFailed
public boolean isFailed() -
send
-
expects100Continue
-
queuedToBegin
-
beginToHeaders
-
headersToCommit
-
someToContent
-
someToSuccess
-
sendHeaders
protected abstract void sendHeaders(HttpExchange exchange, ByteBuffer contentBuffer, boolean lastContent, Callback callback) Implementations should send the HTTP headers over the wire, possibly with some content, in a single write, and notify the given
callback
of the result of this operation.If there is more content to send, then
sendContent(HttpExchange, ByteBuffer, boolean, Callback)
will be invoked.- Parameters:
exchange
- the exchangecontentBuffer
- the content to sendlastContent
- whether the content is the last content to sendcallback
- the callback to notify
-
sendContent
protected abstract void sendContent(HttpExchange exchange, ByteBuffer contentBuffer, boolean lastContent, Callback callback) Implementations should send the given HTTP content over the wire.
- Parameters:
exchange
- the exchangecontentBuffer
- the content to sendlastContent
- whether the content is the last content to sendcallback
- the callback to notify
-
reset
protected void reset() -
dispose
protected void dispose() -
proceed
-
abort
-
relativize
-
toString
-