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 class
Nested classes/interfaces inherited from class reactor.netty.channel.ChannelOperations
ChannelOperations.OnSetup
Nested classes/interfaces inherited from interface reactor.core.Disposable
Disposable.Composite, Disposable.Swap
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
HttpOperations
(Connection connection, ConnectionObserver listener, HttpMessageLogFactory httpMessageLogFactory) protected
HttpOperations
(HttpOperations<INBOUND, OUTBOUND> replaced) -
Method Summary
Modifier and TypeMethodDescriptionaddHandler
(String name, ChannelHandler handler) Add aChannelHandler
withConnection.addHandlerFirst(io.netty.channel.ChannelHandler)
if of type ofChannelOutboundHandler
otherwise withConnection.addHandlerLast(io.netty.channel.ChannelHandler)
.protected abstract void
protected String
Transforms the object to a string for debug logs.protected abstract void
protected final boolean
Has Body been sent.final boolean
Has headers been sent.protected HttpMessageLogFactory
protected final String
protected abstract boolean
boolean
Returns true if websocket connection (upgraded).protected final boolean
Mark the body sent.protected final boolean
markSentHeaderAndBody
(Object... objectsToRelease) Mark the headers and body sent.protected final boolean
markSentHeaders
(Object... objectsToRelease) Mark the headers sent.protected abstract HttpMessage
newFullBodyMessage
(ByteBuf body) protected abstract void
protected abstract HttpMessage
Outbound Netty HttpMessage.protected HttpMessage
prepareHttpMessage
(ByteBuf buffer) Return a unique id for the request.static String
resolvePath
(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 NettyOutbound
Sends content from the givenPath
usingFileChannel.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 aMono
of 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, wrapInboundError
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface reactor.netty.Connection
addHandler, addHandlerFirst, addHandlerFirst, addHandlerLast, addHandlerLast, bind, markPersistent, onReadIdle, onWriteIdle, rebind, removeHandler, replaceHandler
Methods inherited from interface reactor.netty.DisposableChannel
address, disposeNow, disposeNow
Methods inherited from interface reactor.netty.http.HttpInfos
cookies, fullPath, isKeepAlive, method, path, uri, version
Methods 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, 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:HttpInfos
Returns true if websocket connection (upgraded).- Specified by:
isWebsocket
in interfaceHttpInfos
- Returns:
- true if websocket connection
-
requestId
Description copied from interface:HttpInfos
Return 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:NettyOutbound
Sends data to the peer, listens for any error on write and closes on terminal signal (complete|error).A new
NettyOutbound
type (or the same) for typed send sequences.Note: Nesting any send* method is not supported.
- Specified by:
send
in interfaceNettyOutbound
- Parameters:
source
- the dataStream publishing OUT items to write on this channel- Returns:
- A new
NettyOutbound
to 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:NettyOutbound
Sends 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:
sendObject
in interfaceNettyOutbound
- Overrides:
sendObject
in classChannelOperations<INBOUND extends NettyInbound,
OUTBOUND extends NettyOutbound> - Parameters:
message
- the object to publish- Returns:
- A
Mono
to signal successful sequence write (e.g. after "flush") or any error during write
-
then
Description copied from interface:NettyOutbound
Obtains aMono
of pending outbound(s) write completion.- Specified by:
then
in interfaceNettyOutbound
- Returns:
- a
Mono
of pending outbound(s) write completion
-
asDebugLogMessage
Description copied from class:ChannelOperations
Transforms the object to a string for debug logs.- Overrides:
asDebugLogMessage
in 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:NettyOutbound
Sends content from the givenPath
usingFileChannel.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:
sendFile
in 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:
toString
in classChannelOperations<INBOUND extends NettyInbound,
OUTBOUND extends NettyOutbound>
-
addHandler
Description copied from interface:Connection
Add aChannelHandler
withConnection.addHandlerFirst(io.netty.channel.ChannelHandler)
if of type ofChannelOutboundHandler
otherwise 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:
addHandler
in 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:
initShortId
in 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
-