@@ -805,14 +805,32 @@ void envoy_dynamic_module_callback_http_send_response(
805805// ------------------- HTTP Request/Response body callbacks --------------------
806806
807807/* *
808- * envoy_dynamic_module_callback_http_get_request_body_vector is called by the module to get the
809- * request body as a vector of buffers. The body is returned as an array of
808+ * NOTE: Envoy will handle the request/response as a stream of data. Therefore, the body may not be
809+ * available in its entirety before the end of stream flag is set. The Envoy will provides both the
810+ * received body (body pieces received in the latest event) and the buffered body (body pieces
811+ * buffered so far) to the module. The module should be aware of this distinction when processing
812+ * the body.
813+ *
814+ * NOTE: The received body could only be available during the request/response body
815+ * event hooks (the envoy_dynamic_module_on_http_filter_request_body and
816+ * envoy_dynamic_module_on_http_filter_response_body).
817+ * Outside of these hooks, the received body will be unavailable.
818+ *
819+ * NOTE: The buffered body, however, is always available. But only the latest data processing filter
820+ * in the filter chain could modify the buffered body. That is say for a given filter X, filter X
821+ * can safely modify the buffered body if and only if the filters following filter X in the filter
822+ * chain have not yet accessed the body.
823+ */
824+
825+ /* *
826+ * envoy_dynamic_module_callback_http_get_received_request_body_vector is called by the module to
827+ * get the current request body as a vector of buffers. The body is returned as an array of
810828 * envoy_dynamic_module_type_envoy_buffer.
811829 *
812830 * PRECONDITION: The module must ensure that the result_buffer_vector is valid and has enough length
813831 * to store all the buffers. The module can use
814- * envoy_dynamic_module_callback_http_get_request_body_vector_size to get the number of buffers
815- * before calling this function.
832+ * envoy_dynamic_module_callback_http_get_received_request_body_vector_size to get the number of
833+ * buffers before calling this function.
816834 *
817835 * @param filter_envoy_ptr is the pointer to the DynamicModuleHttpFilter object of the
818836 * corresponding HTTP filter.
@@ -821,82 +839,179 @@ void envoy_dynamic_module_callback_http_send_response(
821839 * end of the current event hook unless the setter callback is called.
822840 * @return true if the body is available, false otherwise.
823841 */
824- bool envoy_dynamic_module_callback_http_get_request_body_vector (
842+ bool envoy_dynamic_module_callback_http_get_received_request_body_vector (
825843 envoy_dynamic_module_type_http_filter_envoy_ptr filter_envoy_ptr,
826844 envoy_dynamic_module_type_envoy_buffer* result_buffer_vector);
827845
828846/* *
829- * envoy_dynamic_module_callback_http_get_request_body_vector_size is called by the module to get
830- * the number of buffers in the request body. Combined with
831- * envoy_dynamic_module_callback_http_get_request_body_vector, this can be used to iterate over all
832- * buffers in the request body.
847+ * envoy_dynamic_module_callback_http_get_buffered_request_body_vector is called by the module to
848+ * get the buffered request body as a vector of buffers. The body is returned as an array of
849+ * envoy_dynamic_module_type_envoy_buffer.
850+ *
851+ * PRECONDITION: The module must ensure that the result_buffer_vector is valid and has enough length
852+ * to store all the buffers. The module can use
853+ * envoy_dynamic_module_callback_http_get_buffered_request_body_vector_size to get the number of
854+ * buffers before calling this function.
855+ *
856+ * @param filter_envoy_ptr is the pointer to the DynamicModuleHttpFilter object of the
857+ * corresponding HTTP filter.
858+ * @param result_buffer_vector is the pointer to the array of envoy_dynamic_module_type_envoy_buffer
859+ * where the buffers of the body will be stored. The lifetime of the buffer is guaranteed until the
860+ * end of the current event hook unless the setter callback is called.
861+ * @return true if the body is available, false otherwise.
862+ */
863+ bool envoy_dynamic_module_callback_http_get_buffered_request_body_vector (
864+ envoy_dynamic_module_type_http_filter_envoy_ptr filter_envoy_ptr,
865+ envoy_dynamic_module_type_envoy_buffer* result_buffer_vector);
866+
867+ /* *
868+ * envoy_dynamic_module_callback_http_get_received_request_body_vector_size is called by the module
869+ * to get the number of buffers in the current request body. Combined with
870+ * envoy_dynamic_module_callback_http_get_received_request_body_vector, this can be used to iterate
871+ * over all buffers in the request body.
833872 *
834873 * @param filter_envoy_ptr is the pointer to the DynamicModuleHttpFilter object of the
835874 * corresponding HTTP filter.
836875 * @param size is the pointer to the variable where the number of buffers will be stored.
837876 * @return true if the body is available, false otherwise.
838877 */
839- bool envoy_dynamic_module_callback_http_get_request_body_vector_size (
878+ bool envoy_dynamic_module_callback_http_get_received_request_body_vector_size (
840879 envoy_dynamic_module_type_http_filter_envoy_ptr filter_envoy_ptr, size_t * size);
841880
842881/* *
843- * envoy_dynamic_module_callback_http_append_request_body is called by the module to append the
844- * given data to the end of the request body.
882+ * envoy_dynamic_module_callback_http_get_buffered_request_body_vector_size is called by the module
883+ * to get the number of buffers in the buffered request body. Combined with
884+ * envoy_dynamic_module_callback_http_get_buffered_request_body_vector, this can be used to iterate
885+ * over all buffers in the request body.
886+ *
887+ * @param filter_envoy_ptr is the pointer to the DynamicModuleHttpFilter object of the
888+ * corresponding HTTP filter.
889+ * @param size is the pointer to the variable where the number of buffers will be stored.
890+ * @return true if the body is available, false otherwise.
891+ */
892+ bool envoy_dynamic_module_callback_http_get_buffered_request_body_vector_size (
893+ envoy_dynamic_module_type_http_filter_envoy_ptr filter_envoy_ptr, size_t * size);
894+
895+ /* *
896+ * envoy_dynamic_module_callback_http_append_received_request_body is called by the module to append
897+ * the given data to the end of the current request body.
845898 *
846899 * @param filter_envoy_ptr is the pointer to the DynamicModuleHttpFilter object of the
847900 * corresponding HTTP filter.
848901 * @param data is the pointer to the buffer of the data to be appended.
849902 * @param length is the length of the data.
850903 * @return true if the body is available, false otherwise.
851904 */
852- bool envoy_dynamic_module_callback_http_append_request_body (
905+ bool envoy_dynamic_module_callback_http_append_received_request_body (
853906 envoy_dynamic_module_type_http_filter_envoy_ptr filter_envoy_ptr,
854907 envoy_dynamic_module_type_buffer_module_ptr data, size_t length);
855908
856909/* *
857- * envoy_dynamic_module_callback_http_drain_request_body is called by the module to drain the given
858- * number of bytes from the request body. If the number of bytes to drain is greater than
859- * the size of the body, the whole body will be drained.
910+ * envoy_dynamic_module_callback_http_append_buffered_request_body is called by the module to append
911+ * the given data to the end of the buffered request body.
912+ *
913+ * @param filter_envoy_ptr is the pointer to the DynamicModuleHttpFilter object of the
914+ * corresponding HTTP filter.
915+ * @param data is the pointer to the buffer of the data to be appended.
916+ * @param length is the length of the data.
917+ * @return true if the body is available, false otherwise.
918+ */
919+ bool envoy_dynamic_module_callback_http_append_buffered_request_body (
920+ envoy_dynamic_module_type_http_filter_envoy_ptr filter_envoy_ptr,
921+ envoy_dynamic_module_type_buffer_module_ptr data, size_t length);
922+
923+ /* *
924+ * envoy_dynamic_module_callback_http_drain_received_request_body is called by the module to drain
925+ * the given number of bytes from the current request body. If the number of bytes to drain is
926+ * greater than the size of the body, the whole body will be drained.
860927 *
861928 * @param filter_envoy_ptr is the pointer to the DynamicModuleHttpFilter object of the
862929 * corresponding HTTP filter.
863930 * @param number_of_bytes is the number of bytes to drain.
864931 * @return true if the body is available, false otherwise.
865932 */
866- bool envoy_dynamic_module_callback_http_drain_request_body (
933+ bool envoy_dynamic_module_callback_http_drain_received_request_body (
867934 envoy_dynamic_module_type_http_filter_envoy_ptr filter_envoy_ptr, size_t number_of_bytes);
868935
869936/* *
870- * This is the same as envoy_dynamic_module_callback_http_get_request_body_vector, but for the
871- * response body. See the comments on envoy_dynamic_module_callback_http_get_request_body_vector
872- * for more details.
937+ * envoy_dynamic_module_callback_http_drain_buffered_request_body is called by the module to drain
938+ * the given number of bytes from the buffered request body. If the number of bytes to drain is
939+ * greater than the size of the body, the whole body will be drained.
940+ *
941+ * @param filter_envoy_ptr is the pointer to the DynamicModuleHttpFilter object of the
942+ * corresponding HTTP filter.
943+ * @param number_of_bytes is the number of bytes to drain.
944+ * @return true if the body is available, false otherwise.
945+ */
946+ bool envoy_dynamic_module_callback_http_drain_buffered_request_body (
947+ envoy_dynamic_module_type_http_filter_envoy_ptr filter_envoy_ptr, size_t number_of_bytes);
948+
949+ /* *
950+ * This is the same as envoy_dynamic_module_callback_http_get_received_request_body_vector, but for
951+ * the current response body. See the comments on
952+ * envoy_dynamic_module_callback_http_get_received_request_body_vector for more details.
953+ */
954+ bool envoy_dynamic_module_callback_http_get_received_response_body_vector (
955+ envoy_dynamic_module_type_http_filter_envoy_ptr filter_envoy_ptr,
956+ envoy_dynamic_module_type_envoy_buffer* result_buffer_vector);
957+
958+ /* *
959+ * This is the same as envoy_dynamic_module_callback_http_get_buffered_request_body_vector, but for
960+ * the buffered response body. See the comments on
961+ * envoy_dynamic_module_callback_http_get_buffered_request_body_vector for more details.
873962 */
874- bool envoy_dynamic_module_callback_http_get_response_body_vector (
963+ bool envoy_dynamic_module_callback_http_get_buffered_response_body_vector (
875964 envoy_dynamic_module_type_http_filter_envoy_ptr filter_envoy_ptr,
876965 envoy_dynamic_module_type_envoy_buffer* result_buffer_vector);
877966
878967/* *
879- * This is the same as envoy_dynamic_module_callback_http_get_request_body_vector_size , but for the
880- * response body. See the comments on
881- * envoy_dynamic_module_callback_http_get_request_body_vector_size for more details.
968+ * This is the same as envoy_dynamic_module_callback_http_get_received_request_body_vector_size , but
969+ * for the current response body. See the comments on
970+ * envoy_dynamic_module_callback_http_get_received_request_body_vector_size for more details.
882971 */
883- bool envoy_dynamic_module_callback_http_get_response_body_vector_size (
972+ bool envoy_dynamic_module_callback_http_get_received_response_body_vector_size (
884973 envoy_dynamic_module_type_http_filter_envoy_ptr filter_envoy_ptr, size_t * size);
885974
886975/* *
887- * This is the same as envoy_dynamic_module_callback_http_append_request_body , but for the response
888- * body. See the comments on envoy_dynamic_module_callback_http_append_request_body for more
889- * details.
976+ * This is the same as envoy_dynamic_module_callback_http_get_buffered_request_body_vector_size , but
977+ * for the buffered response body. See the comments on
978+ * envoy_dynamic_module_callback_http_get_buffered_request_body_vector_size for more details.
890979 */
891- bool envoy_dynamic_module_callback_http_append_response_body (
980+ bool envoy_dynamic_module_callback_http_get_buffered_response_body_vector_size (
981+ envoy_dynamic_module_type_http_filter_envoy_ptr filter_envoy_ptr, size_t * size);
982+
983+ /* *
984+ * This is the same as envoy_dynamic_module_callback_http_append_received_request_body, but for the
985+ * current response body. See the comments on
986+ * envoy_dynamic_module_callback_http_append_received_request_body for more details.
987+ */
988+ bool envoy_dynamic_module_callback_http_append_received_response_body (
892989 envoy_dynamic_module_type_http_filter_envoy_ptr filter_envoy_ptr,
893990 envoy_dynamic_module_type_buffer_module_ptr data, size_t length);
894991
895992/* *
896- * This is the same as envoy_dynamic_module_callback_http_drain_request_body, but for the response
897- * body. See the comments on envoy_dynamic_module_callback_http_drain_request_body for more details.
993+ * This is the same as envoy_dynamic_module_callback_http_append_buffered_request_body, but for the
994+ * buffered response body. See the comments on
995+ * envoy_dynamic_module_callback_http_append_buffered_request_body for more details.
996+ */
997+ bool envoy_dynamic_module_callback_http_append_buffered_response_body (
998+ envoy_dynamic_module_type_http_filter_envoy_ptr filter_envoy_ptr,
999+ envoy_dynamic_module_type_buffer_module_ptr data, size_t length);
1000+
1001+ /* *
1002+ * This is the same as envoy_dynamic_module_callback_http_drain_received_request_body, but for the
1003+ * current response body. See the comments on
1004+ * envoy_dynamic_module_callback_http_drain_received_request_body for more details.
1005+ */
1006+ bool envoy_dynamic_module_callback_http_drain_received_response_body (
1007+ envoy_dynamic_module_type_http_filter_envoy_ptr filter_envoy_ptr, size_t number_of_bytes);
1008+
1009+ /* *
1010+ * This is the same as envoy_dynamic_module_callback_http_drain_buffered_request_body, but for the
1011+ * buffered response body. See the comments on
1012+ * envoy_dynamic_module_callback_http_drain_buffered_request_body for more details.
8981013 */
899- bool envoy_dynamic_module_callback_http_drain_response_body (
1014+ bool envoy_dynamic_module_callback_http_drain_buffered_response_body (
9001015 envoy_dynamic_module_type_http_filter_envoy_ptr filter_envoy_ptr, size_t number_of_bytes);
9011016
9021017// ------------------------ Dynamic Metadata Callbacks -------------------------
0 commit comments