TextResponseData.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. //
  2. // Created by xcbosa on 2023/1/28.
  3. //
  4. #pragma once
  5. #include "ResponseData.h"
  6. #include "utils-private.h"
  7. using namespace std;
  8. namespace xc {
  9. namespace utils {
  10. class TextResponseData: public ResponseData {
  11. public:
  12. TextResponseData(int statusCode, string body);
  13. TextResponseData(int statusCode, string body, string contentType);
  14. void setHeader(string headerName, string value);
  15. void removeHeader(string headerName);
  16. string getHeader(string headerName);
  17. void setContentType(string mimeType);
  18. void setStatusCode(int statusCode);
  19. int getStatusCode() const;
  20. void setBody(string body);
  21. string getBody();
  22. void writeTo(::FILE *fp) const;
  23. void writeResponseBodyTo(ostream &fp) const;
  24. void addCookie(string key, string value);
  25. private:
  26. int statusCode;
  27. map<string, string> headers;
  28. map<string, string> cookies;
  29. string body;
  30. };
  31. } // xc
  32. } // utils