Top Description Inners Fields Constructors Methods
reactor.netty.http

public abstract Class HttpOperations<INBOUND extends reactor.netty.NettyInbound, OUTBOUND extends reactor.netty.NettyOutbound>

extends ChannelOperations<INBOUND extends NettyInbound, OUTBOUND extends NettyOutbound>
implements HttpInfos
Class Inheritance
All Implemented Interfaces
reactor.netty.http.HttpInfos
Known Direct Subclasses
reactor.netty.http.client.HttpClientOperations, reactor.netty.http.server.HttpServerOperations
Imports
java.net.URI, java.nio.file.Path, java.util.Objects, java.util.concurrent.Callable, java.util.concurrent.atomic.AtomicIntegerFieldUpdater, .AtomicLong, java.util.function.BiFunction, .Consumer, .Predicate, java.util.regex.Pattern, io.netty.buffer.ByteBuf, .ByteBufAllocator, .ByteBufHolder, .Unpooled, io.netty.channel.ChannelHandler, .ChannelInboundHandler, .CombinedChannelDuplexHandler, io.netty.handler.codec.ByteToMessageCodec, .ByteToMessageDecoder, io.netty.handler.codec.http.FullHttpMessage, .HttpHeaderNames, .HttpMessage, .HttpObject, .HttpUtil, .LastHttpContent, io.netty.util.ReferenceCountUtil, org.reactivestreams.Publisher, reactor.core.publisher.Mono, reactor.netty.Connection, .ConnectionObserver, .FutureMono, .NettyInbound, .NettyOutbound, .NettyPipeline, .ReactorNetty, reactor.netty.channel.AbortedException, .ChannelOperations, reactor.netty.http.logging.HttpMessageArgProviderFactory, .HttpMessageLogFactory, reactor.util.Logger, .Loggers, reactor.util.annotation.Nullable

An HTTP ready ChannelOperations with state management for status and headers (first HTTP response packet).
Author
Stephane Maldini

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static class

Field Summary

Modifier and TypeField and Description
pack-priv static final int
pack-priv static final int
pack-priv static final ChannelInboundHandler
pack-priv static final AtomicIntegerFieldUpdater<HttpOperations<INBOUND extends NettyInbound, OUTBOUND extends NettyOutbound>>
pack-priv final HttpMessageLogFactory
pack-priv static final Logger
pack-priv static final int
pack-priv static final Pattern
pack-priv volatile int

Constructor Summary

AccessConstructor and Description
protected
HttpOperations(HttpOperations<INBOUND, OUTBOUND> replaced)

protected
HttpOperations(Connection connection, ConnectionObserver listener, HttpMessageLogFactory httpMessageLogFactory)

Method Summary

Modifier and TypeMethod and Description
public HttpOperations<INBOUND, OUTBOUND>
addHandler(String
handler name
name
,
ChannelHandler
handler instance
handler
)

Overrides default reactor.netty.Connection.addHandler.

Add a ChannelHandler with addHandlerFirst if of type of io.netty.channel.ChannelOutboundHandler otherwise with addHandlerLast.
protected abstract void
protected String
asDebugLogMessage(Object
the object to be transformed
o
)

Overrides reactor.netty.channel.ChannelOperations.asDebugLogMessage.

Transforms the object to a string for debug logs.
pack-priv static void
protected abstract void
protected final boolean

Returns:

true if body has been sent
hasSentBody
()

Has Body been sent.

public final boolean

Returns:

true if headers have been sent
hasSentHeaders
()

Has headers been sent.

protected HttpMessageLogFactory
protected final String
protected abstract boolean
public boolean
isWebsocket()

Implements reactor.netty.http.HttpInfos.isWebsocket.

Returns true if websocket connection (upgraded).
protected final boolean

Returns:

true if marked for the first time
markSentBody
()

Mark the body sent.

protected final boolean

Returns:

true if marked for the first time
markSentHeaderAndBody
(Object... objectsToRelease)

Mark the headers and body sent.

protected final boolean

Returns:

true if marked for the first time
markSentHeaders
(Object... objectsToRelease)

Mark the headers sent.

protected abstract HttpMessage
protected abstract void
protected abstract HttpMessage

Returns:

Outbound Netty HttpMessage
outboundHttpMessage
()

Outbound Netty HttpMessage.

pack-priv HttpMessage
public String
requestId()

Implements reactor.netty.http.HttpInfos.requestId.

Return a unique id for the request.
public static String

Returns:

the decoded path portion from the provided uri
resolvePath
(String
an HTTP URL that may contain a path with query/fragment
uri
)

Returns the decoded path portion from the provided uri.

public NettyOutbound
send(Publisher<? extends ByteBuf>
the dataStream publishing OUT items to write on this channel
source
)

Overrides default reactor.netty.NettyOutbound.send.

Sends data to the peer, listens for any error on write and closes on terminal signal (complete|error).
public final NettyOutbound
sendFile(Path
the file Path
file
,
long
where to start
position
,
long
how much to transfer
count
)

Overrides default reactor.netty.NettyOutbound.sendFile.

Sends content from the given Path using java.nio.channels.FileChannel#transferTo(long, long, WritableByteChannel) support, if the system supports it, the path resolves to a local file system File, compression and SSL/TLS is not enabled, then transfer will use zero-byte copy to the peer., otherwise chunked read/write will be used.
public NettyOutbound
sendObject(Object
the object to publish
message
)

Overrides reactor.netty.channel.ChannelOperations.sendObject.

Implements reactor.netty.NettyOutbound.sendObject.

Sends data to the peer, listens for any error on write and closes on terminal signal (complete|error).
public Mono<Void>
then()

Overrides default reactor.netty.NettyOutbound.then.

Obtains a Mono of pending outbound(s) write completion.
public String
toString()

Overrides reactor.netty.channel.ChannelOperations.toString.

Returns a string representation of the object.
Inherited from reactor.netty.channel.ChannelOperations:
addMetricsHandleraddReactiveBridgeafterInboundCompleteallocasasLongTextasShortTextchannelconnectioncurrentContextdiscarddiscardWhenNoReceiverdisposedisposeSubscriberformatNamegetinboundisDisposedisInboundCancelledisInboundCompleteisInboundDisposedisPersistentisSubscriptionDisposedlisteneronCompleteonDisposeonDisposeonErroronInboundCancelonInboundCloseonInboundCompleteonInboundErroronInboundNextonNextonOutboundCompleteonOutboundErroronSubscribeonTerminateonUnprocessedOutboundErroronWritabilityChangedoutboundreceivereceiveObjectsendsendObjectsendUsingterminatewithConnectionwrapInboundError

Field Detail

BODY_SENTback to summary
pack-priv static final int BODY_SENT
HEADERS_SENTback to summary
pack-priv static final int HEADERS_SENT
HTTP_EXTRACTORback to summary
pack-priv static final ChannelInboundHandler HTTP_EXTRACTOR
HTTP_STATEback to summary
pack-priv static final AtomicIntegerFieldUpdater<HttpOperations<INBOUND extends NettyInbound, OUTBOUND extends NettyOutbound>> HTTP_STATE
Annotations
@SuppressWarnings:rawtypes
httpMessageLogFactoryback to summary
pack-priv final HttpMessageLogFactory httpMessageLogFactory
logback to summary
pack-priv static final Logger log

Hides reactor.netty.channel.ChannelOperations.log.

READYback to summary
pack-priv static final int READY
SCHEME_PATTERNback to summary
pack-priv static final Pattern SCHEME_PATTERN
statusAndHeadersSentback to summary
pack-priv volatile int statusAndHeadersSent

Constructor Detail

HttpOperationsback to summary
protected HttpOperations(HttpOperations<INBOUND, OUTBOUND> replaced)
HttpOperationsback to summary
protected HttpOperations(Connection connection, ConnectionObserver listener, HttpMessageLogFactory httpMessageLogFactory)

Method Detail

addHandlerback to summary
public HttpOperations<INBOUND, OUTBOUND> addHandler(String name, ChannelHandler handler)

Overrides default reactor.netty.Connection.addHandler.

Doc from reactor.netty.Connection.addHandler.

Add a ChannelHandler with addHandlerFirst if of type of io.netty.channel.ChannelOutboundHandler otherwise with addHandlerLast. 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.)

Parameters
name:String

handler name

handler:ChannelHandler

handler instance

Returns:HttpOperations<INBOUND, OUTBOUND>

this Connection

Annotations
@Override
@SuppressWarnings:deprecation
afterMarkSentHeadersback to summary
protected abstract void afterMarkSentHeaders()
asDebugLogMessageback to summary
protected String asDebugLogMessage(Object o)

Overrides reactor.netty.channel.ChannelOperations.asDebugLogMessage.

Doc from reactor.netty.channel.ChannelOperations.asDebugLogMessage.

Transforms the object to a string for debug logs.

Parameters
o:Object

the object to be transformed

Returns:String

the string to be logged

Annotations
@Override
autoAddHttpExtractorback to summary
pack-priv static void autoAddHttpExtractor(Connection c, String name, ChannelHandler handler)
beforeMarkSentHeadersback to summary
protected abstract void beforeMarkSentHeaders()
hasSentBodyback to summary
protected final boolean hasSentBody()

Has Body been sent.

Returns:boolean

true if body has been sent

Since
1.0.37
hasSentHeadersback to summary
public final boolean hasSentHeaders()

Has headers been sent.

Returns:boolean

true if headers have been sent

httpMessageLogFactoryback to summary
protected HttpMessageLogFactory httpMessageLogFactory()
initShortIdback to summary
protected final String initShortId()

Overrides reactor.netty.channel.ChannelOperations.initShortId.

Annotations
@Override
isContentAlwaysEmptyback to summary
protected abstract boolean isContentAlwaysEmpty()
isWebsocketback to summary
public boolean isWebsocket()

Implements reactor.netty.http.HttpInfos.isWebsocket.

Doc from reactor.netty.http.HttpInfos.isWebsocket.

Returns true if websocket connection (upgraded).

Returns:boolean

true if websocket connection

Annotations
@Override
markSentBodyback to summary
protected final boolean markSentBody()

Mark the body sent.

Returns:boolean

true if marked for the first time

markSentHeaderAndBodyback to summary
protected final boolean markSentHeaderAndBody(Object... objectsToRelease)

Mark the headers and body sent.

Returns:boolean

true if marked for the first time

markSentHeadersback to summary
protected final boolean markSentHeaders(Object... objectsToRelease)

Mark the headers sent.

Returns:boolean

true if marked for the first time

newFullBodyMessageback to summary
protected abstract HttpMessage newFullBodyMessage(ByteBuf body)
onHeadersSentback to summary
protected abstract void onHeadersSent()
outboundHttpMessageback to summary
protected abstract HttpMessage outboundHttpMessage()

Outbound Netty HttpMessage.

Returns:HttpMessage

Outbound Netty HttpMessage

prepareHttpMessageback to summary
pack-priv HttpMessage prepareHttpMessage(ByteBuf buffer)
requestIdback to summary
public String requestId()

Implements reactor.netty.http.HttpInfos.requestId.

Doc from reactor.netty.http.HttpInfos.requestId.

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

Returns:String

an unique id for the request

Annotations
@Override
resolvePathback to summary
public static String resolvePath(String uri)

Returns the decoded path portion from the provided uri.

Parameters
uri:String

an HTTP URL that may contain a path with query/fragment

Returns:String

the decoded path portion from the provided uri

sendback to summary
public NettyOutbound send(Publisher<? extends ByteBuf> source)

Overrides default reactor.netty.NettyOutbound.send.

Doc from reactor.netty.NettyOutbound.send.

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.

Parameters
source:Publisher<? extends ByteBuf>

the dataStream publishing OUT items to write on this channel

Returns:NettyOutbound

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.

Annotations
@Override
@SuppressWarnings:unchecked
sendFileback to summary
public final NettyOutbound sendFile(Path file, long position, long count)

Overrides default reactor.netty.NettyOutbound.sendFile.

Doc from reactor.netty.NettyOutbound.sendFile.

Sends content from the given Path using java.nio.channels.FileChannel#transferTo(long, long, WritableByteChannel) support, if the system supports it, the path resolves to a local file system File, 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.

Parameters
file:Path

the file Path

position:long

where to start

count:long

how much to transfer

Returns:NettyOutbound

A Publisher to signal successful sequence write (e.g. after "flush") or any error during write

Annotations
@Override
sendObjectback to summary
public NettyOutbound sendObject(Object message)

Overrides reactor.netty.channel.ChannelOperations.sendObject.

Implements reactor.netty.NettyOutbound.sendObject.

Doc from reactor.netty.NettyOutbound.sendObject.

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.

Parameters
message:Object

the object to publish

Returns:NettyOutbound

A Mono to signal successful sequence write (e.g. after "flush") or any error during write

Annotations
@Override
thenback to summary
public Mono<Void> then()

Overrides default reactor.netty.NettyOutbound.then.

Doc from reactor.netty.NettyOutbound.then.

Obtains a Mono of pending outbound(s) write completion.

Returns:Mono<Void>

a Mono of pending outbound(s) write completion

Annotations
@Override
toStringback to summary
public String toString()

Overrides reactor.netty.channel.ChannelOperations.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
reactor.netty.http back to summary

protected final Class HttpOperations.PostHeadersNettyOutbound

extends Object
implements NettyOutbound, Consumer<Throwable>, Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable, java.util.function.Consumer, reactor.netty.NettyOutbound, org.reactivestreams.Publisher

Field Summary

Modifier and TypeField and Description
pack-priv final ByteBuf
pack-priv final HttpOperations<?, ?>
pack-priv final Mono<Void>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
accept(Throwable
the input argument
throwable
)

Implements java.util.function.Consumer.accept.

Performs this operation on the given argument.
public ByteBufAllocator
alloc()

Implements reactor.netty.NettyOutbound.alloc.

Returns the assigned ByteBufAllocator.
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.
public NettyOutbound
send(Publisher<? extends ByteBuf>
the dataStream publishing OUT items to write on this channel
dataStream
,
Predicate<ByteBuf>
that returns true if explicit flush operation is needed after that buffer
predicate
)

Implements reactor.netty.NettyOutbound.send.

Sends data to the peer, listens for any error on write and closes on terminal signal (complete|error).
public NettyOutbound
sendObject(Publisher<?>
the dataStream publishing items to write on this channel or a simple pojo supported by configured Netty handlers
dataStream
,
Predicate<Object>
that returns true if explicit flush operation is needed after that object
predicate
)

Implements reactor.netty.NettyOutbound.sendObject.

Sends an object through Netty pipeline.
public NettyOutbound
sendObject(Object
the object to publish
message
)

Implements reactor.netty.NettyOutbound.sendObject.

Sends data to the peer, listens for any error on write and closes on terminal signal (complete|error).
public <S> NettyOutbound
sendUsing(Callable<? extends S>
state generator
sourceInput
,
BiFunction<? super Connection, ? super S, ?>
input to send
mappedInput
,
Consumer<? super S>
state cleaner
sourceCleanup
)

Implements reactor.netty.NettyOutbound.sendUsing.

Binds a send to a starting/cleanup lifecycle

Note

Nesting any send* method is not supported.

public Mono<Void>
then()

Overrides default reactor.netty.NettyOutbound.then.

Obtains a Mono of pending outbound(s) write completion.
public NettyOutbound
withConnection(Consumer<? super Connection>
connection callback
withConnection
)

Implements reactor.netty.NettyOutbound.withConnection.

Call the passed callback with a Connection to operate on the underlying Channel state.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

msgback to summary
pack-priv final ByteBuf msg
parentback to summary
pack-priv final HttpOperations<?, ?> parent
sourceback to summary
pack-priv final Mono<Void> source

Constructor Detail

PostHeadersNettyOutboundback to summary
public PostHeadersNettyOutbound(Mono<Void> source, HttpOperations<?, ?> parent, ByteBuf msg)

Method Detail

acceptback to summary
public void accept(Throwable throwable)

Implements java.util.function.Consumer.accept.

Doc from java.util.function.Consumer.accept.

Performs this operation on the given argument.

Parameters
throwable:Throwable

the input argument

Annotations
@Override
allocback to summary
public ByteBufAllocator alloc()

Implements reactor.netty.NettyOutbound.alloc.

Doc from reactor.netty.NettyOutbound.alloc.

Returns the assigned ByteBufAllocator.

Returns:ByteBufAllocator

the ByteBufAllocator

Annotations
@Override
runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

Annotations
@Override
sendback to summary
public NettyOutbound send(Publisher<? extends ByteBuf> dataStream, Predicate<ByteBuf> predicate)

Implements reactor.netty.NettyOutbound.send.

Doc from reactor.netty.NettyOutbound.send.

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.

Parameters
dataStream:Publisher<? extends ByteBuf>

the dataStream publishing OUT items to write on this channel

predicate:Predicate<ByteBuf>

that returns true if explicit flush operation is needed after that buffer

Returns:NettyOutbound

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.

Annotations
@Override
sendObjectback to summary
public NettyOutbound sendObject(Publisher<?> dataStream, Predicate<Object> predicate)

Implements reactor.netty.NettyOutbound.sendObject.

Doc from reactor.netty.NettyOutbound.sendObject.

Sends an object through Netty pipeline. If type of Publisher, sends all signals, flushing on complete by default. Write occur in FIFO sequence.

Note

Nesting any send* method is not supported.

Parameters
dataStream:Publisher<?>

the dataStream publishing items to write on this channel or a simple pojo supported by configured Netty handlers

predicate:Predicate<Object>

that returns true if explicit flush operation is needed after that object

Returns:NettyOutbound

A Publisher to signal successful sequence write (e.g. after "flush") or any error during write

Annotations
@Override
sendObjectback to summary
public NettyOutbound sendObject(Object message)

Implements reactor.netty.NettyOutbound.sendObject.

Doc from reactor.netty.NettyOutbound.sendObject.

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.

Parameters
message:Object

the object to publish

Returns:NettyOutbound

A Mono to signal successful sequence write (e.g. after "flush") or any error during write

Annotations
@Override
sendUsingback to summary
public <S> NettyOutbound sendUsing(Callable<? extends S> sourceInput, BiFunction<? super Connection, ? super S, ?> mappedInput, Consumer<? super S> sourceCleanup)

Implements reactor.netty.NettyOutbound.sendUsing.

Doc from reactor.netty.NettyOutbound.sendUsing.

Binds a send to a starting/cleanup lifecycle

Note

Nesting any send* method is not supported.

Parameters
<S>
state type
sourceInput:Callable<? extends S>

state generator

mappedInput:BiFunction<? super Connection, ? super S, ?>

input to send

sourceCleanup:Consumer<? super S>

state cleaner

Returns:NettyOutbound

a new NettyOutbound

Annotations
@Override
thenback to summary
public Mono<Void> then()

Overrides default reactor.netty.NettyOutbound.then.

Doc from reactor.netty.NettyOutbound.then.

Obtains a Mono of pending outbound(s) write completion.

Returns:Mono<Void>

a Mono of pending outbound(s) write completion

Annotations
@Override
withConnectionback to summary
public NettyOutbound withConnection(Consumer<? super Connection> withConnection)

Implements reactor.netty.NettyOutbound.withConnection.

Doc from reactor.netty.NettyOutbound.withConnection.

Call the passed callback with a Connection to operate on the underlying Channel state.

Parameters
withConnection:Consumer<? super Connection>

connection callback

Returns:NettyOutbound

the Connection

Annotations
@Override