|
- #pragma once
-
- #include "response.h"
-
- namespace cppmicrohttpd
- {
-
- struct callback_response
- : public response
- {
- public:
- /**
- * @brief Constructor.
- *
- * @param[in] p_request Request this response belongs to.
- * @param[in] p_chunk_size Size of the chunk to use for reading data from the callback.
- * @param[in] p_response_size Total size of the response (-1 for unknown)
- */
- inline callback_response(
- const request_t& p_request,
- size_t p_chunk_size,
- ssize_t p_response_size = -1);
-
- private:
- /**
- * @brief Handle read requests from MHD.
- *
- * @param[in] p_pos Total position inside the response data stream.
- * @param[in] p_buf Buffer to write requested data to.
- * @param[in] p_max Max number of bytes to write to p_buf.
- *
- * @return Number of bytes stored in buf.
- *
- * @retval MHD_CONTENT_READER_END_OF_STREAM If the stream is finished.
- * @retval MHD_CONTENT_READER_END_WITH_ERROR If an error occured.
- */
- virtual ssize_t read_content(
- uint64_t p_pos,
- char * p_buf,
- size_t p_max) = 0;
-
- private:
- /**
- * @brief Handle read requests from MHD.
- *
- * @param[in] cls User pointer that was passed to the MHD response.
- * @param[in] pos Total position inside the response data stream.
- * @param[in] buf Buffer to write requested data to.
- * @param[in] max Max number of bytes to write to buf.
- *
- * @return Number of bytes stored in buf.
- *
- * @retval MHD_CONTENT_READER_END_OF_STREAM If the stream is finished.
- * @retval MHD_CONTENT_READER_END_WITH_ERROR If an error occured.
- */
- static ssize_t mhd_content_reader_callback(
- void * cls,
- uint64_t pos,
- char * buf,
- size_t max);
- };
-
- }
|