Class RequestContext


  • public class RequestContext
    extends java.lang.Object
    Context containing all important info about a request.
    • Constructor Detail

      • RequestContext

        public RequestContext​(HttpHeaders headers,
                              java.net.URI uri,
                              HttpClient.Method method,
                              java.lang.Object body)
        Construct a request context.
        Parameters:
        headers - map of all headers
        uri - uri of the request
        method - verb to be used
        body - optional body of request
    • Method Detail

      • putHeader

        public void putHeader​(java.lang.String name,
                              java.lang.String value)
      • containsHeader

        public boolean containsHeader​(java.lang.String name)
      • removeHeader

        public void removeHeader​(java.lang.String name)
      • getUri

        public java.net.URI getUri()
      • getBody

        public java.util.Optional<java.lang.Object> getBody()
      • addResponseCallback

        public void addResponseCallback​(java.util.function.BiConsumer<ResponseContext,​java.lang.Exception> responseCallback)
        Adds a callback to be called when the request has finished. The responseCallback consumer is called with a non-null ResponseContext, if the HTTP request technically succeeded. The The responseCallback consumer is called with a non-null Exception object, if the HTTP request technically failed.
        Parameters:
        responseCallback - callback that receives either a non-null ResponseContext or a non-null Exception.