BMA Server Framework
Public Types | Public Member Functions | List of all members
core::Response Class Reference

#include <Response.h>

Inheritance diagram for core::Response:
Inheritance graph
[legend]
Collaboration diagram for core::Response:
Collaboration graph
[legend]

Public Types

enum  Mode { LENGTH, STREAMING }
 

Public Member Functions

 Response ()
 
 ~Response ()
 
std::string getResponse (Mode mode)
 
std::string getResponse (std::string content, Mode mode)
 
void setProtocol (std::string protocol)
 
void setCode (std::string code)
 
void setText (std::string text)
 
void setMimeType (std::string mimeType)
 
void addHeaderItem (std::string key, std::string value)
 

Additional Inherited Members

- Public Attributes inherited from core::Object
std::string name
 
std::string tag
 

Detailed Description

Response

Use this object to build a response output for a protocol that uses headers and responses as the main communications protocol.

Constructor & Destructor Documentation

◆ Response()

core::Response::Response ( )

The constructor for the object.

◆ ~Response()

core::Response::~Response ( )

The destructor for the object.

Member Function Documentation

◆ getResponse() [1/2]

std::string core::Response::getResponse ( Mode  mode)

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.

Returns
the complete response string to send to client.

◆ getResponse() [2/2]

std::string core::Response::getResponse ( std::string  content,
Mode  mode 
)

Returns the response plus the content passed as a parameter.

This method will automatically generate the proper Content-Length value for the response.

Parameters
contentthe content that will be provided on the response message to the client.
Returns
the complete response string to send to client.

◆ setCode()

void core::Response::setCode ( std::string  code)

Sets the return code value for the response.

Parameters
codethe response code value to return in the response.

◆ setMimeType()

void core::Response::setMimeType ( std::string  mimeType)

Specifies the type of data that will be returned in this response.

Parameters
mimeTypethe mime type for the data.

◆ setProtocol()

void core::Response::setProtocol ( std::string  protocol)

Sets the protocol value for the response message. The protocol should match the header received.

Parameters
protocolthe protocol value to return in response.

◆ setText()

void core::Response::setText ( std::string  text)

Sets the return code string value for the response.

Parameters
textthe text value for the response code to return on the response.

The documentation for this class was generated from the following files: