BinaryResponseData.h 853 B

12345678910111213141516171819202122232425262728293031
  1. //
  2. // Created by xcbosa on 2023/1/28.
  3. //
  4. #pragma once
  5. #include "utils-private.h"
  6. #include "ResponseData.h"
  7. namespace xc {
  8. namespace utils {
  9. class BinaryResponseData: public ResponseData {
  10. public:
  11. BinaryResponseData(int statusCode, uint8_t *body, int bodySize, string contentType);
  12. BinaryResponseData(int statusCode, string filePath, string contentType);
  13. void writeTo(::FILE *fp) const;
  14. void writeResponseBodyTo(ostream &fp) const;
  15. void setHeader(string headerName, string value);
  16. bool isWriteFromFile() const;
  17. bool isWriteFromMemory() const;
  18. private:
  19. int statusCode;
  20. map<string, string> headers;
  21. uint8_t *body;
  22. string filePath;
  23. int bodySize;
  24. };
  25. } // xc
  26. } // utils