Interface HttpPlainRequest
- All Superinterfaces:
BaseRequest,HttpBaseRequest
- All Known Subinterfaces:
HttpRequest,HttpRequest,Request
- Author:
- Jeoffrey HAEYAERT (jeoffrey.haeyaert at graviteesource.com), GraviteeSource Team
-
Method Summary
Modifier and TypeMethodDescriptionio.reactivex.rxjava3.core.Maybe<Buffer>body()Get the current body request as aMaybe.voidSet the current body request as aBuffer.io.reactivex.rxjava3.core.Single<Buffer>io.reactivex.rxjava3.core.Flowable<Buffer>chunks()Get the current request body chunks asFlowableofBuffer.voidSet the current request body chunks from aFlowableofBuffer.voidcontentLength(long length) Set the `Content-Length` header to the request.booleanIndicates if that request is a websocket request.voidmethod(io.gravitee.common.http.HttpMethod method) io.reactivex.rxjava3.core.CompletableApplies a transformation on the complete body given as a singleBuffer.io.reactivex.rxjava3.core.CompletableApplies a transformation on each body chunks and completes when all the chunks have been processed.Returns the underlying websocket associated to this request ornullif the current request is not a websocket request.Methods inherited from interface io.gravitee.gateway.reactive.api.context.http.HttpBaseRequest
clientIdentifier, contextPath, ended, headers, host, id, localAddress, method, originalHost, parameters, path, pathInfo, pathParameters, remoteAddress, scheme, timestamp, tlsSession, transactionId, uri, version
-
Method Details
-
isWebSocket
boolean isWebSocket()Indicates if that request is a websocket request.A websocket request must respond to the following criteria:
- Has a
Connection: Upgradeheader - Has a
Upgrade: websocketheader - Is a
GETrequest - Is an HTTP 1.0 or HTTP 1.1 request
- Returns:
trueis the request is a websocket,falseotherwise.
- Has a
-
webSocket
WebSocket webSocket()Returns the underlying websocket associated to this request ornullif the current request is not a websocket request.- Returns:
- the underlying websocket associated to this request.
- See Also:
-
body
io.reactivex.rxjava3.core.Maybe<Buffer> body()Get the current body request as aMaybe.By getting the body as a
Maybe, the current body chunks will be merged together to reconstruct the entire body to provide it in the form of a singleBufferThis is useful when the entire body is required to apply some transformation or any manipulation.WARN: beware that the entire body content will be loaded in memory. You should not keep a direct reference on the body chunks as they could be overridden by others at anytime.
- Returns:
- a
Maybeobservable containing the current entire body request or empty if request body has not been set yet. - See Also:
-
bodyOrEmpty
io.reactivex.rxjava3.core.Single<Buffer> bodyOrEmpty()Same asbody()but returns aSingleofBufferinstead.If no body request as been set yet, it returns a
Singlewith an emptyBuffer. It is a convenient way that avoid checking if the body is set or not prior to manipulate it.- Returns:
- a
Singleobservable containing the current entire body request or empty an {@link Buffer) if request body has not been set yet. - See Also:
-
body
Set the current body request as aBuffer.This is useful when you want to replace the current body request with a specific content that doesn't come from a reactive chain, ex:
WARN:request.body(Buffer.buffer("My custom content");- replacing the request body will NOT "drain" the previous request that was in place.
- You MUST ensure to consume the previous body by yourself when using it.
- You SHOULD consider using
onBody(MaybeTransformer)to change the body during the chain execution.
- See Also:
-
onBody
io.reactivex.rxjava3.core.Completable onBody(io.reactivex.rxjava3.core.MaybeTransformer<Buffer, Buffer> onBody) Applies a transformation on the complete body given as a singleBuffer.Ex:
request.onBody(body -> body.map(buffer -> Buffer.buffer(buffer.toString().toUpperCase())));IMPORTANT: applying a transformation on the body content loads the whole body in memory. It's up to the consumer to make sure it is safe to do that without consuming too much memory.
- Parameters:
onBody- the transformation that will be applied on the body.- Returns:
- a
Completablethat completes once the body transformation has occurred.
-
chunks
io.reactivex.rxjava3.core.Flowable<Buffer> chunks()Get the current request body chunks asFlowableofBuffer.This is useful when you want to manipulate the entire body without having to load it in memory.
WARN: you should not keep a direct reference on the body chunks as they could be overridden by others at anytime.
- Returns:
- a
Flowablecontaining the current body request chunks.
-
chunks
Set the current request body chunks from aFlowableofBuffer.This is useful to directly pump the upstream chunks to the downstream without having to load all the chunks in memory.
WARN:
- replacing the request chunks will NOT "drain" the previous request that was in place.
- You MUST ensure to consume the previous chunks by yourself when using it.
- You SHOULD consider using
onChunks(FlowableTransformer)to change the chunks during the chain execution.
- Parameters:
chunks- theFlowableof chunks representing the request body that will be pushed to the upstream.- See Also:
-
onChunks
io.reactivex.rxjava3.core.Completable onChunks(io.reactivex.rxjava3.core.FlowableTransformer<Buffer, Buffer> onChunks) Applies a transformation on each body chunks and completes when all the chunks have been processed.Ex:
request.onChunks(chunks -> chunks.map(buffer -> Buffer.buffer(buffer.toString().toUpperCase())));IMPORTANT: applying a transformation on the body chunks loads the whole body in memory. It's up to the consumer to make sure it is safe to do that without consuming too much memory.
IMPORTANT: applying a transformation on chunks completes when all chunks have been transformed. If used in a policy chain, it means that the next policy will start once all chunks have been transformed
- Parameters:
onChunks- the transformer that will be applied.- Returns:
- a
Completablethat completes once the body transformation has occurred on all the chunks.
-
contentLength
void contentLength(long length) Set the `Content-Length` header to the request.WARN: any existing `Transfer-Encoding` header will be removed.
- Parameters:
length- The value of the `Content-Length` header- See Also:
-
method
void method(io.gravitee.common.http.HttpMethod method)
-