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.
HttpReceiver
| Modifier and Type | Class and Description |
|---|---|
| private class | |
| private static enum | HttpSender.
The request states |
| Modifier and Type | Field and Description |
|---|---|
| private final HttpChannel | |
| private final HttpSender. | |
| private final AtomicReference | |
| private static final Logger | |
| private final AtomicReference |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| private void | |
| private boolean | |
| protected boolean | |
| protected void | |
| private void | |
| protected boolean | |
| private void | |
| private boolean | |
| protected HttpChannel | |
| protected HttpExchange | |
| protected boolean | |
| private void | |
| public boolean | |
| public void | |
| protected boolean | |
| protected String | |
| protected void | |
| public void | |
| protected abstract void | sendContent(HttpExchange
the exchange exchange, ByteBuffer the content to send contentBuffer, boolean whether the content is the last content to send lastContent, Callback the callback to notify callback)Implementations should send the given HTTP content over the wire. |
| protected abstract void | sendHeaders(HttpExchange
the exchange exchange, ByteBuffer the content to send contentBuffer, boolean whether the content is the last content to send lastContent, Callback the callback to notify callback)Implementations should send the HTTP headers over the wire, possibly with some content,
in a single write, and notify the given |
| protected boolean | |
| protected boolean | |
| private void | |
| public String | |
| private boolean |
| channel | back to summary |
|---|---|
| private final HttpChannel channel | |
| contentSender | back to summary |
|---|---|
| private final HttpSender. | |
| failure | back to summary |
|---|---|
| private final AtomicReference<Throwable> failure | |
| LOG | back to summary |
|---|---|
| private static final Logger LOG | |
| requestState | back to summary |
|---|---|
| private final AtomicReference<HttpSender. | |
| HttpSender | back to summary |
|---|---|
| protected HttpSender(HttpChannel channel) | |
| abort | back to summary |
|---|---|
| public void abort(HttpExchange exchange, Throwable failure, Promise<Boolean> promise) | |
| abortRequest | back to summary |
|---|---|
| private void abortRequest(HttpExchange exchange) | |
| anyToFailure | back to summary |
|---|---|
| private boolean anyToFailure(Throwable failure) | |
| beginToHeaders | back to summary |
|---|---|
| protected boolean beginToHeaders(HttpExchange exchange) | |
| dispose | back to summary |
|---|---|
| protected void dispose() | |
| executeAbort | back to summary |
|---|---|
| private void executeAbort(HttpExchange exchange, Throwable failure) | |
| expects100Continue | back to summary |
|---|---|
| protected boolean expects100Continue(Request request) | |
| externalAbort | back to summary |
|---|---|
| private void externalAbort(Throwable failure, Promise<Boolean> promise) | |
| failRequest | back to summary |
|---|---|
| private boolean failRequest(Throwable failure) | |
| getHttpChannel | back to summary |
|---|---|
| protected HttpChannel getHttpChannel() | |
| getHttpExchange | back to summary |
|---|---|
| protected HttpExchange getHttpExchange() | |
| headersToCommit | back to summary |
|---|---|
| protected boolean headersToCommit(HttpExchange exchange) | |
| internalAbort | back to summary |
|---|---|
| private void internalAbort(HttpExchange exchange, Throwable failure) | |
| isFailed | back to summary |
|---|---|
| public boolean isFailed() | |
| proceed | back to summary |
|---|---|
| public void proceed(HttpExchange exchange, Throwable failure) | |
| queuedToBegin | back to summary |
|---|---|
| protected boolean queuedToBegin(HttpExchange exchange) | |
| relativize | back to summary |
|---|---|
| protected String relativize(String path) | |
| reset | back to summary |
|---|---|
| protected void reset() | |
| send | back to summary |
|---|---|
| public void send(HttpExchange exchange) | |
| sendContent | back to summary |
|---|---|
| protected abstract void sendContent(HttpExchange exchange, ByteBuffer contentBuffer, boolean lastContent, Callback callback) Implementations should send the given HTTP content over the wire.
| |
| sendHeaders | back to summary |
|---|---|
| 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 If there is more content to send, then
| |
| someToContent | back to summary |
|---|---|
| protected boolean someToContent(HttpExchange exchange, ByteBuffer content) | |
| someToSuccess | back to summary |
|---|---|
| protected boolean someToSuccess(HttpExchange exchange) | |
| terminateRequest | back to summary |
|---|---|
| private void terminateRequest(HttpExchange exchange, Throwable failure, Result result) | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |
| updateRequestState | back to summary |
|---|---|
| private boolean updateRequestState(HttpSender. | |
| Modifier and Type | Field and Description |
|---|---|
| private Promise | |
| private Content. | |
| private boolean | |
| private boolean | |
| private ByteBuffer | |
| private HttpExchange | |
| private boolean | |
| private boolean |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public Invocable. | |
| protected void | onCompleteFailure(Throwable
the throwable to indicate cause of failure x)Overrides org. Invoked when the overall task has completed with a failure. |
| protected IteratingCallback. | process()
Implements abstract org. Method called by |
| public boolean | |
| public void | succeeded()
Overrides org. Overrides default org. Method to invoke when the asynchronous sub-task succeeds. |
| abort | back to summary |
|---|---|
| private Promise<Boolean> abort | |
| chunk | back to summary |
|---|---|
| private Content. | |
| committed | back to summary |
|---|---|
| private boolean committed | |
| complete | back to summary |
|---|---|
| private boolean complete | |
| contentBuffer | back to summary |
|---|---|
| private ByteBuffer contentBuffer | |
| exchange | back to summary |
|---|---|
| private HttpExchange exchange | |
| expect100 | back to summary |
|---|---|
| private boolean expect100 | |
| success | back to summary |
|---|---|
| private boolean success | |
| ContentSender | back to summary |
|---|---|
| private ContentSender() | |
| getInvocationType | back to summary |
|---|---|
| public Invocable. Overrides default org.
| |
| onCompleteFailure | back to summary |
|---|---|
| protected void onCompleteFailure(Throwable x) Overrides org. Doc from org. Invoked when the overall task has completed with a failure. | |
| process | back to summary |
|---|---|
| protected IteratingCallback. Implements abstract org. Doc from org. Method called by Implementations must initiate the asynchronous execution of the sub-task (if any) and return an appropriate action:
| |
| reset | back to summary |
|---|---|
| public boolean reset() Overrides org. Doc from org. Resets this callback.
A callback can only be reset to the idle state from the
| |
| succeeded | back to summary |
|---|---|
| public void succeeded() Overrides org. Overrides default org. Doc from org. Method to invoke when the asynchronous sub-task succeeds.
Subclasses that override this method must always remember
to call
| |
HttpSender goes through when sending a request.
| Modifier and Type | Field and Description |
|---|---|
| public static final HttpSender. | BEGIN
The request has been dequeued |
| public static final HttpSender. | COMMIT
The request headers (and possibly some content) have been sent |
| public static final HttpSender. | CONTENT
The request content is being sent |
| public static final HttpSender. | FAILURE
The request is failed |
| public static final HttpSender. | HEADERS
The request headers (and possibly some content) is about to be sent |
| public static final HttpSender. | QUEUED
The request is queued, the initial state |
| public static final HttpSender. | TRANSIENT
One of the state transition methods is being executed. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static HttpSender. | |
| public static HttpSender. |
| BEGIN | back to summary |
|---|---|
| public static final HttpSender. The request has been dequeued | |
| COMMIT | back to summary |
|---|---|
| public static final HttpSender. The request headers (and possibly some content) have been sent | |
| CONTENT | back to summary |
|---|---|
| public static final HttpSender. The request content is being sent | |
| FAILURE | back to summary |
|---|---|
| public static final HttpSender. The request is failed | |
| HEADERS | back to summary |
|---|---|
| public static final HttpSender. The request headers (and possibly some content) is about to be sent | |
| QUEUED | back to summary |
|---|---|
| public static final HttpSender. The request is queued, the initial state | |
| TRANSIENT | back to summary |
|---|---|
| public static final HttpSender. One of the state transition methods is being executed. | |
| RequestState | back to summary |
|---|---|
| private RequestState() | |
| valueOf | back to summary |
|---|---|
| public static HttpSender. | |
| values | back to summary |
|---|---|
| public static HttpSender. | |