fhq-server  v0.2.33
Documentation for fhq-server. FreeHackQuest is an open source platform for competitions of computer security.
wsjcpp_light_web_http_response.h
Go to the documentation of this file.
1 #ifndef WSJCPP_LIGHT_WEB_HTTP_RESPONSE_H
2 #define WSJCPP_LIGHT_WEB_HTTP_RESPONSE_H
3 
4 #include <string>
5 #include <map>
6 #include <json.hpp>
7 
8 // ---------------------------------------------------------------------
9 
11  public:
12  static std::map<int, std::string> *g_mapReponseDescription;
13 
14  WsjcppLightWebHttpResponse(int nSockFd);
15 
24 
26  WsjcppLightWebHttpResponse &cacheSec(int nCacheSec);
27 
28  void sendText(const std::string &sBody);
29  void sendJson(const nlohmann::json &json);
30  void sendEmpty();
31  void sendOptions(const std::string &sOptions);
32  void sendFile(const std::string &sFilePath);
33  void sendBuffer(const std::string &sFilePath, const char *pBuffer, const int nBufferSize);
34 
35  private:
36  std::string prepareHeaders(int nLength);
37  std::string detectTypeOfFile(const std::string &sFilePath);
38 
39  std::string TAG;
40 
41  int m_nSockFd;
42  bool m_bClosed;
44  std::string m_sDataType;
45  std::string m_sCacheControl;
46  std::string m_sLastModified;
47 };
48 
49 #endif // WSJCPP_LIGHT_WEB_HTTP_RESPONSE_H
50 
51 
bool m_bClosed
Definition: wsjcpp_light_web_http_response.h:42
std::string m_sCacheControl
Definition: wsjcpp_light_web_http_response.h:45
WsjcppLightWebHttpResponse & requestTimeout()
Definition: wsjcpp_light_web_http_response.cpp:90
void sendFile(const std::string &sFilePath)
Definition: wsjcpp_light_web_http_response.cpp:223
std::string prepareHeaders(int nLength)
Definition: wsjcpp_light_web_http_response.cpp:111
std::string m_sDataType
Definition: wsjcpp_light_web_http_response.h:44
void sendEmpty()
Definition: wsjcpp_light_web_http_response.cpp:197
WsjcppLightWebHttpResponse & notFound()
Definition: wsjcpp_light_web_http_response.cpp:62
Definition: wsjcpp_light_web_http_response.h:10
WsjcppLightWebHttpResponse & noCache()
Definition: wsjcpp_light_web_http_response.cpp:97
int m_nSockFd
Definition: wsjcpp_light_web_http_response.h:41
WsjcppLightWebHttpResponse & internalServerError()
Definition: wsjcpp_light_web_http_response.cpp:76
WsjcppLightWebHttpResponse & cacheSec(int nCacheSec)
Definition: wsjcpp_light_web_http_response.cpp:104
void sendBuffer(const std::string &sFilePath, const char *pBuffer, const int nBufferSize)
Definition: wsjcpp_light_web_http_response.cpp:252
WsjcppLightWebHttpResponse(int nSockFd)
Definition: wsjcpp_light_web_http_response.cpp:16
std::string detectTypeOfFile(const std::string &sFilePath)
Definition: wsjcpp_light_web_http_response.cpp:126
WsjcppLightWebHttpResponse & ok()
Definition: wsjcpp_light_web_http_response.cpp:41
void sendText(const std::string &sBody)
Definition: wsjcpp_light_web_http_response.cpp:157
WsjcppLightWebHttpResponse & notImplemented()
Definition: wsjcpp_light_web_http_response.cpp:83
WsjcppLightWebHttpResponse & payloadTooLarge()
Definition: wsjcpp_light_web_http_response.cpp:69
WsjcppLightWebHttpResponse & forbidden()
Definition: wsjcpp_light_web_http_response.cpp:55
std::string TAG
Definition: wsjcpp_light_web_http_response.h:39
static std::map< int, std::string > * g_mapReponseDescription
Definition: wsjcpp_light_web_http_response.h:12
WsjcppLightWebHttpResponse & badRequest()
Definition: wsjcpp_light_web_http_response.cpp:48
void sendOptions(const std::string &sOptions)
Definition: wsjcpp_light_web_http_response.cpp:203
std::string m_sLastModified
Definition: wsjcpp_light_web_http_response.h:46
int m_nResponseCode
Definition: wsjcpp_light_web_http_response.h:43
void sendJson(const nlohmann::json &json)
Definition: wsjcpp_light_web_http_response.cpp:177