10 #ifndef COMPONENTS_CPP_UTILS_HTTPRESPONSE_H_
11 #define COMPONENTS_CPP_UTILS_HTTPRESPONSE_H_
14 #include "HttpRequest.h"
18 static const int HTTP_STATUS_CONTINUE;
19 static const int HTTP_STATUS_SWITCHING_PROTOCOL;
20 static const int HTTP_STATUS_OK;
21 static const int HTTP_STATUS_MOVED_PERMANENTLY;
22 static const int HTTP_STATUS_BAD_REQUEST;
23 static const int HTTP_STATUS_UNAUTHORIZED;
24 static const int HTTP_STATUS_FORBIDDEN;
25 static const int HTTP_STATUS_NOT_FOUND;
26 static const int HTTP_STATUS_METHOD_NOT_ALLOWED;
27 static const int HTTP_STATUS_INTERNAL_SERVER_ERROR;
28 static const int HTTP_STATUS_NOT_IMPLEMENTED;
29 static const int HTTP_STATUS_SERVICE_UNAVAILABLE;
34 void addHeader(std::string name, std::string value);
37 std::map<std::string, std::string> getHeaders();
39 void sendData(uint8_t* pData,
size_t size);
40 void setStatus(
int status, std::string message);
41 void sendFile(std::string fileName,
size_t bufSize = 4 * 1024);
44 bool m_headerCommitted;
46 std::map<std::string, std::string> m_responseHeaders;
48 std::string m_statusMessage;
void setStatus(int status, std::string message)
Set the status code that is to be sent back to the client. When a client makes a request, the response contains a status. This call sets the status that will be sent back to the client.
Definition: HttpResponse.cpp:179
std::string getHeader(std::string name)
Get the value of the named header.
Definition: HttpResponse.cpp:71
void sendData(std::string data)
Send data to the partner. Send some data to the partner. If we haven't yet sent the HTTP header then ...
Definition: HttpResponse.cpp:88
void addHeader(std::string name, std::string value)
Add a header to the response message. If the response has already been committed then ignore this req...
Definition: HttpResponse.cpp:46
Definition: HttpRequest.h:19
void close()
Close the response. We close the response. If we haven't yet sent the header, we send that now and th...
Definition: HttpResponse.cpp:57
Definition: HttpResponse.h:16