| 1 |
#ifndef AWS_HTTP_CONNECTION_IMPL_H |
| 2 |
#define AWS_HTTP_CONNECTION_IMPL_H |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
#include <aws/http/connection.h> |
| 10 |
|
| 11 |
#include <aws/http/private/http_impl.h> |
| 12 |
#include <aws/http/server.h> |
| 13 |
|
| 14 |
#include <aws/common/atomics.h> |
| 15 |
#include <aws/io/channel.h> |
| 16 |
#include <aws/io/channel_bootstrap.h> |
| 17 |
|
| 18 |
struct aws_http_message; |
| 19 |
struct aws_http_make_request_options; |
| 20 |
struct aws_http_request_handler_options; |
| 21 |
struct aws_http_stream; |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
struct aws_http_connection_system_vtable { |
| 26 |
int (*aws_client_bootstrap_new_socket_channel)(struct aws_socket_channel_bootstrap_options *options); |
| 27 |
}; |
| 28 |
|
| 29 |
struct aws_http_connection_vtable { |
| 30 |
struct aws_channel_handler_vtable channel_handler_vtable; |
| 31 |
|
| 32 |
|
| 33 |
void (*on_channel_handler_installed)(struct aws_channel_handler *handler, struct aws_channel_slot *slot); |
| 34 |
|
| 35 |
struct aws_http_stream *(*make_request)( |
| 36 |
struct aws_http_connection *client_connection, |
| 37 |
const struct aws_http_make_request_options *options); |
| 38 |
|
| 39 |
struct aws_http_stream *(*new_server_request_handler_stream)( |
| 40 |
const struct aws_http_request_handler_options *options); |
| 41 |
int (*stream_send_response)(struct aws_http_stream *stream, struct aws_http_message *response); |
| 42 |
void (*close)(struct aws_http_connection *connection); |
| 43 |
void (*stop_new_requests)(struct aws_http_connection *connection); |
| 44 |
bool (*is_open)(const struct aws_http_connection *connection); |
| 45 |
bool (*new_requests_allowed)(const struct aws_http_connection *connection); |
| 46 |
|
| 47 |
|
| 48 |
void (*update_window)(struct aws_http_connection *connection, uint32_t increment_size); |
| 49 |
int (*change_settings)( |
| 50 |
struct aws_http_connection *http2_connection, |
| 51 |
const struct aws_http2_setting *settings_array, |
| 52 |
size_t num_settings, |
| 53 |
aws_http2_on_change_settings_complete_fn *on_completed, |
| 54 |
void *user_data); |
| 55 |
int (*send_ping)( |
| 56 |
struct aws_http_connection *http2_connection, |
| 57 |
const struct aws_byte_cursor *optional_opaque_data, |
| 58 |
aws_http2_on_ping_complete_fn *on_completed, |
| 59 |
void *user_data); |
| 60 |
void (*send_goaway)( |
| 61 |
struct aws_http_connection *http2_connection, |
| 62 |
uint32_t http2_error, |
| 63 |
bool allow_more_streams, |
| 64 |
const struct aws_byte_cursor *optional_debug_data); |
| 65 |
int (*get_sent_goaway)( |
| 66 |
struct aws_http_connection *http2_connection, |
| 67 |
uint32_t *out_http2_error, |
| 68 |
uint32_t *out_last_stream_id); |
| 69 |
int (*get_received_goaway)( |
| 70 |
struct aws_http_connection *http2_connection, |
| 71 |
uint32_t *out_http2_error, |
| 72 |
uint32_t *out_last_stream_id); |
| 73 |
void (*get_local_settings)( |
| 74 |
const struct aws_http_connection *http2_connection, |
| 75 |
struct aws_http2_setting out_settings[AWS_HTTP2_SETTINGS_COUNT]); |
| 76 |
void (*get_remote_settings)( |
| 77 |
const struct aws_http_connection *http2_connection, |
| 78 |
struct aws_http2_setting out_settings[AWS_HTTP2_SETTINGS_COUNT]); |
| 79 |
}; |
| 80 |
|
| 81 |
typedef int(aws_http_proxy_request_transform_fn)(struct aws_http_message *request, void *user_data); |
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
struct aws_http_connection { |
| 88 |
const struct aws_http_connection_vtable *vtable; |
| 89 |
struct aws_channel_handler channel_handler; |
| 90 |
struct aws_channel_slot *channel_slot; |
| 91 |
struct aws_allocator *alloc; |
| 92 |
enum aws_http_version http_version; |
| 93 |
|
| 94 |
aws_http_proxy_request_transform_fn *proxy_request_transform; |
| 95 |
void *user_data; |
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
struct aws_atomic_var refcount; |
| 100 |
|
| 101 |
|
| 102 |
uint32_t next_stream_id; |
| 103 |
|
| 104 |
union { |
| 105 |
struct aws_http_connection_client_data { |
| 106 |
uint64_t response_first_byte_timeout_ms; |
| 107 |
} client; |
| 108 |
|
| 109 |
struct aws_http_connection_server_data { |
| 110 |
aws_http_on_incoming_request_fn *on_incoming_request; |
| 111 |
aws_http_on_server_connection_shutdown_fn *on_shutdown; |
| 112 |
} server; |
| 113 |
} client_or_server_data; |
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
struct aws_http_connection_client_data *client_data; |
| 118 |
struct aws_http_connection_server_data *server_data; |
| 119 |
|
| 120 |
bool stream_manual_window_management; |
| 121 |
}; |
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
struct aws_http_client_bootstrap { |
| 126 |
struct aws_allocator *alloc; |
| 127 |
bool is_using_tls; |
| 128 |
bool stream_manual_window_management; |
| 129 |
bool prior_knowledge_http2; |
| 130 |
size_t initial_window_size; |
| 131 |
struct aws_http_connection_monitoring_options monitoring_options; |
| 132 |
void *user_data; |
| 133 |
aws_http_on_client_connection_setup_fn *on_setup; |
| 134 |
aws_http_on_client_connection_shutdown_fn *on_shutdown; |
| 135 |
aws_http_proxy_request_transform_fn *proxy_request_transform; |
| 136 |
uint64_t response_first_byte_timeout_ms; |
| 137 |
|
| 138 |
struct aws_http1_connection_options http1_options; |
| 139 |
struct aws_http2_connection_options http2_options; |
| 140 |
struct aws_hash_table *alpn_string_map; |
| 141 |
struct aws_http_connection *connection; |
| 142 |
}; |
| 143 |
|
| 144 |
AWS_EXTERN_C_BEGIN |
| 145 |
AWS_HTTP_API |
| 146 |
void aws_http_client_bootstrap_destroy(struct aws_http_client_bootstrap *bootstrap); |
| 147 |
|
| 148 |
AWS_HTTP_API |
| 149 |
void aws_http_connection_set_system_vtable(const struct aws_http_connection_system_vtable *system_vtable); |
| 150 |
|
| 151 |
AWS_HTTP_API |
| 152 |
int aws_http_client_connect_internal( |
| 153 |
const struct aws_http_client_connection_options *options, |
| 154 |
aws_http_proxy_request_transform_fn *proxy_request_transform); |
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
AWS_HTTP_API |
| 160 |
void aws_http_connection_acquire(struct aws_http_connection *connection); |
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
AWS_HTTP_API |
| 166 |
struct aws_crt_statistics_http1_channel *aws_h1_connection_get_statistics(struct aws_http_connection *connection); |
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
AWS_HTTP_API |
| 176 |
uint32_t aws_http_connection_get_next_stream_id(struct aws_http_connection *connection); |
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
AWS_HTTP_API |
| 196 |
struct aws_http_connection *aws_http_connection_new_channel_handler( |
| 197 |
struct aws_allocator *alloc, |
| 198 |
struct aws_channel *channel, |
| 199 |
bool is_server, |
| 200 |
bool is_using_tls, |
| 201 |
bool manual_window_management, |
| 202 |
bool prior_knowledge_http2, |
| 203 |
size_t initial_window_size, |
| 204 |
const struct aws_hash_table *alpn_string_map, |
| 205 |
const struct aws_http1_connection_options *http1_options, |
| 206 |
const struct aws_http2_connection_options *http2_options, |
| 207 |
void *connection_user_data); |
| 208 |
|
| 209 |
AWS_EXTERN_C_END |
| 210 |
|
| 211 |
#endif |