Interface Message
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 TypeMethodDescriptionReturns 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 inStringform, 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.booleanReturns whether or not an entity has been set on this object.booleanReturns 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, usegetContentCharset(). To get the full Content-Type header value including charset if specified, usegetHeader("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
Returns the current entity as an input stream, or null if not set. UsehasEntity()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 inStringform, 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 StringIllegalArgumentException- 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'shasReadEntity()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 anIllegalStateExceptionbeing thrown.- Returns:
- True if the entity has already been read
-
getHeaders
-
getHeader
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.
-