Interface Request


  • public interface Request
    • Method Detail

      • transactionId

        String transactionId()
        Propagated transaction id between multiple requests.
        Returns:
        Transaction ID.
      • uri

        String uri()
        Returns:
        The URL the client used to make the request.
      • host

        String host()
        Allows to retrieve the request host. This method should be preferred over retrieving the host from http headers.
        Returns:
        the host.
      • path

        String path()
        Returns:
        the part of this request's URL from the protocol name up to the query string in the first line of the HTTP request.
      • pathInfo

        String pathInfo()
        Returns:
        the path without the context-path.
      • contextPath

        String contextPath()
        Returns:
        the portion of the request URI that indicates the context of the request.
      • parameters

        io.gravitee.common.util.MultiValueMap<String,​String> parameters()
        Returns:
        the query parameters in the request
      • pathParameters

        io.gravitee.common.util.MultiValueMap<String,​String> pathParameters()
        Returns:
        the path parameters in the request
      • headers

        HttpHeaders headers()
        Returns:
        the headers in the request.
      • method

        io.gravitee.common.http.HttpMethod method()
        Returns:
        the HTTP method for the request.
      • version

        io.gravitee.common.http.HttpVersion version()
        Returns:
        the HTTP version of the request
      • timestamp

        long timestamp()
        The timestamp for when this request was received. Specifically, this is the timestamp of creation of the request object.
        Returns:
        the instant timestamp for the request.
      • remoteAddress

        String remoteAddress()
        Returns the Internet Protocol (IP) address of the client or last proxy that sent the request.
        Returns:
        a String containing the IP address of the client that sent the request.
      • localAddress

        String localAddress()
        Returns the Internet Protocol (IP) address of the interface on which the request was received.
        Returns:
        a String containing the IP address on which the request was received.
      • sslSession

        SSLSession sslSession()
        Returns:
        SSLSession associated to the request. Returns null if not an SSL connection.
        See Also:
        SSLSession
      • metrics

        io.gravitee.reporter.api.http.Metrics metrics()
        Get the metrics associated to the request.
        Returns:
        a Metrics object.
      • ended

        boolean ended()
        Indicates if that request is ended or not meaning that all the request headers and the request body have been fully read.
        Returns:
        true if the headers and body have been read, false else.
      • body

        io.reactivex.Maybe<Buffer> body()
        Get the current body request as a Maybe. By getting the body as a Maybe, the current body chunks will be merged together to reconstruct the entire body in provide it in the form of a single Buffer This 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 Maybe observable containing the current entire body request or empty if request body as not been set yet.
        See Also:
        bodyOrEmpty()
      • bodyOrEmpty

        io.reactivex.Single<Buffer> bodyOrEmpty()
        Same as body() but returns a Single of Buffer instead. If no body request as been set yet, it returns a Single with an empty Buffer. It is a convenient way that avoid checking if the body is set or not prior to manipulate it.
        Returns:
        a Single observable containing the current entire body request or empty an {@link Buffer) if request body as not been set yet.
        See Also:
        body()
      • body

        void body​(Buffer buffer)
        Set the current body request as a Buffer. 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: request.body(Buffer.buffer("My custom content"); WARN: replacing the request body will "drain" the previous request that was in place but occurs outside the reactive chain. You should consider using onBody(MaybeTransformer) to change the body during the chain execution.
        See Also:
        onBody(MaybeTransformer), chunks(Flowable)
      • onBody

        io.reactivex.Completable onBody​(io.reactivex.MaybeTransformer<Buffer,​Buffer> onBody)
        Applies a transformation on the complete body given as a single Buffer. 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 Completable that completes once the body transformation has occurred.
      • chunks

        io.reactivex.Flowable<Buffer> chunks()
        Get the current request body chunks as Flowable of Buffer. 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 Flowable containing the current body request chunks.
      • chunks

        void chunks​(io.reactivex.Flowable<Buffer> chunks)
        Set the current request body chunks from a Flowable of Buffer. 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 body will "drain" the previous request that was in place.
        Parameters:
        chunks - the flowable of chunks representing the request body that will be pushed to the upstream.
        See Also:
        body()
      • onChunk

        io.reactivex.Completable onChunk​(io.reactivex.FlowableTransformer<Buffer,​Buffer> onChunk)
        Applies a transformation on each body chunks and completes when all the chunks have been processed. Ex: request.onChunk(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:
        onChunk - the transformer that will be applied.
        Returns:
        a Completable that completes once the body transformation has occurred on all the chunks.