public class HttpToH2Operations extends HttpOperations<HttpServerRequest,HttpServerResponse>
ChannelOperations.OnSetup
Disposable.Composite, Disposable.Swap
Modifier and Type | Method and Description |
---|---|
HttpServerResponse |
addCookie(Cookie cookie)
Add an outbound cookie
|
HttpServerResponse |
addHeader(CharSequence name,
CharSequence value)
Add an outbound http header, appending the value if the header already exist.
|
reactor.netty.http.server.HttpServerOperations |
chunkedTransfer(boolean chunked)
Set transfer-encoding header
|
HttpServerResponse |
compression(boolean compress)
Enable/Disable compression handling (gzip/deflate) for the underlying response
|
Map<CharSequence,Set<Cookie>> |
cookies()
Return resolved HTTP cookies
|
HttpServerResponse |
header(CharSequence name,
CharSequence value)
Set an outbound header, replacing any pre-existing value.
|
HttpServerResponse |
headers(HttpHeaders headers)
Set outbound headers, replacing any pre-existing value for these headers.
|
InetSocketAddress |
hostAddress()
Return the address of the host peer.
|
boolean |
isKeepAlive()
Is the request keepAlive
|
boolean |
isWebsocket()
Return true if websocket connection (upgraded)
|
HttpServerResponse |
keepAlive(boolean keepAlive)
Set the request keepAlive if true otherwise remove the existing connection keep alive header
|
HttpMethod |
method()
Return the resolved request method (HTTP 1.1 etc)
|
protected HttpMessage |
newFullEmptyBodyMessage() |
protected void |
onInboundNext(ChannelHandlerContext ctx,
Object msg)
React on inbound
Channel.read() |
protected void |
onOutboundComplete()
React on inbound/outbound completion (last packet)
|
protected void |
onOutboundError(Throwable err)
React on inbound/outbound error
|
protected HttpMessage |
outboundHttpMessage()
Outbound Netty HttpMessage
|
String |
param(CharSequence key)
URI parameter captured via {} "/test/{var}"
|
Map<String,String> |
params()
Return the param captured key/value map
|
HttpServerRequest |
paramsResolver(java.util.function.Function<? super String,Map<String,String>> headerResolver) |
protected void |
preSendHeadersAndStatus() |
Flux<?> |
receiveObject()
a Object inbound
Flux |
InetSocketAddress |
remoteAddress()
Return the address of the remote peer.
|
HttpHeaders |
requestHeaders()
Return inbound
HttpHeaders |
HttpHeaders |
responseHeaders()
Return headers sent back to the clients
|
String |
scheme()
Return the current scheme
|
Mono<Void> |
send()
Send headers and empty content thus delimiting a full empty body http response.
|
NettyOutbound |
sendFile(Path file)
Send content from given
Path using
FileChannel.transferTo(long, long, WritableByteChannel)
support. |
NettyOutbound |
sendHeaders()
Return a
NettyOutbound successful on committed response |
Mono<Void> |
sendNotFound()
Send 404 status
HttpResponseStatus.NOT_FOUND . |
Mono<Void> |
sendRedirect(String location)
Send redirect status
HttpResponseStatus.FOUND along with a location
header to the remote client. |
Mono<Void> |
sendWebsocket(String protocols,
int maxFramePayloadLength,
java.util.function.BiFunction<? super WebsocketInbound,? super WebsocketOutbound,? extends Publisher<Void>> websocketHandler)
Upgrade connection to Websocket with optional subprotocol(s).
|
HttpServerResponse |
sse()
Add "text/event-stream" content-type for Server-Sent Events
|
HttpResponseStatus |
status()
Return the assigned HTTP status
|
HttpServerResponse |
status(HttpResponseStatus status)
Set an HTTP status to be sent along with the headers
|
String |
uri()
Return the resolved target address
|
HttpVersion |
version()
Return the resolved request version (HTTP 1.1 etc)
|
reactor.netty.http.server.HttpServerOperations |
withConnection(java.util.function.Consumer<? super Connection> withConnection)
Call the passed callback with a
Connection to operate on the
underlying
Channel state. |
addHandler, hasSentHeaders, markSentBody, markSentHeaderAndBody, markSentHeaders, sendFile, then, toString
addListener, addListeners, addReactiveBridge, alloc, as, await, awaitUninterruptibly, channel, connection, currentContext, discard, dispose, disposeSubscriber, formatName, get, inbound, isDisposed, isInboundCancelled, isInboundDisposed, isPersistent, isVoid, listener, onComplete, onDispose, onDispose, onError, onInboundCancel, onInboundClose, onInboundComplete, onInboundError, onNext, onSubscribe, onTerminate, outbound, receive, removeListener, removeListeners, sendObject, sendObject, sendUsing, setFailure, setSuccess, setSuccess, sync, syncUninterruptibly, terminate, trySuccess, unvoid
await, await, awaitUninterruptibly, awaitUninterruptibly, cancel, cause, checkDeadLock, executor, getNow, isCancellable, isCancelled, isDone, isSuccess, notifyListener, setUncancellable, toStringBuilder, tryFailure, trySuccess
get, get
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
receiveContent
receive
hasSentHeaders, options, sendWebsocket, sendWebsocket, status
alloc, neverComplete, send, sendByteArray, sendFile, sendFileChunked, sendGroups, sendObject, sendObject, sendString, sendString, sendUsing, subscribe, then, then
addHandler, addHandlerFirst, addHandlerFirst, addHandlerLast, addHandlerLast, bind, from, markPersistent, onReadIdle, onWriteIdle, rebind, removeHandler, replaceHandler
address, disposeNow, disposeNow
setUncancellable, tryFailure, trySuccess
await, await, awaitUninterruptibly, awaitUninterruptibly, cancel, cause, getNow, isCancellable, isSuccess
get, get, isCancelled, isDone
protected void onInboundNext(ChannelHandlerContext ctx, Object msg)
ChannelOperations
Channel.read()
ctx
- the contextmsg
- the read payloadpublic NettyOutbound sendHeaders()
HttpServerResponse
NettyOutbound
successful on committed responsesendHeaders
in interface HttpServerResponse
NettyOutbound
successful on committed responsepublic reactor.netty.http.server.HttpServerOperations withConnection(java.util.function.Consumer<? super Connection> withConnection)
NettyInbound
Connection
to operate on the
underlying
Channel
state. This allows for chaining inbound API.withConnection
in interface HttpServerRequest
withConnection
in interface HttpServerResponse
withConnection
in interface NettyInbound
withConnection
in interface NettyOutbound
withConnection
in class ChannelOperations<HttpServerRequest,HttpServerResponse>
withConnection
- connection callbackConnection
protected HttpMessage newFullEmptyBodyMessage()
newFullEmptyBodyMessage
in class HttpOperations<HttpServerRequest,HttpServerResponse>
public HttpServerResponse addCookie(Cookie cookie)
HttpServerResponse
addCookie
in interface HttpServerResponse
public HttpServerResponse addHeader(CharSequence name, CharSequence value)
HttpServerResponse
addHeader
in interface HttpServerResponse
name
- header namevalue
- header valuepublic reactor.netty.http.server.HttpServerOperations chunkedTransfer(boolean chunked)
HttpServerResponse
chunkedTransfer
in interface HttpServerResponse
chunked
- true if transfer-encoding:chunkedpublic Map<CharSequence,Set<Cookie>> cookies()
HttpInfos
public HttpServerResponse header(CharSequence name, CharSequence value)
HttpServerResponse
header
in interface HttpServerResponse
name
- headers keyvalue
- header valuepublic HttpServerResponse headers(HttpHeaders headers)
HttpServerResponse
headers
in interface HttpServerResponse
headers
- netty headers mappublic boolean isKeepAlive()
HttpInfos
isKeepAlive
in interface HttpInfos
public boolean isWebsocket()
HttpInfos
isWebsocket
in interface HttpInfos
isWebsocket
in class HttpOperations<HttpServerRequest,HttpServerResponse>
public HttpServerResponse keepAlive(boolean keepAlive)
HttpServerResponse
keepAlive
in interface HttpServerResponse
public HttpMethod method()
HttpInfos
@Nullable public String param(CharSequence key)
HttpServerRequest
param
in interface HttpServerRequest
key
- param var name@Nullable public Map<String,String> params()
HttpServerRequest
params
in interface HttpServerRequest
public HttpServerRequest paramsResolver(java.util.function.Function<? super String,Map<String,String>> headerResolver)
paramsResolver
in interface HttpServerRequest
headerResolver
- provide a paramspublic Flux<?> receiveObject()
NettyInbound
Flux
receiveObject
in interface NettyInbound
receiveObject
in class ChannelOperations<HttpServerRequest,HttpServerResponse>
Flux
public InetSocketAddress hostAddress()
HttpServerRequest
hostAddress
in interface HttpServerRequest
public InetSocketAddress remoteAddress()
HttpServerRequest
remoteAddress
in interface HttpServerRequest
public HttpHeaders requestHeaders()
HttpServerRequest
HttpHeaders
requestHeaders
in interface HttpServerRequest
HttpHeaders
public String scheme()
HttpServerRequest
scheme
in interface HttpServerRequest
public HttpHeaders responseHeaders()
HttpServerResponse
responseHeaders
in interface HttpServerResponse
public Mono<Void> send()
HttpServerResponse
send
in interface HttpServerResponse
Mono
successful on committed responseNettyOutbound.send(Publisher)
public NettyOutbound sendFile(Path file)
NettyOutbound
Path
using
FileChannel.transferTo(long, long, WritableByteChannel)
support. If the system supports it and the path resolves to a local file
system File
then transfer will use zero-byte copy
to the peer.
It will listen for any error on write and close on terminal signal (complete|error). If more than one publisher is attached (multiple calls to send()) completion occurs after all publishers complete.
Note: this will emit FileRegion
in the outbound
ChannelPipeline
Note: Nesting any send* method is not supported.
sendFile
in interface NettyOutbound
file
- the file Pathpublic Mono<Void> sendNotFound()
HttpServerResponse
HttpResponseStatus.NOT_FOUND
.sendNotFound
in interface HttpServerResponse
Mono
successful on flush confirmationpublic Mono<Void> sendRedirect(String location)
HttpServerResponse
HttpResponseStatus.FOUND
along with a location
header to the remote client.sendRedirect
in interface HttpServerResponse
location
- the location to redirect toMono
successful on flush confirmationpublic HttpServerResponse sse()
HttpServerResponse
sse
in interface HttpServerResponse
public HttpResponseStatus status()
HttpServerResponse
status
in interface HttpServerResponse
public HttpServerResponse status(HttpResponseStatus status)
HttpServerResponse
status
in interface HttpServerResponse
status
- an HTTP status to be sent along with the headerspublic Mono<Void> sendWebsocket(@Nullable String protocols, int maxFramePayloadLength, java.util.function.BiFunction<? super WebsocketInbound,? super WebsocketOutbound,? extends Publisher<Void>> websocketHandler)
HttpServerResponse
Mono
fails.sendWebsocket
in interface HttpServerResponse
protocols
- optional sub-protocolmaxFramePayloadLength
- maximum allowable frame payload lengthwebsocketHandler
- the in/out handler for ws transportMono
completing when upgrade is confirmedpublic String uri()
HttpInfos
public HttpVersion version()
HttpInfos
public HttpServerResponse compression(boolean compress)
HttpServerResponse
compression
in interface HttpServerResponse
compress
- should handle compressionprotected void preSendHeadersAndStatus()
preSendHeadersAndStatus
in class HttpOperations<HttpServerRequest,HttpServerResponse>
protected void onOutboundComplete()
ChannelOperations
onOutboundComplete
in class ChannelOperations<HttpServerRequest,HttpServerResponse>
protected void onOutboundError(Throwable err)
ChannelOperations
onOutboundError
in class ChannelOperations<HttpServerRequest,HttpServerResponse>
err
- the Throwable
causeprotected HttpMessage outboundHttpMessage()
HttpOperations
outboundHttpMessage
in class HttpOperations<HttpServerRequest,HttpServerResponse>