@@ -371,6 +371,34 @@ typedef enum {
371371 envoy_dynamic_module_type_attribute_id_XdsFilterChainName,
372372} envoy_dynamic_module_type_attribute_id;
373373
374+ /* *
375+ * envoy_dynamic_module_type_http_callout_init_result represents the result of the HTTP callout
376+ * initialization after envoy_dynamic_module_callback_http_filter_http_callout is called.
377+ * Success means the callout is successfully initialized and ready to be used.
378+ * MissingRequiredHeaders means the callout is missing one of the required headers, :path, :method,
379+ * or host header. DuplicateCalloutId means the callout id is already used by another callout.
380+ * ClusterNotFound means the cluster is not found in the configuration. CannotCreateRequest means
381+ * the request cannot be created. That happens when, for example, there's no healthy upstream host
382+ * in the cluster.
383+ */
384+ typedef enum {
385+ envoy_dynamic_module_type_http_callout_init_result_Success,
386+ envoy_dynamic_module_type_http_callout_init_result_MissingRequiredHeaders,
387+ envoy_dynamic_module_type_http_callout_init_result_ClusterNotFound,
388+ envoy_dynamic_module_type_http_callout_init_result_DuplicateCalloutId,
389+ envoy_dynamic_module_type_http_callout_init_result_CannotCreateRequest,
390+ } envoy_dynamic_module_type_http_callout_init_result;
391+
392+ /* *
393+ * envoy_dynamic_module_type_http_callout_result represents the result of the HTTP callout.
394+ * This corresponds to `AsyncClient::FailureReason::*` in envoy/http/async_client.h plus Success.
395+ */
396+ typedef enum {
397+ envoy_dynamic_module_type_http_callout_result_Success,
398+ envoy_dynamic_module_type_http_callout_result_Reset,
399+ envoy_dynamic_module_type_http_callout_result_ExceedResponseBufferLimit,
400+ } envoy_dynamic_module_type_http_callout_result;
401+
374402// -----------------------------------------------------------------------------
375403// ------------------------------- Event Hooks ---------------------------------
376404// -----------------------------------------------------------------------------
@@ -566,6 +594,32 @@ void envoy_dynamic_module_on_http_filter_stream_complete(
566594void envoy_dynamic_module_on_http_filter_destroy (
567595 envoy_dynamic_module_type_http_filter_module_ptr filter_module_ptr);
568596
597+ /* *
598+ * envoy_dynamic_module_on_http_filter_http_callout_done is called when the HTTP callout
599+ * response is received initiated by a HTTP filter.
600+ *
601+ * @param filter_envoy_ptr is the pointer to the DynamicModuleHttpFilter object of the
602+ * corresponding HTTP filter.
603+ * @param filter_module_ptr is the pointer to the in-module HTTP filter created by
604+ * envoy_dynamic_module_on_http_filter_new.
605+ * @param callout_id is the ID of the callout. This is used to differentiate between multiple
606+ * calls.
607+ * @param result is the result of the callout.
608+ * @param headers is the headers of the response.
609+ * @param headers_size is the size of the headers.
610+ * @param body_vector is the body of the response.
611+ * @param body_vector_size is the size of the body.
612+ *
613+ * headers and body_vector are owned by Envoy, and they are guaranteed to be valid until the end of
614+ * this event hook. They may be null if the callout fails or the response is empty.
615+ */
616+ void envoy_dynamic_module_on_http_filter_http_callout_done (
617+ envoy_dynamic_module_type_http_filter_envoy_ptr filter_envoy_ptr,
618+ envoy_dynamic_module_type_http_filter_module_ptr filter_module_ptr, uint32_t callout_id,
619+ envoy_dynamic_module_type_http_callout_result result,
620+ envoy_dynamic_module_type_http_header* headers, size_t headers_size,
621+ envoy_dynamic_module_type_envoy_buffer* body_vector, size_t body_vector_size);
622+
569623// -----------------------------------------------------------------------------
570624// -------------------------------- Callbacks ----------------------------------
571625// -----------------------------------------------------------------------------
@@ -1083,6 +1137,32 @@ bool envoy_dynamic_module_callback_http_filter_get_attribute_int(
10831137 envoy_dynamic_module_type_http_filter_envoy_ptr filter_envoy_ptr,
10841138 envoy_dynamic_module_type_attribute_id attribute_id, uint64_t * result);
10851139
1140+ /* *
1141+ * envoy_dynamic_module_callback_http_filter_http_callout is called by the module to initiate
1142+ * an HTTP callout. The callout is initiated by the HTTP filter and the response is received in
1143+ * envoy_dynamic_module_on_http_filter_http_callout_done.
1144+ *
1145+ * @param filter_envoy_ptr is the pointer to the DynamicModuleHttpFilter object of the
1146+ * corresponding HTTP filter.
1147+ * @param callout_id is the ID of the callout. This can be arbitrary and is used to
1148+ * differentiate between multiple calls from the same filter.
1149+ * @param cluster_name is the name of the cluster to which the callout is sent.
1150+ * @param cluster_name_length is the length of the cluster name.
1151+ * @param headers is the headers of the request. It must contain :method, :path and host headers.
1152+ * @param headers_size is the size of the headers.
1153+ * @param body is the pointer to the buffer of the body of the request.
1154+ * @param body_size is the length of the body.
1155+ * @param timeout_milliseconds is the timeout for the callout in milliseconds.
1156+ * @return envoy_dynamic_module_type_http_callout_init_result is the result of the callout.
1157+ */
1158+ envoy_dynamic_module_type_http_callout_init_result
1159+ envoy_dynamic_module_callback_http_filter_http_callout (
1160+ envoy_dynamic_module_type_http_filter_envoy_ptr filter_envoy_ptr, uint32_t callout_id,
1161+ envoy_dynamic_module_type_buffer_module_ptr cluster_name, size_t cluster_name_length,
1162+ envoy_dynamic_module_type_http_header* headers, size_t headers_size,
1163+ envoy_dynamic_module_type_buffer_module_ptr body, size_t body_size,
1164+ uint64_t timeout_milliseconds);
1165+
10861166#ifdef __cplusplus
10871167}
10881168#endif
0 commit comments