com.atlassian.httpclient.api
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
 java.lang.String getContentCharset()
          Returns the currently set content charset value, if any.
 java.lang.String getContentType()
          Returns the IANA media type, minus charset information, for the current entity, if any.
 java.lang.String 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.
 java.io.InputStream getEntityStream()
          Returns the current entity as an input stream, or null if not set.
 java.lang.String getHeader(java.lang.String name)
          Returns the specified header by name.
 java.util.Map<java.lang.String,java.lang.String> getHeaders()
          Returns a map of all headers that have been set on this object.
 boolean hasEntity()
          Returns whether or not an entity has been set on this object.
 boolean hasReadEntity()
          Returns whether or not the current entity property, if any, has been read from this object.
 

Method Detail

getContentType

java.lang.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

java.lang.String getContentCharset()
Returns the currently set content charset value, if any.

Returns:
The current content charset

getEntityStream

java.io.InputStream getEntityStream()
                                    throws java.lang.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:
java.lang.IllegalStateException - If the non-null entity has already been accessed once, through any accessor for this object

getEntity

java.lang.String getEntity()
                           throws java.lang.IllegalStateException,
                                  java.lang.IllegalArgumentException
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:
java.lang.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
java.lang.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

java.util.Map<java.lang.String,java.lang.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

java.lang.String getHeader(java.lang.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


Copyright © 2012-2014 Atlassian. All Rights Reserved.