net.officefloor.plugin.socket.server.http
Interface HttpResponse

All Known Implementing Classes:
HttpResponseImpl

public interface HttpResponse

HttpResponse for the ServerHttpConnection.

Author:
Daniel Sagenschneider

Method Summary
 HttpHeader addHeader(String name, String value)
           Adds a HttpHeader for the response.
 OutputBufferStream getBody()
           Obtains the OutputBufferStream to write the body of the response.
 HttpHeader getHeader(String name)
          Obtains the first HttpHeader by the name.
 HttpHeader[] getHeaders()
          Obtains all the HttpHeader instances for the response.
 void removeHeader(HttpHeader header)
          Removes the particular HttpHeader from the response.
 void removeHeaders(String name)
           Removes all HttpHeader instances by the name.
 void send()
          Sends this HttpResponse.
 void setStatus(int status)
           Specifies the status of the response with the default status message.
 void setStatus(int status, String statusMessage)
          Specifies the status of the response including specifying the status human readable message.
 void setVersion(String version)
           Allows specifying the HTTP version on the response.
 

Method Detail

setVersion

void setVersion(String version)

Allows specifying the HTTP version on the response. Values should be either HTTP/1.0 or HTTP/1.1.

This defaults to value on HttpRequest.

Parameters:
version - HTTP version.

setStatus

void setStatus(int status)

Specifies the status of the response with the default status message.

This defaults to 200 assuming the request was processed successfully.

Parameters:
status - Status of the response.

setStatus

void setStatus(int status,
               String statusMessage)
Specifies the status of the response including specifying the status human readable message.

Parameters:
status - Status of the response.
statusMessage - Human readable status message.
See Also:
setStatus(int)

addHeader

HttpHeader addHeader(String name,
                     String value)

Adds a HttpHeader for the response.

HttpHeader instances are provided on the response in the order they are added.

Parameters:
name - Name of HttpHeader.
value - Value of HttpHeader.
Returns:
HttpHeader instance added.

getHeader

HttpHeader getHeader(String name)
Obtains the first HttpHeader by the name.

Parameters:
name - Name of the HttpHeader.
Returns:
First HttpHeader by the name.

getHeaders

HttpHeader[] getHeaders()
Obtains all the HttpHeader instances for the response.

Returns:
All the HttpHeader instances for the response.

removeHeader

void removeHeader(HttpHeader header)
Removes the particular HttpHeader from the response.

Parameters:
header - HttpHeader to be removed from the response.

removeHeaders

void removeHeaders(String name)

Removes all HttpHeader instances by the name.

This method compliments addHeader(String, String) to allow adding a new single HttpHeader instance by name.

Parameters:
name - Name of the HttpHeader instances to remove.

getBody

OutputBufferStream getBody()

Obtains the OutputBufferStream to write the body of the response.

Closing the returned OutputBufferStream is similar to calling send().

Returns:
OutputBufferStream to write the body of the response.
See Also:
send()

send

void send()
          throws IOException
Sends this HttpResponse. After calling this getBody() is closed and the corresponding HttpRequest.getBody() is closed.

Throws:
IOException - If fails to send this HttpResponse.


Copyright © 2005-2011. All Rights Reserved.