Class Message<T extends Message<T>>

  • Type Parameters:
    T - A Type that extends Message (either Request or Response)
    Direct Known Subclasses:
    Request

    public abstract class Message<T extends Message<T>>
    extends Object
    This class represents an HTTP Message, which could either be a Request or a Response. Message is an abstract class that contains fields and methods that are common to both types of Messages.
    • Constructor Detail

      • Message

        public Message()
        The default constructor is a no-op constructor.
    • Method Detail

      • getBody

        public String getBody()
        Returns the Message body (also known as the Entity body).
        Returns:
        The body of the HTTP Message. It will typically be HTML, JSON, or XML.
      • setBody

        public T setBody​(String body)
        Sets the body of the Message.
        Parameters:
        body - This is typically the JSON, XML, or Form Parameters being sent to the server.
        Returns:
        this Message, to support chained method calls
      • addHeader

        public T addHeader​(String name,
                           String value)
        Adds a single header value to the Message.
        Parameters:
        name - The header name.
        value - The header value
        Returns:
        this Message, to support chained method calls
      • removeHeader

        public T removeHeader​(String name)
        Removes the specified header.
        Parameters:
        name - The name of the header to remove.
        Returns:
        this Message, to support chained method calls
      • setHeaders

        public T setHeaders​(Map<String,​List<String>> headers)
        Sets all of the headers in one call.
        Parameters:
        headers - A Map of headers, where the header name is a String, and the value is a List of one or more values.
        Returns:
        this Message, to support chained method calls