Interface Message

All Known Subinterfaces:
Request, Response

public interface Message
An abstract base class for HTTP messages (i.e. Request and Response) with support for header and entity management.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the currently set content charset value, if any.
    io.atlassian.fugue.Option<Long>
    Returns the content length for the entity in the message.
    Returns the IANA media type, minus charset information, for the current entity, if any.
    Returns the current entity in String form, if available, converting the underlying entity stream to a string using the currently set content charset, or defaulting to the HTTP standard of "ISO-8859-1" if no content charset has been specified.
    Returns the current entity as an input stream, or null if not set.
    Returns the specified header by name.
    Returns a map of all headers that have been set on this object.
    boolean
    Returns whether or not an entity has been set on this object.
    boolean
    Returns whether or not the current entity property, if any, has been read from this object.
  • Method Details

    • getContentType

      String getContentType()
      Returns the IANA media type, minus charset information, for the current entity, if any. To access charset information, use getContentCharset(). To get the full Content-Type header value including charset if specified, use getHeader("Content-Type").
      Returns:
      An IANA media type, or null
    • getContentCharset

      String getContentCharset()
      Returns the currently set content charset value, if any.
      Returns:
      The current content charset
    • getEntityStream

      InputStream getEntityStream() throws IllegalStateException
      Returns the current entity as an input stream, or null if not set. Use hasEntity() to check if this message has an entity value.
      Returns:
      An input stream for the current entity, or null if not set
      Throws:
      IllegalStateException - If the non-null entity has already been accessed once, through any accessor for this object
    • getEntity

      Returns the current entity in String form, if available, converting the underlying entity stream to a string using the currently set content charset, or defaulting to the HTTP standard of "ISO-8859-1" if no content charset has been specified.
      Returns:
      The entity string, or null if no entity has been set
      Throws:
      IllegalStateException - If the non-null entity has already been accessed once, through any accessor for this object. Also thrown if underlying body cannot be converted into a String
      IllegalArgumentException - If the entity exceeds the maximum size
    • hasEntity

      boolean hasEntity()
      Returns whether or not an entity has been set on this object. Use this instead of calling an entity getter to test for presence of an entity, as the getters will affect this object's hasReadEntity() state.
      Returns:
      This object, for builder-style chaining
    • hasReadEntity

      boolean hasReadEntity()
      Returns whether or not the current entity property, if any, has been read from this object. If this method returns true, any further calls to entity property accessors on this object will result in an IllegalStateException being thrown.
      Returns:
      True if the entity has already been read
    • getHeaders

      Map<String,String> getHeaders()
      Returns a map of all headers that have been set on this object. If the content type property has been set, a full "Content-Type" header including content charset, if set, is generated as part of this map.
      Returns:
      The headers map
    • getHeader

      String getHeader(String name)
      Returns the specified header by name. If "Content-Type" is requested, the value will be constructed from this object's content type and content charset properties, if set and as appropriate.
      Parameters:
      name - The name of the header to fetch
      Returns:
      The value of the named header, or null if not set
    • getContentLength

      io.atlassian.fugue.Option<Long> getContentLength()
      Returns the content length for the entity in the message. For requests, this would be the content length of the entity that you set, or the content length that you can set manually (e.g. for streamed entities). For responses, this would be the content length from the header.
      Returns:
      The content length as an option. None is returned if no content length has been set or not present.