Class HttpOperations<INBOUND extends NettyInbound,OUTBOUND extends NettyOutbound>
- All Implemented Interfaces:
Publisher<Void>,Subscriber<Void>,CoreSubscriber<Void>,Disposable,ChannelOperationsId,Connection,DisposableChannel,HttpInfos,NettyInbound,NettyOutbound
ChannelOperations with state management for status and headers
(first HTTP response packet).- Author:
- Stephane Maldini
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static final classNested classes/interfaces inherited from class reactor.netty.channel.ChannelOperations
ChannelOperations.OnSetupNested classes/interfaces inherited from interface reactor.core.Disposable
Disposable.Composite, Disposable.Swap -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedHttpOperations(Connection connection, ConnectionObserver listener, HttpOperations<INBOUND, OUTBOUND> replaced) protectedHttpOperations(Connection connection, ConnectionObserver listener, HttpMessageLogFactory httpMessageLogFactory) protectedHttpOperations(HttpOperations<INBOUND, OUTBOUND> replaced) -
Method Summary
Modifier and TypeMethodDescriptionaddHandler(String name, ChannelHandler handler) Add aChannelHandlerwithConnection.addHandlerFirst(io.netty.channel.ChannelHandler)if of type ofChannelOutboundHandlerotherwise withConnection.addHandlerLast(io.netty.channel.ChannelHandler).protected abstract voidprotected StringTransforms the object to a string for debug logs.protected abstract voidprotected final booleanHas Body been sent.final booleanHas headers been sent.protected HttpMessageLogFactoryprotected final Stringprotected abstract booleanbooleanReturns true if websocket connection (upgraded).protected final booleanMark the body sent.protected final booleanmarkSentHeaderAndBody(Object... objectsToRelease) Mark the headers and body sent.protected final booleanmarkSentHeaders(Object... objectsToRelease) Mark the headers sent.protected abstract HttpMessagenewFullBodyMessage(ByteBuf body) protected abstract voidprotected abstract HttpMessageOutbound Netty HttpMessage.protected HttpMessageprepareHttpMessage(ByteBuf buffer) Return a unique id for the request.static StringresolvePath(String uri) Returns the decoded path portion from the provideduri.Sends data to the peer, listens for any error on write and closes on terminal signal (complete|error).final NettyOutboundSends content from the givenPathusingFileChannel.transferTo(long, long, WritableByteChannel)support, if the system supports it, the path resolves to a local file systemFile, compression and SSL/TLS is not enabled, then transfer will use zero-byte copy to the peer., otherwise chunked read/write will be used.sendObject(Object message) Sends data to the peer, listens for any error on write and closes on terminal signal (complete|error).then()Obtains aMonoof pending outbound(s) write completion.toString()Methods inherited from class reactor.netty.channel.ChannelOperations
addMetricsHandler, addReactiveBridge, afterInboundComplete, alloc, as, asLongText, asShortText, channel, connection, currentContext, discard, discardWhenNoReceiver, dispose, disposeSubscriber, formatName, get, inbound, isDisposed, isInboundCancelled, isInboundComplete, isInboundDisposed, isPersistent, isSubscriptionDisposed, listener, onComplete, onDispose, onDispose, onError, onInboundCancel, onInboundClose, onInboundComplete, onInboundError, onInboundNext, onNext, onOutboundComplete, onOutboundError, onSubscribe, onTerminate, onUnprocessedOutboundError, onWritabilityChanged, outbound, receive, receiveObject, send, sendObject, sendUsing, terminate, withConnection, wrapInboundErrorMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface reactor.netty.Connection
addHandler, addHandlerFirst, addHandlerFirst, addHandlerLast, addHandlerLast, bind, markPersistent, onReadIdle, onWriteIdle, rebind, removeHandler, replaceHandlerMethods inherited from interface reactor.netty.DisposableChannel
address, disposeNow, disposeNowMethods inherited from interface reactor.netty.http.HttpInfos
cookies, fullPath, isKeepAlive, method, path, uri, versionMethods inherited from interface reactor.netty.NettyOutbound
neverComplete, sendByteArray, sendFile, sendFileChunked, sendGroups, sendObject, sendString, sendString, subscribe, then, then
-
Constructor Details
-
HttpOperations
-
HttpOperations
protected HttpOperations(Connection connection, ConnectionObserver listener, HttpOperations<INBOUND, OUTBOUND> replaced) -
HttpOperations
protected HttpOperations(Connection connection, ConnectionObserver listener, HttpMessageLogFactory httpMessageLogFactory)
-
-
Method Details
-
hasSentHeaders
public final boolean hasSentHeaders()Has headers been sent.- Returns:
- true if headers have been sent
-
isWebsocket
public boolean isWebsocket()Description copied from interface:HttpInfosReturns true if websocket connection (upgraded).- Specified by:
isWebsocketin interfaceHttpInfos- Returns:
- true if websocket connection
-
requestId
Description copied from interface:HttpInfosReturn a unique id for the request. The id is a combination of the id of the underlying connection and the serial number of the request received on that connection.Format of the id:
<CONNECTION_ID>-<REQUEST_NUMBER>Example:
<CONNECTION_ID>: 329c6ffd <REQUEST_NUMBER>: 5 Result: 329c6ffd-5 -
send
Description copied from interface:NettyOutboundSends data to the peer, listens for any error on write and closes on terminal signal (complete|error).A new
NettyOutboundtype (or the same) for typed send sequences.Note: Nesting any send* method is not supported.
- Specified by:
sendin interfaceNettyOutbound- Parameters:
source- the dataStream publishing OUT items to write on this channel- Returns:
- A new
NettyOutboundto append further send. It will emit a complete signal successful sequence write (e.g. after "flush") or any error during write.
-
sendObject
Description copied from interface:NettyOutboundSends data to the peer, listens for any error on write and closes on terminal signal (complete|error).Note: Nesting any send* method is not supported.
- Specified by:
sendObjectin interfaceNettyOutbound- Overrides:
sendObjectin classChannelOperations<INBOUND extends NettyInbound,OUTBOUND extends NettyOutbound> - Parameters:
message- the object to publish- Returns:
- A
Monoto signal successful sequence write (e.g. after "flush") or any error during write
-
then
Description copied from interface:NettyOutboundObtains aMonoof pending outbound(s) write completion.- Specified by:
thenin interfaceNettyOutbound- Returns:
- a
Monoof pending outbound(s) write completion
-
asDebugLogMessage
Description copied from class:ChannelOperationsTransforms the object to a string for debug logs.- Overrides:
asDebugLogMessagein classChannelOperations<INBOUND extends NettyInbound,OUTBOUND extends NettyOutbound> - Parameters:
o- the object to be transformed- Returns:
- the string to be logged
-
httpMessageLogFactory
-
beforeMarkSentHeaders
protected abstract void beforeMarkSentHeaders() -
afterMarkSentHeaders
protected abstract void afterMarkSentHeaders() -
isContentAlwaysEmpty
protected abstract boolean isContentAlwaysEmpty() -
onHeadersSent
protected abstract void onHeadersSent() -
newFullBodyMessage
-
sendFile
Description copied from interface:NettyOutboundSends content from the givenPathusingFileChannel.transferTo(long, long, WritableByteChannel)support, if the system supports it, the path resolves to a local file systemFile, compression and SSL/TLS is not enabled, then transfer will use zero-byte copy to the peer., otherwise chunked read/write will be used.It will listens for any error on write and closes on terminal signal (complete|error). If more than one publisher is attached (multiple calls to send()) completion occurs after all publishers complete.
Note: Nesting any send* method is not supported.
- Specified by:
sendFilein interfaceNettyOutbound- Parameters:
file- the file Pathposition- where to startcount- how much to transfer- Returns:
- A Publisher to signal successful sequence write (e.g. after "flush") or any error during write
-
toString
- Overrides:
toStringin classChannelOperations<INBOUND extends NettyInbound,OUTBOUND extends NettyOutbound>
-
addHandler
Description copied from interface:ConnectionAdd aChannelHandlerwithConnection.addHandlerFirst(io.netty.channel.ChannelHandler)if of type ofChannelOutboundHandlerotherwise withConnection.addHandlerLast(io.netty.channel.ChannelHandler). Implementation may add more auto handling in particular HTTP based context will prepend an HttpContent body extractor.[ [reactor codecs], [<- user FIRST HANDLERS added here, user LAST HANDLERS added here ->], [reactor handlers] ]If effectively added, the handler will be safely removed when the channel is made inactive (pool release). As the Connection object is available once the channel is in active state, events prior this state will not be available (i.e.
channelRegistered,initChannel,channelActive, etc.)- Specified by:
addHandlerin interfaceConnection- Parameters:
name- handler namehandler- handler instance- Returns:
- this Connection
-
markSentHeaders
Mark the headers sent.- Returns:
- true if marked for the first time
-
markSentBody
protected final boolean markSentBody()Mark the body sent.- Returns:
- true if marked for the first time
-
hasSentBody
protected final boolean hasSentBody()Has Body been sent.- Returns:
- true if body has been sent
- Since:
- 1.0.37
-
markSentHeaderAndBody
Mark the headers and body sent.- Returns:
- true if marked for the first time
-
initShortId
- Overrides:
initShortIdin classChannelOperations<INBOUND extends NettyInbound,OUTBOUND extends NettyOutbound>
-
resolvePath
Returns the decoded path portion from the provideduri.- Parameters:
uri- an HTTP URL that may contain a path with query/fragment- Returns:
- the decoded path portion from the provided
uri
-
outboundHttpMessage
Outbound Netty HttpMessage.- Returns:
- Outbound Netty HttpMessage
-
prepareHttpMessage
-