Interface HttpIncomingResponse<Self,​Request extends HttpOutgoingRequest<?>>

    • Method Detail

      • bodyAsIfSuccess

        default <R extends DtoReadableFuture<R> bodyAsIfSuccess​(java.lang.Class<R> class_)
        Retrieves the body of this response, if its status code is in the range 200-299.

        If the body is to be decoded, an attempt will be made to automatically resolve a supported DTO encoding. If the attempt fails an exception is thrown.

        Type Parameters:
        R - Type of class_.
        Parameters:
        class_ - Class to decode incoming HTTP body into.
        Returns:
        Future completed immediately with an exception if the status code is outside the success range, or when the incoming HTTP body has been fully received and decoded into an instance of class_.
        Throws:
        MessageException - If resolving a default encoding failed.
        java.lang.IllegalStateException - If the body has already been requested.
      • bodyAsIfSuccess

        default <R extends DtoReadableFuture<R> bodyAsIfSuccess​(DtoEncoding encoding,
                                                                  java.lang.Class<R> class_)
        Retrieves the body of this response, if its status code is in the range 200-299.
        Type Parameters:
        R - Type of class_.
        Parameters:
        encoding - Encoding to use if decoding incoming HTTP body.
        class_ - Class to decode incoming HTTP body into.
        Returns:
        Future completed immediately with an exception if the status code is outside the success range, or when the incoming HTTP body has been fully received and decoded into an instance of class_.
        Throws:
        java.lang.IllegalStateException - If the body has already been requested.
      • reject

        default HttpIncomingResponseUnexpected reject()
        Creates an exception containing this response.

        This method is primarily intended to be used when receiving messages that contain unexpected status codes. If the reason behind the rejection requires more explanation, please use reject(String) instead.

        Returns:
        Exception wrapping this response.
      • reject

        default HttpIncomingResponseUnexpected reject​(java.lang.String reason)
        Creates an exception containing this response and a description of why it was rejected.
        Parameters:
        reason - Description of what expectations this request fails to fulfill.
        Returns:
        Exception wrapping this response.
      • reject

        default HttpIncomingResponseUnexpected reject​(java.lang.String reason,
                                                      java.lang.Throwable cause)
        Creates an exception containing this response and a description of why it was rejected.
        Parameters:
        reason - Description of what expectations this response fails to fulfill.
        cause - Exception thrown due to this response not fulfilling some arbitrary requirement.
        Returns:
        Exception wrapping this response.
      • rejectIfNotSuccess

        default Future<?> rejectIfNotSuccess()
        Returns a Future that contains the exception returned by reject(), if its status code is not in the range 200-299. Otherwise a successful future containing null is returned.

        This method is primarily intended to be used when receiving messages that contain unexpected status codes and no response body is expected. If a response body is expected, please use bodyAsIfSuccess(DtoEncoding, Class) instead. If the reason behind the rejection requires more explanation, please use rejectIfNotSuccess(String) instead.

        Returns:
        Future completed with exception only if this response contains a status code outside the range 200-299.
      • rejectIfNotSuccess

        default Future<?> rejectIfNotSuccess​(java.lang.String reason)
        Returns a Future that contains the exception returned by reject(String), if its status code is not in the range 200-299. Otherwise a successful future containing null is returned.

        This method is primarily intended to be used when receiving messages that contain unexpected status codes and no response body is expected. If a response body is expected, please use bodyAsIfSuccess(DtoEncoding, Class) instead.

        Parameters:
        reason - Description of what expectations this request fails to fulfill.
        Returns:
        Future completed with exception only if this response contains a status code outside the range 200-299.
      • request

        Request request()
        Gets request that was responded to with this message.
        Returns:
        Original response request.
      • status

        HttpStatus status()
        Gets HTTP status code associated with this response.
        Returns:
        Response status.