Groovy Documentation

betamax.proxy
[Groovy] Interface Message


interface Message

An abstraction of an HTTP request or response. Implementations can be backed by any sort of underlying implementation.


Method Summary
java.io.InputStream getBodyAsBinary()

Returns the message body in its raw binary form.

java.io.Reader getBodyAsText()

Returns the message body as a string.

java.lang.String getHeader(java.lang.String name)

@param name an HTTP header name.

java.util.Map getHeaders()

@return all HTTP headers attached to this message.

boolean hasBody()

@return `true` if the message currently contains a body, `false` otherwise.

 

Method Detail

getBodyAsBinary

java.io.InputStream getBodyAsBinary()
Returns the message body in its raw binary form. If the body is encoded then the implementation should return the encoded data _without_ decoding it first.
throws:
IllegalStateException if the message does not have a body.
Returns:
the message body as binary data.


getBodyAsText

java.io.Reader getBodyAsText()
Returns the message body as a string. If the message body is encoded then the implementation must decode it before converting it to a string.
throws:
IllegalStateException if the message does not have a body.
Returns:
the message body as a string.


getHeader

java.lang.String getHeader(java.lang.String name)
Parameters:
name - an HTTP header name.
Returns:
the comma-separated values for all HTTP headers with the specified name or `null` if there are no headers with that name.


getHeaders

java.util.Map getHeaders()
Returns:
all HTTP headers attached to this message.


hasBody

boolean hasBody()
Returns:
`true` if the message currently contains a body, `false` otherwise.


 

Groovy Documentation