選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

64 行
2.1 KiB

  1. #pragma once
  2. #include "response.h"
  3. namespace cppmicrohttpd
  4. {
  5. struct callback_response
  6. : public response
  7. {
  8. public:
  9. /**
  10. * @brief Constructor.
  11. *
  12. * @param[in] p_request Request this response belongs to.
  13. * @param[in] p_chunk_size Size of the chunk to use for reading data from the callback.
  14. * @param[in] p_response_size Total size of the response (-1 for unknown)
  15. */
  16. inline callback_response(
  17. const request_t& p_request,
  18. size_t p_chunk_size,
  19. ssize_t p_response_size = -1);
  20. private:
  21. /**
  22. * @brief Handle read requests from MHD.
  23. *
  24. * @param[in] p_pos Total position inside the response data stream.
  25. * @param[in] p_buf Buffer to write requested data to.
  26. * @param[in] p_max Max number of bytes to write to p_buf.
  27. *
  28. * @return Number of bytes stored in buf.
  29. *
  30. * @retval MHD_CONTENT_READER_END_OF_STREAM If the stream is finished.
  31. * @retval MHD_CONTENT_READER_END_WITH_ERROR If an error occured.
  32. */
  33. virtual ssize_t read_content(
  34. uint64_t p_pos,
  35. char * p_buf,
  36. size_t p_max) = 0;
  37. private:
  38. /**
  39. * @brief Handle read requests from MHD.
  40. *
  41. * @param[in] cls User pointer that was passed to the MHD response.
  42. * @param[in] pos Total position inside the response data stream.
  43. * @param[in] buf Buffer to write requested data to.
  44. * @param[in] max Max number of bytes to write to buf.
  45. *
  46. * @return Number of bytes stored in buf.
  47. *
  48. * @retval MHD_CONTENT_READER_END_OF_STREAM If the stream is finished.
  49. * @retval MHD_CONTENT_READER_END_WITH_ERROR If an error occured.
  50. */
  51. static ssize_t mhd_content_reader_callback(
  52. void * cls,
  53. uint64_t pos,
  54. char * buf,
  55. size_t max);
  56. };
  57. }