#ifndef AWS_PROXY_H
#define AWS_PROXY_H
#include <aws/common/ref_count.h>
#include <aws/http/http.h>
#include <aws/http/request_response.h>
#include <aws/http/status_code.h>
struct aws_http_client_connection_options;
struct aws_http_connection_manager_options;
struct aws_http_message;
struct aws_http_header;
struct aws_http_proxy_config;
struct aws_http_proxy_negotiator;
struct aws_http_proxy_strategy;
struct aws_socket_channel_bootstrap_options;
enum aws_http_proxy_authentication_type {
AWS_HPAT_NONE = 0,
AWS_HPAT_BASIC,
};
enum aws_http_proxy_env_var_type {
AWS_HPEV_DISABLE = 0,
AWS_HPEV_ENABLE,
};
enum aws_http_proxy_connection_type {
AWS_HPCT_HTTP_LEGACY = 0,
AWS_HPCT_HTTP_FORWARD,
AWS_HPCT_HTTP_TUNNEL,
};
struct proxy_env_var_settings {
enum aws_http_proxy_env_var_type env_var_type;
enum aws_http_proxy_connection_type connection_type;
const struct aws_tls_connection_options *tls_options;
};
struct aws_http_proxy_strategy;
struct aws_http_proxy_options {
enum aws_http_proxy_connection_type connection_type;
struct aws_byte_cursor host;
uint16_t port;
const struct aws_tls_connection_options *tls_options;
struct aws_http_proxy_strategy *proxy_strategy;
enum aws_http_proxy_authentication_type auth_type;
struct aws_byte_cursor auth_username;
struct aws_byte_cursor auth_password;
};
typedef struct aws_string *(aws_http_proxy_negotiation_get_token_sync_fn)(void *user_data, int *out_error_code);
typedef struct aws_string *(aws_http_proxy_negotiation_get_challenge_token_sync_fn)(
void *user_data,
const struct aws_byte_cursor *challenge_context,
int *out_error_code);
typedef void(aws_http_proxy_negotiation_terminate_fn)(
struct aws_http_message *message,
int error_code,
void *internal_proxy_user_data);
typedef void(aws_http_proxy_negotiation_http_request_forward_fn)(
struct aws_http_message *message,
void *internal_proxy_user_data);
typedef void(aws_http_proxy_negotiation_http_request_transform_async_fn)(
struct aws_http_proxy_negotiator *proxy_negotiator,
struct aws_http_message *message,
aws_http_proxy_negotiation_terminate_fn *negotiation_termination_callback,
aws_http_proxy_negotiation_http_request_forward_fn *negotiation_http_request_forward_callback,
void *internal_proxy_user_data);
typedef int(aws_http_proxy_negotiation_http_request_transform_fn)(
struct aws_http_proxy_negotiator *proxy_negotiator,
struct aws_http_message *message);
typedef int(aws_http_proxy_negotiation_connect_on_incoming_headers_fn)(
struct aws_http_proxy_negotiator *proxy_negotiator,
enum aws_http_header_block header_block,
const struct aws_http_header *header_array,
size_t num_headers);
typedef int(aws_http_proxy_negotiator_connect_status_fn)(
struct aws_http_proxy_negotiator *proxy_negotiator,
enum aws_http_status_code status_code);
typedef int(aws_http_proxy_negotiator_connect_on_incoming_body_fn)(
struct aws_http_proxy_negotiator *proxy_negotiator,
const struct aws_byte_cursor *data);
enum aws_http_proxy_negotiation_retry_directive {
AWS_HPNRD_STOP,
AWS_HPNRD_NEW_CONNECTION,
AWS_HPNRD_CURRENT_CONNECTION,
};
typedef enum aws_http_proxy_negotiation_retry_directive(aws_http_proxy_negotiator_get_retry_directive_fn)(
struct aws_http_proxy_negotiator *proxy_negotiator);
struct aws_http_proxy_negotiator_forwarding_vtable {
aws_http_proxy_negotiation_http_request_transform_fn *forward_request_transform;
};
struct aws_http_proxy_negotiator_tunnelling_vtable {
aws_http_proxy_negotiation_http_request_transform_async_fn *connect_request_transform;
aws_http_proxy_negotiation_connect_on_incoming_headers_fn *on_incoming_headers_callback;
aws_http_proxy_negotiator_connect_status_fn *on_status_callback;
aws_http_proxy_negotiator_connect_on_incoming_body_fn *on_incoming_body_callback;
aws_http_proxy_negotiator_get_retry_directive_fn *get_retry_directive;
};
struct aws_http_proxy_negotiator {
struct aws_ref_count ref_count;
void *impl;
union {
struct aws_http_proxy_negotiator_forwarding_vtable *forwarding_vtable;
struct aws_http_proxy_negotiator_tunnelling_vtable *tunnelling_vtable;
} strategy_vtable;
};
typedef struct aws_http_proxy_negotiator *(aws_http_proxy_strategy_create_negotiator_fn)(
struct aws_http_proxy_strategy *proxy_strategy,
struct aws_allocator *allocator);
struct aws_http_proxy_strategy_vtable {
aws_http_proxy_strategy_create_negotiator_fn *create_negotiator;
};
struct aws_http_proxy_strategy {
struct aws_ref_count ref_count;
struct aws_http_proxy_strategy_vtable *vtable;
void *impl;
enum aws_http_proxy_connection_type proxy_connection_type;
};
struct aws_http_proxy_strategy_basic_auth_options {
enum aws_http_proxy_connection_type proxy_connection_type;
struct aws_byte_cursor user_name;
struct aws_byte_cursor password;
};
struct aws_http_proxy_strategy_tunneling_kerberos_options {
aws_http_proxy_negotiation_get_token_sync_fn *get_token;
void *get_token_user_data;
};
struct aws_http_proxy_strategy_tunneling_ntlm_options {
aws_http_proxy_negotiation_get_token_sync_fn *get_token;
aws_http_proxy_negotiation_get_challenge_token_sync_fn *get_challenge_token;
void *get_challenge_token_user_data;
};
struct aws_http_proxy_strategy_tunneling_adaptive_options {
struct aws_http_proxy_strategy_tunneling_kerberos_options *kerberos_options;
struct aws_http_proxy_strategy_tunneling_ntlm_options *ntlm_options;
};
struct aws_http_proxy_strategy_tunneling_sequence_options {
struct aws_http_proxy_strategy **strategies;
uint32_t strategy_count;
};
AWS_EXTERN_C_BEGIN
AWS_HTTP_API
struct aws_http_proxy_negotiator *aws_http_proxy_negotiator_acquire(struct aws_http_proxy_negotiator *proxy_negotiator);
AWS_HTTP_API
void aws_http_proxy_negotiator_release(struct aws_http_proxy_negotiator *proxy_negotiator);
AWS_HTTP_API
struct aws_http_proxy_negotiator *aws_http_proxy_strategy_create_negotiator(
struct aws_http_proxy_strategy *strategy,
struct aws_allocator *allocator);
AWS_HTTP_API
struct aws_http_proxy_strategy *aws_http_proxy_strategy_acquire(struct aws_http_proxy_strategy *proxy_strategy);
AWS_HTTP_API
void aws_http_proxy_strategy_release(struct aws_http_proxy_strategy *proxy_strategy);
AWS_HTTP_API
struct aws_http_proxy_strategy *aws_http_proxy_strategy_new_basic_auth(
struct aws_allocator *allocator,
struct aws_http_proxy_strategy_basic_auth_options *config);
AWS_HTTP_API
struct aws_http_proxy_strategy *aws_http_proxy_strategy_new_tunneling_adaptive(
struct aws_allocator *allocator,
struct aws_http_proxy_strategy_tunneling_adaptive_options *config);
AWS_HTTP_API
struct aws_http_proxy_config *aws_http_proxy_config_new_from_connection_options(
struct aws_allocator *allocator,
const struct aws_http_client_connection_options *options);
AWS_HTTP_API
struct aws_http_proxy_config *aws_http_proxy_config_new_from_manager_options(
struct aws_allocator *allocator,
const struct aws_http_connection_manager_options *options);
AWS_HTTP_API
struct aws_http_proxy_config *aws_http_proxy_config_new_tunneling_from_proxy_options(
struct aws_allocator *allocator,
const struct aws_http_proxy_options *options);
AWS_HTTP_API
struct aws_http_proxy_config *aws_http_proxy_config_new_from_proxy_options(
struct aws_allocator *allocator,
const struct aws_http_proxy_options *options);
AWS_HTTP_API
struct aws_http_proxy_config *aws_http_proxy_config_new_clone(
struct aws_allocator *allocator,
const struct aws_http_proxy_config *proxy_config);
AWS_HTTP_API
void aws_http_proxy_config_destroy(struct aws_http_proxy_config *config);
AWS_HTTP_API
void aws_http_proxy_options_init_from_config(
struct aws_http_proxy_options *options,
const struct aws_http_proxy_config *config);
AWS_HTTP_API int aws_http_proxy_new_socket_channel(
struct aws_socket_channel_bootstrap_options *channel_options,
const struct aws_http_proxy_options *proxy_options);
AWS_EXTERN_C_END
#endif