Class BaseRequest

  • All Implemented Interfaces:
    Request

    @Immutable
    @Loggable(1)
    public final class BaseRequest
    extends Object
    implements Request
    Base implementation of Request.
    Since:
    0.8 // @checkstyle ClassDataAbstractionCoupling (500 lines)
    See Also:
    Request, Response
    • Constructor Detail

      • BaseRequest

        public BaseRequest​(Wire wre,
                           String uri)
        Public ctor.
        Parameters:
        wre - Wire
        uri - The resource to work with
      • BaseRequest

        public BaseRequest​(Wire wre,
                           String uri,
                           Iterable<Map.Entry<String,​String>> headers,
                           String method,
                           byte[] body)
        Public ctor.
        Parameters:
        wre - Wire
        uri - The resource to work with
        headers - Headers
        method - HTTP method
        body - HTTP request body
      • BaseRequest

        public BaseRequest​(Wire wre,
                           String uri,
                           Iterable<Map.Entry<String,​String>> headers,
                           String method,
                           byte[] body,
                           int cnct,
                           int rdd)
        Public ctor.
        Parameters:
        wre - Wire
        uri - The resource to work with
        headers - Headers
        method - HTTP method
        body - HTTP request body
        cnct - Connect timeout for http connection
        rdd - Read timeout for http connection
    • Method Detail

      • uri

        public RequestURI uri()
        Description copied from interface: Request
        Get destination URI.
        Specified by:
        uri in interface Request
        Returns:
        The destination it is currently pointing to
      • header

        public Request header​(String name,
                              Object value)
        Description copied from interface: Request
        Set request header.
        Specified by:
        header in interface Request
        Parameters:
        name - ImmutableHeader name
        value - Value of the header to set
        Returns:
        New alternated request
      • reset

        public Request reset​(String name)
        Description copied from interface: Request
        Remove all headers with this name.
        Specified by:
        reset in interface Request
        Parameters:
        name - ImmutableHeader name
        Returns:
        New alternated request
      • body

        public RequestBody body()
        Description copied from interface: Request
        Get request body.
        Specified by:
        body in interface Request
        Returns:
        New alternated request
      • multipartBody

        public RequestBody multipartBody()
        Description copied from interface: Request
        Get multipart form (multipart/form-data) body.
        Specified by:
        multipartBody in interface Request
        Returns:
        New altered request
      • method

        public Request method​(String method)
        Description copied from interface: Request
        Use this method.
        Specified by:
        method in interface Request
        Parameters:
        method - The method to use
        Returns:
        New alternated request
      • timeout

        public Request timeout​(int cnct,
                               int rdd)
        Description copied from interface: Request
        Use this timeout values.
        Specified by:
        timeout in interface Request
        Parameters:
        cnct - The connect timeout to use in ms
        rdd - The read timeout to use in ms
        Returns:
        New alternated request
      • fetch

        public Response fetch()
                       throws IOException
        Description copied from interface: Request
        Execute it with a specified HTTP method.
        Specified by:
        fetch in interface Request
        Returns:
        Response
        Throws:
        IOException - If fails to fetch HTTP request
      • fetch

        public Response fetch​(InputStream stream)
                       throws IOException
        Description copied from interface: Request
        Execute this request using the content provided by the InputStream being passed as the request body. Note that the request MUST have an empty body when this method is being invoked, or it will throw an IllegalStateException.
        Specified by:
        fetch in interface Request
        Parameters:
        stream - The input stream to use
        Returns:
        Response
        Throws:
        IOException - If fails to fetch HTTP request
      • through

        public <T extends WireRequest through​(Class<T> type,
                                                Object... args)
        Description copied from interface: Request
        Send it through a decorating Wire.
        Specified by:
        through in interface Request
        Type Parameters:
        T - Type to use
        Parameters:
        type - Type of wire to use
        args - Optional arguments for the wire constructor
        Returns:
        New request with a wire decorated
      • through

        public Request through​(Wire wre)
        Description copied from interface: Request
        Send it through a decorating Wire.
        Specified by:
        through in interface Request
        Parameters:
        wre - Wire to use
        Returns:
        New request with a wire decorated