- java.lang.Object
-
- org.eclipse.jetty.client.HttpSender
-
- Direct Known Subclasses:
HttpSenderOverHTTP
public abstract class HttpSender extends java.lang.ObjectHttpSender 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)andsendContent(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 toRequestState#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:
HttpReceiver
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedHttpSender(HttpChannel channel)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleanabort(HttpExchange exchange, java.lang.Throwable failure)protected booleanbeginToHeaders(HttpExchange exchange)protected voiddispose()protected booleanexpects100Continue(Request request)protected HttpChannelgetHttpChannel()protected HttpExchangegetHttpExchange()protected booleanheadersToCommit(HttpExchange exchange)booleanisFailed()voidproceed(HttpExchange exchange, java.lang.Throwable failure)protected booleanqueuedToBegin(HttpExchange exchange)protected java.lang.Stringrelativize(java.lang.String path)protected voidreset()voidsend(HttpExchange exchange)protected abstract voidsendContent(HttpExchange exchange, java.nio.ByteBuffer contentBuffer, boolean lastContent, org.eclipse.jetty.util.Callback callback)Implementations should send the given HTTP content over the wire.protected abstract voidsendHeaders(HttpExchange exchange, java.nio.ByteBuffer contentBuffer, boolean lastContent, org.eclipse.jetty.util.Callback callback)Implementations should send the HTTP headers over the wire, possibly with some content, in a single write, and notify the givencallbackof the result of this operation.protected booleansomeToContent(HttpExchange exchange, java.nio.ByteBuffer content)protected booleansomeToSuccess(HttpExchange exchange)java.lang.StringtoString()
-
-
-
Constructor Detail
-
HttpSender
protected HttpSender(HttpChannel channel)
-
-
Method Detail
-
getHttpChannel
protected HttpChannel getHttpChannel()
-
getHttpExchange
protected HttpExchange getHttpExchange()
-
isFailed
public boolean isFailed()
-
send
public void send(HttpExchange exchange)
-
expects100Continue
protected boolean expects100Continue(Request request)
-
queuedToBegin
protected boolean queuedToBegin(HttpExchange exchange)
-
beginToHeaders
protected boolean beginToHeaders(HttpExchange exchange)
-
headersToCommit
protected boolean headersToCommit(HttpExchange exchange)
-
someToContent
protected boolean someToContent(HttpExchange exchange, java.nio.ByteBuffer content)
-
someToSuccess
protected boolean someToSuccess(HttpExchange exchange)
-
sendHeaders
protected abstract void sendHeaders(HttpExchange exchange, java.nio.ByteBuffer contentBuffer, boolean lastContent, org.eclipse.jetty.util.Callback callback)
Implementations should send the HTTP headers over the wire, possibly with some content, in a single write, and notify the given
callbackof 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, java.nio.ByteBuffer contentBuffer, boolean lastContent, org.eclipse.jetty.util.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
public void proceed(HttpExchange exchange, java.lang.Throwable failure)
-
abort
public boolean abort(HttpExchange exchange, java.lang.Throwable failure)
-
relativize
protected java.lang.String relativize(java.lang.String path)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-