com.atlassian.httpclient.api
Interface Response

All Superinterfaces:
Message

public interface Response
extends Message

Represents the result of an HTTP request.


Method Summary
 int getStatusCode()
          Gets the status code of the response.
 java.lang.String getStatusText()
          Gets the status text of the response.
 boolean isBadRequest()
          Indicates whether or not this response's status code is "Bad Request".
 boolean isClientError()
          Indicates whether or not this response's status code is categorized as "Client Error" (4xx).
 boolean isConflict()
          Indicates whether or not this response's status code is "Conflict".
 boolean isCreated()
          Indicates whether or not this response's status code is "Created".
 boolean isError()
          Indicates whether or not this response's status code is categorized as either "Client Error" or "Server Error".
 boolean isForbidden()
          Indicates whether or not this response's status code is "Forbidden".
 boolean isInformational()
          Indicates whether or not this response's status code is categorized as "Informational" (1xx).
 boolean isInternalServerError()
          Indicates whether or not this response's status code is "Internal Server Error".
 boolean isNoContent()
          Indicates whether or not this response's status code is "No Content".
 boolean isNotFound()
          Indicates whether or not this response's status code is "Not Found".
 boolean isNotModified()
          Indicates whether or not this response's status code is "Not Modified".
 boolean isNotSuccessful()
          Indicates whether or not this response's status code is categorized as one of "Informational", "Redirection", "Client Error" or "Server Error".
 boolean isOk()
          Indicates whether or not this response's status code is "OK".
 boolean isRedirection()
          Indicates whether or not this response's status code is categorized as "Redirection" (3xx).
 boolean isSeeOther()
          Indicates whether or not this response's status code is "See Other".
 boolean isServerError()
          Indicates whether or not this response's status code is categorized as "Server Error" (5xx).
 boolean isServiceUnavailable()
          Indicates whether or not this response's status code is "Service Unavailable".
 boolean isSuccessful()
          Indicates whether or not this response's status code is categorized as "Successful" (2xx).
 boolean isUnauthorized()
          Indicates whether or not this response's status code is "Unauthorized".
 Response setContentCharset(java.lang.String contentCharset)
          Sets the charset for this object's entity, if any.
 Response setContentType(java.lang.String contentType)
          Sets the IANA media type, for the current entity, if any.
 Response setEntity(java.lang.String entity)
          Sets this object's entity stream from a string.
 Response setEntityStream(java.io.InputStream entityStream)
          Sets this object's entity as an input stream.
 Response setEntityStream(java.io.InputStream entityStream, java.lang.String encoding)
          Sets this object's entity as an input stream, encoded with the specified charset.
 Response setHeader(java.lang.String name, java.lang.String value)
          Sets an HTTP header on this object.
 Response setHeaders(java.util.Map<java.lang.String,java.lang.String> headers)
          Copies the specified map of HTTP headers into this object.
 Response setStatusCode(int statusCode)
          Sets the status code of the response.
 Response setStatusText(java.lang.String statusText)
          Sets the status text of the response.
 
Methods inherited from interface com.atlassian.httpclient.api.Message
getContentCharset, getContentType, getEntity, getEntityStream, getHeader, getHeaders, hasEntity, hasReadEntity, isFrozen
 

Method Detail

getStatusCode

int getStatusCode()
Gets the status code of the response.

Returns:
The status code

setStatusCode

Response setStatusCode(int statusCode)
Sets the status code of the response.

Parameters:
statusCode - The status code
Returns:
This object, for builder-stye chaining

getStatusText

java.lang.String getStatusText()
Gets the status text of the response.

Returns:
The status text

setStatusText

Response setStatusText(java.lang.String statusText)
Sets the status text of the response.

Parameters:
statusText - The status text
Returns:
This object, for builder-style chaining

isInformational

boolean isInformational()
Indicates whether or not this response's status code is categorized as "Informational" (1xx).

Returns:
True if status code gte 100 and lt 200

isSuccessful

boolean isSuccessful()
Indicates whether or not this response's status code is categorized as "Successful" (2xx).

Returns:
True if status code gte 200 and lt 300

isOk

boolean isOk()
Indicates whether or not this response's status code is "OK".

Returns:
True if status code is 200

isCreated

boolean isCreated()
Indicates whether or not this response's status code is "Created".

Returns:
True if status code is 201

isNoContent

boolean isNoContent()
Indicates whether or not this response's status code is "No Content".

Returns:
True if status code is 204

isRedirection

boolean isRedirection()
Indicates whether or not this response's status code is categorized as "Redirection" (3xx).

Returns:
True if status code gte 300 and lt 400

isSeeOther

boolean isSeeOther()
Indicates whether or not this response's status code is "See Other".

Returns:
True if status code is 303

isNotModified

boolean isNotModified()
Indicates whether or not this response's status code is "Not Modified".

Returns:
True if status code is 304

isClientError

boolean isClientError()
Indicates whether or not this response's status code is categorized as "Client Error" (4xx).

Returns:
True if status code gte 400 and lt 500

isBadRequest

boolean isBadRequest()
Indicates whether or not this response's status code is "Bad Request".

Returns:
True if status code is 400

isUnauthorized

boolean isUnauthorized()
Indicates whether or not this response's status code is "Unauthorized".

Returns:
True if status code is 401

isForbidden

boolean isForbidden()
Indicates whether or not this response's status code is "Forbidden".

Returns:
True if status code is 403

isNotFound

boolean isNotFound()
Indicates whether or not this response's status code is "Not Found".

Returns:
True if status code is 404

isConflict

boolean isConflict()
Indicates whether or not this response's status code is "Conflict".

Returns:
True if status code is 409

isServerError

boolean isServerError()
Indicates whether or not this response's status code is categorized as "Server Error" (5xx).

Returns:
True if status code gte 500 and lt 600

isInternalServerError

boolean isInternalServerError()
Indicates whether or not this response's status code is "Internal Server Error".

Returns:
True if status code is 500

isServiceUnavailable

boolean isServiceUnavailable()
Indicates whether or not this response's status code is "Service Unavailable".

Returns:
True if status code is 503

isError

boolean isError()
Indicates whether or not this response's status code is categorized as either "Client Error" or "Server Error".

Returns:
True if either of isClientError() or isServerError() is true

isNotSuccessful

boolean isNotSuccessful()
Indicates whether or not this response's status code is categorized as one of "Informational", "Redirection", "Client Error" or "Server Error".

Returns:
True if one of isInformational(), isRedirection() or isError() is true

setContentType

Response setContentType(java.lang.String contentType)
Description copied from interface: Message
Sets the IANA media type, for the current entity, if any. If the contentType argument also contains charset information, this method will have the side effect of parsing the charset out and storing the component parts independently. The method getContentCharset() can be used to retrieve extracted content charset, if present, and getHeader("Content-Type") can be used to retrieve the entire Content-Type header, complete with charset information, if set. The content type property is required when an entity is present.

Specified by:
setContentType in interface Message
Parameters:
contentType - An IANA media type with optional charset information
Returns:
This object, for builder-style chaining

setContentCharset

Response setContentCharset(java.lang.String contentCharset)
Description copied from interface: Message
Sets the charset for this object's entity, if any. This value is ignored during headeer access if no entity is present or if the content type property is not set.

Specified by:
setContentCharset in interface Message
Parameters:
contentCharset - The entity's charset value, or null
Returns:
This object, for builder-style chaining

setHeaders

Response setHeaders(java.util.Map<java.lang.String,java.lang.String> headers)
Description copied from interface: Message
Copies the specified map of HTTP headers into this object. It will also parse any included Content-Type header into its constituent parts of IANA media type and content charset, updating those properties as appropriate.

Specified by:
setHeaders in interface Message
Parameters:
headers - A map of HTTP headers
Returns:
This object, for builder-style chaining

setHeader

Response setHeader(java.lang.String name,
                   java.lang.String value)
Description copied from interface: Message
Sets an HTTP header on this object. If the header's name is "Content-Type", the value will be parsed into this object's content type and content charset properties, as appropriate.

Specified by:
setHeader in interface Message
Parameters:
name - The name of the header to be set
value - The value of the header to be set
Returns:
This object, for builder-style chaining

setEntity

Response setEntity(java.lang.String entity)
Description copied from interface: Message
Sets this object's entity stream from a string. Using this method of setting the entity automatically sets this object's content charset property to "UTF-8" if the entity is not null.

Specified by:
setEntity in interface Message
Parameters:
entity - An entity string
Returns:
This object, for builder-style chaining

setEntityStream

Response setEntityStream(java.io.InputStream entityStream,
                         java.lang.String encoding)
Description copied from interface: Message
Sets this object's entity as an input stream, encoded with the specified charset. Invocations of this method reset this object's hasReadEntity() state to false. This method should only be called for entity streams targetting textual media types -- that is, it's nonsensical to set the charset of an entity stream for binary media types (e.g. image/*, etc).

Specified by:
setEntityStream in interface Message
Parameters:
entityStream - An entity input stream ready to be read
encoding - The charset in which the entity stream is encoded
Returns:
This object, for builder-style chaining

setEntityStream

Response setEntityStream(java.io.InputStream entityStream)
Description copied from interface: Message
Sets this object's entity as an input stream. Invocations of this method reset this object's hasReadEntity() state to false. It is recommended to also set this object's content charset property when setting an entity stream for a textual media type (or using the overloaded form that takes both the entity stream and charset in the same call). Clients of this object should assume the HTTP standard of ISO-8859-1 (latin-1) for the content charset property if a textual media type is set but no explcit charset was provided for this message. A charset should NOT be provided for entity streams targetting binary media types.

Specified by:
setEntityStream in interface Message
Parameters:
entityStream - An entity input stream ready to be read
Returns:
This object, for builder-style chaining


Copyright © 2012 Atlassian. All Rights Reserved.