com.continuuity.http
Interface HttpResponder

All Known Implementing Classes:
BasicHttpResponder, InternalHttpResponder

public interface HttpResponder

HttpResponder is used to send response back to clients.


Method Summary
 void sendByteArray(org.jboss.netty.handler.codec.http.HttpResponseStatus status, byte[] bytes, com.google.common.collect.Multimap<String,String> headers)
          Send a response containing raw bytes.
 void sendBytes(org.jboss.netty.handler.codec.http.HttpResponseStatus status, ByteBuffer buffer, com.google.common.collect.Multimap<String,String> headers)
          Sends a response containing raw bytes.
 void sendChunk(org.jboss.netty.buffer.ChannelBuffer content)
          Add a chunk of data to the response.
 void sendChunkEnd()
          Called after all chunks are done.
 void sendChunkStart(org.jboss.netty.handler.codec.http.HttpResponseStatus status, com.google.common.collect.Multimap<String,String> headers)
          Respond to the client saying the response will be in chunks.
 void sendContent(org.jboss.netty.handler.codec.http.HttpResponseStatus status, org.jboss.netty.buffer.ChannelBuffer content, String contentType, com.google.common.collect.Multimap<String,String> headers)
          Send response back to client.
 void sendError(org.jboss.netty.handler.codec.http.HttpResponseStatus status, String errorMessage)
          Sends error message back to the client.
 void sendFile(File file, com.google.common.collect.Multimap<String,String> headers)
          Sends a file content back to client.
 void sendJson(org.jboss.netty.handler.codec.http.HttpResponseStatus status, Object object)
          Sends json response back to the client.
 void sendJson(org.jboss.netty.handler.codec.http.HttpResponseStatus status, Object object, Type type)
          Sends json response back to the client.
 void sendJson(org.jboss.netty.handler.codec.http.HttpResponseStatus status, Object object, Type type, com.google.gson.Gson gson)
          Sends json response back to the client using the given gson object.
 void sendStatus(org.jboss.netty.handler.codec.http.HttpResponseStatus status)
          Send only a status code back to client without any content.
 void sendStatus(org.jboss.netty.handler.codec.http.HttpResponseStatus status, com.google.common.collect.Multimap<String,String> headers)
          Send only a status code back to client without any content.
 void sendString(org.jboss.netty.handler.codec.http.HttpResponseStatus status, String data)
          Send a string response back to the http client.
 

Method Detail

sendJson

void sendJson(org.jboss.netty.handler.codec.http.HttpResponseStatus status,
              Object object)
Sends json response back to the client.

Parameters:
status - Status of the response.
object - Object that will be serialized into Json and sent back as content.

sendJson

void sendJson(org.jboss.netty.handler.codec.http.HttpResponseStatus status,
              Object object,
              Type type)
Sends json response back to the client.

Parameters:
status - Status of the response.
object - Object that will be serialized into Json and sent back as content.
type - Type of object.

sendJson

void sendJson(org.jboss.netty.handler.codec.http.HttpResponseStatus status,
              Object object,
              Type type,
              com.google.gson.Gson gson)
Sends json response back to the client using the given gson object.

Parameters:
status - Status of the response.
object - Object that will be serialized into Json and sent back as content.
type - Type of object.
gson - Gson object for serialization.

sendString

void sendString(org.jboss.netty.handler.codec.http.HttpResponseStatus status,
                String data)
Send a string response back to the http client.

Parameters:
status - status of the Http response.
data - string data to be sent back.

sendStatus

void sendStatus(org.jboss.netty.handler.codec.http.HttpResponseStatus status)
Send only a status code back to client without any content.

Parameters:
status - status of the Http response.

sendStatus

void sendStatus(org.jboss.netty.handler.codec.http.HttpResponseStatus status,
                com.google.common.collect.Multimap<String,String> headers)
Send only a status code back to client without any content.

Parameters:
status - status of the Http response.
headers - Headers to send.

sendByteArray

void sendByteArray(org.jboss.netty.handler.codec.http.HttpResponseStatus status,
                   byte[] bytes,
                   com.google.common.collect.Multimap<String,String> headers)
Send a response containing raw bytes. Sets "application/octet-stream" as content type header.

Parameters:
status - status of the Http response.
bytes - bytes to be sent back.
headers - headers to be sent back. This will overwrite any headers set by the framework.

sendBytes

void sendBytes(org.jboss.netty.handler.codec.http.HttpResponseStatus status,
               ByteBuffer buffer,
               com.google.common.collect.Multimap<String,String> headers)
Sends a response containing raw bytes. Default content type is "application/octet-stream", but can be overridden in the headers.

Parameters:
status - status of the Http response
buffer - bytes to send
headers - Headers to send.

sendError

void sendError(org.jboss.netty.handler.codec.http.HttpResponseStatus status,
               String errorMessage)
Sends error message back to the client.

Parameters:
status - Status of the response.
errorMessage - Error message sent back to the client.

sendChunkStart

void sendChunkStart(org.jboss.netty.handler.codec.http.HttpResponseStatus status,
                    com.google.common.collect.Multimap<String,String> headers)
Respond to the client saying the response will be in chunks. Add chunks to response using sendChunk(ChannelBuffer) and sendChunkEnd().

Parameters:
status - the status code to respond with. Defaults to 200-OK if null.
headers - additional headers to send with the response. May be null.

sendChunk

void sendChunk(org.jboss.netty.buffer.ChannelBuffer content)
Add a chunk of data to the response. sendChunkStart(HttpResponseStatus, Multimap) should be called before calling this method. sendChunkEnd() should be called after all chunks are done.

Parameters:
content - the chunk of content to send

sendChunkEnd

void sendChunkEnd()
Called after all chunks are done. This keeps the connection alive unless specified otherwise in the original request.


sendContent

void sendContent(org.jboss.netty.handler.codec.http.HttpResponseStatus status,
                 org.jboss.netty.buffer.ChannelBuffer content,
                 String contentType,
                 com.google.common.collect.Multimap<String,String> headers)
Send response back to client.

Parameters:
status - Status of the response.
content - Content to be sent back.
contentType - Type of content.
headers - Headers to be sent back.

sendFile

void sendFile(File file,
              com.google.common.collect.Multimap<String,String> headers)
Sends a file content back to client.

Parameters:
file -
headers -


Copyright 2013 Continuuity, Inc. Licensed under the Apache License, Version 2.0