POSTHandler.cpp 635 B

12345678910111213141516171819202122232425262728
  1. //
  2. // Created by David Mike on 2020/2/26.
  3. //
  4. #include "POSTHandler.hpp"
  5. namespace greatbridf
  6. {
  7. namespace Handler
  8. {
  9. void POST(HTTPRequest& request, std::iostream& stream, HTTPResponse& response)
  10. {
  11. response.setResponseCode(200);
  12. auto length = request.bodySize();
  13. if (length > 0)
  14. {
  15. response.setHeader("Content-Length", length);
  16. stream << response;
  17. redirectStream(stream, stream, length);
  18. }
  19. else
  20. {
  21. stream << response << std::flush;
  22. }
  23. }
  24. }
  25. }