CoreUtils/IMFResponse.h

98 lines
2.4 KiB
C++

#ifndef __IMFResponse_h__
#define __IMFResponse_h__
#include "includes"
#include "IMFMessage.h"
namespace coreutils {
///
/// IMFResponse
///
/// Use this object to build a response output for a protocol that uses headers
/// and responses as the main communications protocol.
///
class IMFResponse : public IMFMessage {
public:
enum Mode { LENGTH, STREAMING };
///
/// The constructor for the object.
///
IMFResponse();
///
/// The destructor for the object.
///
~IMFResponse();
///
/// Returns the response generated from the contained values that
/// do not return a content length. Using this constructor ensures
/// a zero length Content-Length value.
///
/// @return the complete response string to send to client.
///
std::stringstream getResponse(Mode mode = LENGTH);
///
/// Returns the response plus the content passed as a parameter.
///
/// This method will automatically generate the proper Content-Length
/// value for the response.
///
/// @param content the content that will be provided on the response
/// message to the client.
///
/// @return the complete response string to send to client.
///
std::stringstream getResponse(std::stringstream &content, Mode mode = LENGTH);
///
/// Sets the protocol value for the response message. The protocol
/// should match the header received.
///
/// @param protocol the protocol value to return in response.
///
void setProtocol(ZString protocol);
///
/// Sets the return code value for the response.
///
/// @param code the response code value to return in the response.
///
void setCode(ZString code);
///
/// Sets the return code string value for the response.
///
/// @param text the text value for the response code to return on
/// the response.
///
void setText(ZString text);
void setCookie(ZString key, ZString data);
private:
ZString protocol;
ZString code;
ZString text;
const char *CRLF = "\r\n";
};
}
#endif