Initial repository load.
This commit is contained in:
commit
604e196fbb
32 files changed
+945
No files matched your search
@@ -0,0 +1,97 @@
|
||||
#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::string 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::string getResponse(std::string 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(std::string protocol);
|
||||
|
||||
///
|
||||
/// Sets the return code value for the response.
|
||||
///
|
||||
/// @param code the response code value to return in the response.
|
||||
///
|
||||
|
||||
void setCode(std::string 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(std::string text);
|
||||
|
||||
void setCookie(std::string name, std::string value);
|
||||
|
||||
private:
|
||||
std::string protocol;
|
||||
std::string code;
|
||||
std::string text;
|
||||
|
||||
std::string CRLF = "\r\n";
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user