1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
;
;
;
;
;
/**
* An HTTP connection.
* This type is used by both server-side and client-side connections.
* This type is also used by all supported versions of HTTP.
*/
;
/**
* Invoked when connect completes.
*
* If unsuccessful, error_code will be set, connection will be NULL,
* and the on_shutdown callback will never be invoked.
*
* If successful, error_code will be 0 and connection will be valid.
* The user is now responsible for the connection and must
* call aws_http_connection_release() when they are done with it.
*
* The connection uses one event-loop thread to do all its work.
* The thread invoking this callback will be the same thread that invokes all
* future callbacks for this connection and its streams.
*/
typedef void;
/**
* Invoked when the connection has finished shutting down.
* Never invoked if on_setup failed.
* This is always invoked on connection's event-loop thread.
* Note that the connection is not completely done until on_shutdown has been invoked
* AND aws_http_connection_release() has been called.
*/
typedef void;
/**
* Invoked when the HTTP/2 settings change is complete.
* If connection setup successfully this will always be invoked whether settings change successfully or unsuccessfully.
* If error_code is AWS_ERROR_SUCCESS (0), then the peer has acknowledged the settings and the change has been applied.
* If error_code is non-zero, then a connection error occurred before the settings could be fully acknowledged and
* applied. This is always invoked on the connection's event-loop thread.
*/
typedef void;
/**
* Invoked when the HTTP/2 PING completes, whether peer has acknowledged it or not.
* If error_code is AWS_ERROR_SUCCESS (0), then the peer has acknowledged the PING and round_trip_time_ns will be the
* round trip time in nano seconds for the connection.
* If error_code is non-zero, then a connection error occurred before the PING get acknowledgment and round_trip_time_ns
* will be useless in this case.
*/
typedef void;
/**
* Invoked when an HTTP/2 GOAWAY frame is received from peer.
* Implies that the peer has initiated shutdown, or encountered a serious error.
* Once a GOAWAY is received, no further streams may be created on this connection.
*
* @param http2_connection This HTTP/2 connection.
* @param last_stream_id ID of the last locally-initiated stream that peer will
* process. Any locally-initiated streams with a higher ID are ignored by
* peer, and are safe to retry on another connection.
* @param http2_error_code The HTTP/2 error code (RFC-7540 section 7) sent by peer.
* `enum aws_http2_error_code` lists official codes.
* @param debug_data The debug data sent by peer. It can be empty. (NOTE: this data is only valid for the lifetime of
* the callback. Make a deep copy if you wish to keep it longer.)
* @param user_data User-data passed to the callback.
*/
typedef void;
/**
* Invoked when new HTTP/2 settings from peer have been applied.
* Settings_array is the array of aws_http2_settings that contains all the settings we just changed in the order we
* applied (the order settings arrived). Num_settings is the number of elements in that array.
*/
typedef void;
/**
* Callback invoked on each statistics sample.
*
* connection_nonce is unique to each connection for disambiguation of each callback per connection.
*/
typedef void;
/**
* Configuration options for connection monitoring
*/
;
/**
* Options specific to HTTP/1.x connections.
*/
;
/**
* Options specific to HTTP/2 connections.
*/
;
/**
* Options for creating an HTTP client connection.
* Initialize with AWS_HTTP_CLIENT_CONNECTION_OPTIONS_INIT to set default values.
*/
;
/* Predefined settings identifiers (RFC-7540 6.5.2) */
;
/* A HTTP/2 setting and its value, used in SETTINGS frame */
;
/**
* HTTP/2: Default value for max closed streams we will keep in memory.
*/
/**
* HTTP/2: The size of payload for HTTP/2 PING frame.
*/
/**
* HTTP/2: The number of known settings.
*/
/**
* Initializes aws_http_client_connection_options with default values.
*/
/**
* Asynchronously establish a client connection.
* The on_setup callback is invoked when the operation has created a connection or failed.
*/
int ;
/**
* Users must release the connection when they are done with it.
* The connection's memory cannot be reclaimed until this is done.
* If the connection was not already shutting down, it will be shut down.
*
* Users should always wait for the on_shutdown() callback to be called before releasing any data passed to the
* http_connection (Eg aws_tls_connection_options, aws_socket_options) otherwise there will be race conditions between
* http_connection shutdown tasks and memory release tasks, causing Segfaults.
*/
void ;
/**
* Begin shutdown sequence of the connection if it hasn't already started. This will schedule shutdown tasks on the
* EventLoop that may send HTTP/TLS/TCP shutdown messages to peers if necessary, and will eventually cause internal
* connection memory to stop being accessed and on_shutdown() callback to be called.
*
* It's safe to call this function regardless of the connection state as long as you hold a reference to the connection.
*/
void ;
/**
* Stop accepting new requests for the connection. It will NOT start the shutdown process for the connection. The
* requests that are already open can still wait to be completed, but new requests will fail to be created,
*/
void ;
/**
* Returns true unless the connection is closed or closing.
*/
bool ;
/**
* Return whether the connection can make a new requests.
* If false, then a new connection must be established to make further requests.
*/
bool ;
/**
* Returns true if this is a client connection.
*/
bool ;
enum aws_http_version ;
/**
* Returns the channel hosting the HTTP connection.
* Do not expose this function to language bindings.
*/
struct aws_channel *;
/**
* Initialize an map copied from the *src map, which maps `struct aws_string *` to `enum aws_http_version`.
*/
int ;
/**
* Initialize an empty hash-table that maps `struct aws_string *` to `enum aws_http_version`.
* This map can used in aws_http_client_connections_options.alpn_string_map.
*/
int ;
/**
* Checks http proxy options for correctness
*/
int ;
/**
* Send a SETTINGS frame (HTTP/2 only).
* SETTINGS will be applied locally when SETTINGS ACK is received from peer.
*
* @param http2_connection HTTP/2 connection.
* @param settings_array The array of settings to change. Note: each setting has its boundary.
* @param num_settings The num of settings to change in settings_array.
* @param on_completed Optional callback, see `aws_http2_on_change_settings_complete_fn`.
* @param user_data User-data pass to on_completed callback.
*/
int ;
/**
* Send a PING frame (HTTP/2 only).
* Round-trip-time is calculated when PING ACK is received from peer.
*
* @param http2_connection HTTP/2 connection.
* @param optional_opaque_data Optional payload for PING frame.
* Must be NULL, or exactly 8 bytes (AWS_HTTP2_PING_DATA_SIZE).
* If NULL, the 8 byte payload will be all zeroes.
* @param on_completed Optional callback, invoked when PING ACK is received from peer,
* or when a connection error prevents the PING ACK from being received.
* Callback always fires on the connection's event-loop thread.
* @param user_data User-data pass to on_completed callback.
*/
int ;
/**
* Get the local settings we are using to affect the decoding.
*
* @param http2_connection HTTP/2 connection.
* @param out_settings fixed size array of aws_http2_setting gets set to the local settings
*/
void ;
/**
* Get the settings received from remote peer, which we are using to restricts the message to send.
*
* @param http2_connection HTTP/2 connection.
* @param out_settings fixed size array of aws_http2_setting gets set to the remote settings
*/
void ;
/**
* Send a custom GOAWAY frame (HTTP/2 only).
*
* Note that the connection automatically attempts to send a GOAWAY during
* shutdown (unless a GOAWAY with a valid Last-Stream-ID has already been sent).
*
* This call can be used to gracefully warn the peer of an impending shutdown
* (http2_error=0, allow_more_streams=true), or to customize the final GOAWAY
* frame that is sent by this connection.
*
* The other end may not receive the goaway, if the connection already closed.
*
* @param http2_connection HTTP/2 connection.
* @param http2_error The HTTP/2 error code (RFC-7540 section 7) to send.
* `enum aws_http2_error_code` lists official codes.
* @param allow_more_streams If true, new peer-initiated streams will continue
* to be acknowledged and the GOAWAY's Last-Stream-ID will be set to a max value.
* If false, new peer-initiated streams will be ignored and the GOAWAY's
* Last-Stream-ID will be set to the latest acknowledged stream.
* @param optional_debug_data Optional debug data to send. Size must not exceed 16KB.
*/
void ;
/**
* Get data about the latest GOAWAY frame sent to peer (HTTP/2 only).
* If no GOAWAY has been sent, AWS_ERROR_HTTP_DATA_NOT_AVAILABLE will be raised.
* Note that GOAWAY frames are typically sent automatically by the connection
* during shutdown.
*
* @param http2_connection HTTP/2 connection.
* @param out_http2_error Gets set to HTTP/2 error code sent in most recent GOAWAY.
* @param out_last_stream_id Gets set to Last-Stream-ID sent in most recent GOAWAY.
*/
int ;
/**
* Get data about the latest GOAWAY frame received from peer (HTTP/2 only).
* If no GOAWAY has been received, or the GOAWAY payload is still in transmitting,
* AWS_ERROR_HTTP_DATA_NOT_AVAILABLE will be raised.
*
* @param http2_connection HTTP/2 connection.
* @param out_http2_error Gets set to HTTP/2 error code received in most recent GOAWAY.
* @param out_last_stream_id Gets set to Last-Stream-ID received in most recent GOAWAY.
*/
int ;
/**
* Increment the connection's flow-control window to keep data flowing (HTTP/2 only).
*
* If the connection was created with `conn_manual_window_management` set true,
* the flow-control window of the connection will shrink as body data is received for all the streams created on it.
* (headers, padding, and other metadata do not affect the window).
* The initial connection flow-control window is 65,535.
* Once the connection's flow-control window reaches to 0, all the streams on the connection stop receiving any further
* data.
*
* If `conn_manual_window_management` is false, this call will have no effect.
* The connection maintains its flow-control windows such that
* no back-pressure is applied and data arrives as fast as possible.
*
* If you are not connected, this call will have no effect.
*
* Crashes when the connection is not http2 connection.
* The limit of the Maximum Size is 2**31 - 1. If the increment size cause the connection flow window exceeds the
* Maximum size, this call will result in the connection lost.
*
* @param http2_connection HTTP/2 connection.
* @param increment_size The size to increment for the connection's flow control window
*/
void ;
/* AWS_HTTP_CONNECTION_H */