aws-crt 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (322) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/VERSION +1 -1
  4. data/aws-crt-ffi/CMakeLists.txt +49 -41
  5. data/aws-crt-ffi/crt/aws-c-auth/CMakeLists.txt +0 -10
  6. data/aws-crt-ffi/crt/aws-c-auth/include/aws/auth/credentials.h +3 -2
  7. data/aws-crt-ffi/crt/aws-c-auth/include/aws/auth/private/credentials_utils.h +4 -4
  8. data/aws-crt-ffi/crt/aws-c-auth/source/auth.c +1 -14
  9. data/aws-crt-ffi/crt/aws-c-auth/source/aws_imds_client.c +206 -68
  10. data/aws-crt-ffi/crt/aws-c-auth/source/aws_signing.c +5 -0
  11. data/aws-crt-ffi/crt/aws-c-auth/source/credentials_provider_cached.c +6 -6
  12. data/aws-crt-ffi/crt/aws-c-auth/source/credentials_provider_default_chain.c +16 -1
  13. data/aws-crt-ffi/crt/aws-c-auth/source/credentials_provider_ecs.c +0 -1
  14. data/aws-crt-ffi/crt/aws-c-auth/source/credentials_provider_process.c +0 -1
  15. data/aws-crt-ffi/crt/aws-c-auth/source/credentials_provider_sts_web_identity.c +0 -1
  16. data/aws-crt-ffi/crt/aws-c-auth/source/credentials_provider_x509.c +10 -7
  17. data/aws-crt-ffi/crt/aws-c-auth/source/credentials_utils.c +35 -26
  18. data/aws-crt-ffi/crt/aws-c-auth/source/signable_chunk.c +3 -2
  19. data/aws-crt-ffi/crt/aws-c-auth/tests/CMakeLists.txt +3 -2
  20. data/aws-crt-ffi/crt/aws-c-auth/tests/aws_imds_client_test.c +1 -0
  21. data/aws-crt-ffi/crt/aws-c-auth/tests/credentials_provider_ecs_tests.c +3 -0
  22. data/aws-crt-ffi/crt/aws-c-auth/tests/credentials_provider_process_tests.c +65 -16
  23. data/aws-crt-ffi/crt/aws-c-auth/tests/credentials_tests.c +125 -0
  24. data/aws-crt-ffi/crt/aws-c-auth/tests/sigv4_signing_tests.c +68 -46
  25. data/aws-crt-ffi/crt/aws-c-cal/CMakeLists.txt +8 -3
  26. data/aws-crt-ffi/crt/aws-c-cal/bin/run_x_platform_fuzz_corpus/main.c +9 -0
  27. data/aws-crt-ffi/crt/aws-c-cal/builder.json +11 -3
  28. data/aws-crt-ffi/crt/aws-c-cal/cmake/aws-c-cal-config.cmake +14 -5
  29. data/aws-crt-ffi/crt/aws-c-cal/source/darwin/securityframework_ecc.c +6 -6
  30. data/aws-crt-ffi/crt/aws-c-cal/source/windows/bcrypt_ecc.c +12 -12
  31. data/aws-crt-ffi/crt/aws-c-cal/tests/test_case_helper.h +14 -14
  32. data/aws-crt-ffi/crt/aws-c-common/CMakeLists.txt +21 -1
  33. data/aws-crt-ffi/crt/aws-c-common/README.md +8 -0
  34. data/aws-crt-ffi/crt/aws-c-common/cmake/AwsCFlags.cmake +20 -5
  35. data/aws-crt-ffi/crt/aws-c-common/cmake/AwsFeatureTests.cmake +7 -1
  36. data/aws-crt-ffi/crt/aws-c-common/format-check.sh +1 -1
  37. data/aws-crt-ffi/crt/aws-c-common/include/aws/common/byte_buf.h +14 -0
  38. data/aws-crt-ffi/crt/aws-c-common/include/aws/common/config.h.in +1 -0
  39. data/aws-crt-ffi/crt/{aws-c-auth/include/aws/auth → aws-c-common/include/aws/common}/external/cJSON.h +82 -74
  40. data/aws-crt-ffi/crt/aws-c-common/include/aws/common/json.h +335 -0
  41. data/aws-crt-ffi/crt/aws-c-common/include/aws/common/logging.h +1 -0
  42. data/aws-crt-ffi/crt/aws-c-common/include/aws/common/math.inl +2 -2
  43. data/aws-crt-ffi/crt/aws-c-common/include/aws/common/private/json_impl.h +22 -0
  44. data/aws-crt-ffi/crt/aws-c-common/include/aws/testing/aws_test_harness.h +2 -0
  45. data/aws-crt-ffi/crt/aws-c-common/source/byte_buf.c +36 -0
  46. data/aws-crt-ffi/crt/aws-c-common/source/common.c +5 -2
  47. data/aws-crt-ffi/crt/aws-c-common/source/external/cJSON.c +3113 -0
  48. data/aws-crt-ffi/crt/aws-c-common/source/file.c +9 -0
  49. data/aws-crt-ffi/crt/aws-c-common/source/json.c +348 -0
  50. data/aws-crt-ffi/crt/aws-c-common/source/logging.c +7 -2
  51. data/aws-crt-ffi/crt/aws-c-common/source/posix/system_info.c +8 -0
  52. data/aws-crt-ffi/crt/aws-c-common/source/ref_count.c +3 -1
  53. data/aws-crt-ffi/crt/aws-c-common/source/windows/file.c +47 -0
  54. data/aws-crt-ffi/crt/aws-c-common/source/windows/system_info.c +2 -1
  55. data/aws-crt-ffi/crt/aws-c-common/tests/CMakeLists.txt +5 -0
  56. data/aws-crt-ffi/crt/aws-c-common/tests/byte_buf_test.c +69 -0
  57. data/aws-crt-ffi/crt/aws-c-common/tests/json_test.c +134 -0
  58. data/aws-crt-ffi/crt/aws-c-common/tests/memtrace_test.c +6 -2
  59. data/aws-crt-ffi/crt/aws-c-event-stream/README.md +18 -35
  60. data/aws-crt-ffi/crt/aws-c-event-stream/include/aws/event-stream/event_stream.h +21 -2
  61. data/aws-crt-ffi/crt/aws-c-event-stream/include/aws/event-stream/event_stream_rpc_client.h +14 -2
  62. data/aws-crt-ffi/crt/aws-c-event-stream/include/aws/event-stream/event_stream_rpc_server.h +13 -0
  63. data/aws-crt-ffi/crt/aws-c-event-stream/include/aws/event-stream/private/event_stream_rpc_priv.h +7 -7
  64. data/aws-crt-ffi/crt/aws-c-event-stream/source/event_stream.c +257 -141
  65. data/aws-crt-ffi/crt/aws-c-event-stream/source/event_stream_channel_handler.c +1 -1
  66. data/aws-crt-ffi/crt/aws-c-event-stream/source/event_stream_rpc_client.c +31 -8
  67. data/aws-crt-ffi/crt/aws-c-event-stream/source/event_stream_rpc_server.c +63 -10
  68. data/aws-crt-ffi/crt/aws-c-event-stream/tests/CMakeLists.txt +2 -0
  69. data/aws-crt-ffi/crt/aws-c-event-stream/tests/event_stream_rpc_client_connection_test.c +157 -106
  70. data/aws-crt-ffi/crt/aws-c-event-stream/tests/event_stream_rpc_server_connection_test.c +168 -1
  71. data/aws-crt-ffi/crt/aws-c-event-stream/tests/message_deserializer_test.c +4 -2
  72. data/aws-crt-ffi/crt/aws-c-http/CMakeLists.txt +1 -0
  73. data/aws-crt-ffi/crt/aws-c-http/README.md +8 -0
  74. data/aws-crt-ffi/crt/aws-c-http/bin/elasticurl/main.c +1 -1
  75. data/aws-crt-ffi/crt/aws-c-http/builder.json +4 -3
  76. data/aws-crt-ffi/crt/aws-c-http/include/aws/http/connection.h +8 -1
  77. data/aws-crt-ffi/crt/aws-c-http/include/aws/http/connection_manager.h +45 -1
  78. data/aws-crt-ffi/crt/aws-c-http/include/aws/http/http2_stream_manager.h +63 -12
  79. data/aws-crt-ffi/crt/aws-c-http/include/aws/http/private/connection_impl.h +2 -1
  80. data/aws-crt-ffi/crt/aws-c-http/include/aws/http/private/h2_connection.h +20 -2
  81. data/aws-crt-ffi/crt/aws-c-http/include/aws/http/private/h2_frames.h +1 -0
  82. data/aws-crt-ffi/crt/aws-c-http/include/aws/http/private/h2_stream.h +42 -13
  83. data/aws-crt-ffi/crt/aws-c-http/include/aws/http/private/http2_stream_manager_impl.h +17 -0
  84. data/aws-crt-ffi/crt/aws-c-http/include/aws/http/private/http_impl.h +3 -0
  85. data/aws-crt-ffi/crt/aws-c-http/include/aws/http/private/random_access_set.h +10 -3
  86. data/aws-crt-ffi/crt/aws-c-http/include/aws/http/private/request_response_impl.h +3 -17
  87. data/aws-crt-ffi/crt/aws-c-http/include/aws/http/request_response.h +108 -4
  88. data/aws-crt-ffi/crt/aws-c-http/include/aws/http/statistics.h +22 -0
  89. data/aws-crt-ffi/crt/aws-c-http/source/connection.c +8 -3
  90. data/aws-crt-ffi/crt/aws-c-http/source/connection_manager.c +22 -3
  91. data/aws-crt-ffi/crt/aws-c-http/source/connection_monitor.c +32 -14
  92. data/aws-crt-ffi/crt/aws-c-http/source/h1_connection.c +14 -0
  93. data/aws-crt-ffi/crt/aws-c-http/source/h1_encoder.c +7 -4
  94. data/aws-crt-ffi/crt/aws-c-http/source/h2_connection.c +161 -45
  95. data/aws-crt-ffi/crt/aws-c-http/source/h2_decoder.c +37 -8
  96. data/aws-crt-ffi/crt/aws-c-http/source/h2_frames.c +13 -1
  97. data/aws-crt-ffi/crt/aws-c-http/source/h2_stream.c +345 -87
  98. data/aws-crt-ffi/crt/aws-c-http/source/hpack.c +3 -0
  99. data/aws-crt-ffi/crt/aws-c-http/source/http.c +3 -0
  100. data/aws-crt-ffi/crt/aws-c-http/source/http2_stream_manager.c +266 -39
  101. data/aws-crt-ffi/crt/aws-c-http/source/random_access_set.c +9 -3
  102. data/aws-crt-ffi/crt/aws-c-http/source/request_response.c +80 -20
  103. data/aws-crt-ffi/crt/aws-c-http/source/statistics.c +11 -0
  104. data/aws-crt-ffi/crt/aws-c-http/tests/CMakeLists.txt +28 -1
  105. data/aws-crt-ffi/crt/aws-c-http/tests/fuzz/fuzz_h2_decoder_correct.c +5 -3
  106. data/aws-crt-ffi/crt/aws-c-http/tests/h2_test_helper.c +133 -29
  107. data/aws-crt-ffi/crt/aws-c-http/tests/h2_test_helper.h +6 -0
  108. data/aws-crt-ffi/crt/aws-c-http/tests/py_localhost/README.md +40 -0
  109. data/aws-crt-ffi/crt/aws-c-http/tests/py_localhost/non_tls_server.py +56 -0
  110. data/aws-crt-ffi/crt/aws-c-http/tests/py_localhost/server.py +329 -0
  111. data/aws-crt-ffi/crt/aws-c-http/tests/test_connection_manager.c +1 -1
  112. data/aws-crt-ffi/crt/aws-c-http/tests/test_connection_monitor.c +2 -2
  113. data/aws-crt-ffi/crt/aws-c-http/tests/test_h1_client.c +47 -34
  114. data/aws-crt-ffi/crt/aws-c-http/tests/test_h1_encoder.c +4 -4
  115. data/aws-crt-ffi/crt/aws-c-http/tests/test_h1_server.c +15 -12
  116. data/aws-crt-ffi/crt/aws-c-http/tests/test_h2_client.c +582 -25
  117. data/aws-crt-ffi/crt/aws-c-http/tests/test_h2_encoder.c +3 -3
  118. data/aws-crt-ffi/crt/aws-c-http/tests/test_localhost_integ.c +530 -0
  119. data/aws-crt-ffi/crt/aws-c-http/tests/test_stream_manager.c +459 -67
  120. data/aws-crt-ffi/crt/aws-c-io/CMakeLists.txt +4 -0
  121. data/aws-crt-ffi/crt/aws-c-io/builder.json +3 -2
  122. data/aws-crt-ffi/crt/aws-c-io/include/aws/io/channel.h +21 -0
  123. data/aws-crt-ffi/crt/aws-c-io/include/aws/io/io.h +3 -0
  124. data/aws-crt-ffi/crt/aws-c-io/include/aws/io/socket.h +6 -0
  125. data/aws-crt-ffi/crt/aws-c-io/include/aws/io/stream.h +35 -5
  126. data/aws-crt-ffi/crt/aws-c-io/include/aws/io/tls_channel_handler.h +211 -15
  127. data/aws-crt-ffi/crt/aws-c-io/source/channel.c +56 -30
  128. data/aws-crt-ffi/crt/aws-c-io/source/darwin/secure_transport_tls_channel_handler.c +0 -24
  129. data/aws-crt-ffi/crt/aws-c-io/source/io.c +9 -0
  130. data/aws-crt-ffi/crt/aws-c-io/source/{pkcs11.c → pkcs11_lib.c} +162 -22
  131. data/aws-crt-ffi/crt/aws-c-io/source/pkcs11_private.h +18 -20
  132. data/aws-crt-ffi/crt/aws-c-io/source/pkcs11_tls_op_handler.c +221 -0
  133. data/aws-crt-ffi/crt/aws-c-io/source/posix/socket.c +135 -81
  134. data/aws-crt-ffi/crt/aws-c-io/source/retry_strategy.c +12 -8
  135. data/aws-crt-ffi/crt/aws-c-io/source/s2n/s2n_tls_channel_handler.c +252 -215
  136. data/aws-crt-ffi/crt/aws-c-io/source/stream.c +65 -82
  137. data/aws-crt-ffi/crt/aws-c-io/source/tls_channel_handler.c +188 -57
  138. data/aws-crt-ffi/crt/aws-c-io/source/windows/iocp/socket.c +271 -256
  139. data/aws-crt-ffi/crt/aws-c-io/tests/CMakeLists.txt +21 -12
  140. data/aws-crt-ffi/crt/aws-c-io/tests/channel_test.c +32 -4
  141. data/aws-crt-ffi/crt/aws-c-io/tests/io_lib_test.c +37 -0
  142. data/aws-crt-ffi/crt/aws-c-io/tests/pkcs11_test.c +412 -93
  143. data/aws-crt-ffi/crt/aws-c-io/tests/resources/ec_unittests.crt +15 -0
  144. data/aws-crt-ffi/crt/aws-c-io/tests/resources/ec_unittests.key +5 -0
  145. data/aws-crt-ffi/crt/aws-c-io/tests/resources/ec_unittests.p12 +0 -0
  146. data/aws-crt-ffi/crt/aws-c-io/tests/resources/ec_unittests.p8 +5 -0
  147. data/aws-crt-ffi/crt/aws-c-io/tests/resources/generateCerts.sh +24 -15
  148. data/aws-crt-ffi/crt/aws-c-io/tests/socket_test.c +72 -1
  149. data/aws-crt-ffi/crt/s2n/CMakeLists.txt +6 -1
  150. data/aws-crt-ffi/crt/s2n/bindings/rust/Cargo.toml +1 -0
  151. data/aws-crt-ffi/crt/s2n/bindings/rust/generate/src/main.rs +105 -82
  152. data/aws-crt-ffi/crt/s2n/bindings/rust/generate.sh +1 -0
  153. data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls/Cargo.toml +2 -2
  154. data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls/src/raw/config.rs +1 -1
  155. data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-sys/Cargo.toml +1 -1
  156. data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-sys/build.rs +84 -30
  157. data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-sys/src/lib.rs +4 -0
  158. data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-tokio/Cargo.toml +21 -0
  159. data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-tokio/examples/certs/cert.pem +14 -0
  160. data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-tokio/examples/certs/key.pem +8 -0
  161. data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-tokio/examples/client.rs +45 -0
  162. data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-tokio/examples/server.rs +60 -0
  163. data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-tokio/src/lib.rs +150 -0
  164. data/aws-crt-ffi/crt/s2n/bindings/rust/s2n-tls-tokio/tests/handshake.rs +51 -0
  165. data/aws-crt-ffi/crt/s2n/crypto/s2n_drbg.c +98 -77
  166. data/aws-crt-ffi/crt/s2n/crypto/s2n_drbg.h +10 -7
  167. data/aws-crt-ffi/crt/s2n/crypto/s2n_openssl.h +2 -0
  168. data/aws-crt-ffi/crt/s2n/error/s2n_errno.c +1 -1
  169. data/aws-crt-ffi/crt/s2n/error/s2n_errno.h +1 -0
  170. data/aws-crt-ffi/crt/s2n/s2n.mk +7 -0
  171. data/aws-crt-ffi/crt/s2n/tests/cbmc/templates/scripts/repository.py +233 -0
  172. data/aws-crt-ffi/crt/s2n/tests/cbmc/templates/scripts/setup-proof.py +8 -7
  173. data/aws-crt-ffi/crt/s2n/tests/cbmc/templates/scripts/setup.py +17 -18
  174. data/aws-crt-ffi/crt/s2n/tests/cbmc/templates/scripts/util.py +41 -23
  175. data/aws-crt-ffi/crt/s2n/tests/fuzz/LD_PRELOAD/global_overrides.c +3 -3
  176. data/aws-crt-ffi/crt/s2n/tests/integration/s2n_client_endpoint_handshake_test.py +2 -2
  177. data/aws-crt-ffi/crt/s2n/tests/integrationv2/Makefile +13 -42
  178. data/aws-crt-ffi/crt/s2n/tests/integrationv2/README.md +6 -1
  179. data/aws-crt-ffi/crt/s2n/tests/integrationv2/common.py +118 -53
  180. data/aws-crt-ffi/crt/s2n/tests/integrationv2/configuration.py +108 -88
  181. data/aws-crt-ffi/crt/s2n/tests/integrationv2/conftest.py +6 -3
  182. data/aws-crt-ffi/crt/s2n/tests/integrationv2/constants.py +6 -4
  183. data/aws-crt-ffi/crt/s2n/tests/integrationv2/fixtures.py +21 -12
  184. data/aws-crt-ffi/crt/s2n/tests/integrationv2/global_flags.py +1 -0
  185. data/aws-crt-ffi/crt/s2n/tests/integrationv2/processes.py +62 -19
  186. data/aws-crt-ffi/crt/s2n/tests/integrationv2/providers.py +304 -48
  187. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_client_authentication.py +20 -11
  188. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_cross_compatibility.py +41 -17
  189. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_dynamic_record_sizes.py +6 -3
  190. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_early_data.py +105 -48
  191. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_external_psk.py +160 -76
  192. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_fragmentation.py +59 -26
  193. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_happy_path.py +42 -28
  194. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_hello_retry_requests.py +33 -13
  195. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_key_update.py +29 -11
  196. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_ocsp.py +138 -0
  197. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_pq_handshake.py +103 -36
  198. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_session_resumption.py +52 -25
  199. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_signature_algorithms.py +47 -21
  200. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_sni_match.py +13 -9
  201. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_sslyze.py +88 -17
  202. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_version_negotiation.py +71 -22
  203. data/aws-crt-ffi/crt/s2n/tests/integrationv2/test_well_known_endpoints.py +4 -3
  204. data/aws-crt-ffi/crt/s2n/tests/integrationv2/tox.ini +1 -0
  205. data/aws-crt-ffi/crt/s2n/tests/integrationv2/utils.py +50 -15
  206. data/aws-crt-ffi/crt/s2n/tests/litani/CHANGELOG +131 -0
  207. data/aws-crt-ffi/crt/s2n/tests/litani/CONTRIBUTING.md +16 -0
  208. data/aws-crt-ffi/crt/s2n/tests/litani/README.md +36 -14
  209. data/aws-crt-ffi/crt/s2n/tests/litani/THIRD-PARTY +205 -41
  210. data/aws-crt-ffi/crt/s2n/tests/litani/doc/bin/build-html-doc +7 -7
  211. data/aws-crt-ffi/crt/s2n/tests/litani/doc/configure +27 -23
  212. data/aws-crt-ffi/crt/s2n/tests/litani/doc/src/man/litani-add-job.scdoc +7 -0
  213. data/aws-crt-ffi/crt/s2n/tests/litani/doc/src/man/litani-dump-run.scdoc +7 -5
  214. data/aws-crt-ffi/crt/s2n/tests/litani/doc/src/man/litani-transform-jobs.scdoc +248 -0
  215. data/aws-crt-ffi/crt/s2n/tests/litani/doc/src/man/litani.scdoc +2 -2
  216. data/aws-crt-ffi/crt/s2n/tests/litani/doc/templates/index.jinja.html +4 -0
  217. data/aws-crt-ffi/crt/s2n/tests/litani/examples/add-root-node/README +12 -0
  218. data/aws-crt-ffi/crt/s2n/tests/litani/examples/add-root-node/original-run.sh +52 -0
  219. data/aws-crt-ffi/crt/s2n/tests/litani/examples/add-root-node/run-all.py +71 -0
  220. data/aws-crt-ffi/crt/s2n/tests/litani/examples/no-standalone-transform/README +13 -0
  221. data/aws-crt-ffi/crt/s2n/tests/litani/examples/no-standalone-transform/run-1.sh +34 -0
  222. data/aws-crt-ffi/crt/s2n/tests/litani/examples/no-standalone-transform/run-2.sh +35 -0
  223. data/aws-crt-ffi/crt/s2n/tests/litani/examples/no-standalone-transform/run-3.sh +34 -0
  224. data/aws-crt-ffi/crt/s2n/tests/litani/examples/no-standalone-transform/run-all.py +60 -0
  225. data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/README.md +10 -0
  226. data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/assumptions.html +42 -0
  227. data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/file.dat +7 -0
  228. data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/histogram.dat +7 -0
  229. data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/run-1.sh +41 -0
  230. data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/run-2.sh +47 -0
  231. data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/run-3.sh +41 -0
  232. data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/run-all.py +34 -0
  233. data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/scripts/fib-table.py +40 -0
  234. data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/scripts/fib.plt +5 -0
  235. data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/scripts/fib.py +32 -0
  236. data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/scripts/sin-output.py +40 -0
  237. data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/scripts/sin.plt +5 -0
  238. data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/scripts/sin.py +30 -0
  239. data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/templates/fib-table.jinja.html +45 -0
  240. data/aws-crt-ffi/crt/s2n/tests/litani/examples/rich-output/templates/sin-output.jinja.html +30 -0
  241. data/aws-crt-ffi/crt/s2n/tests/litani/lib/add_job.py +55 -0
  242. data/aws-crt-ffi/crt/s2n/tests/litani/lib/graph.py +2 -2
  243. data/aws-crt-ffi/crt/s2n/tests/litani/lib/litani.py +6 -1
  244. data/aws-crt-ffi/crt/s2n/tests/litani/lib/litani_report.py +18 -21
  245. data/aws-crt-ffi/crt/s2n/tests/litani/lib/ninja.py +2 -0
  246. data/aws-crt-ffi/crt/s2n/tests/litani/lib/run_printer.py +26 -7
  247. data/aws-crt-ffi/crt/s2n/tests/litani/lib/transform_jobs.py +84 -0
  248. data/aws-crt-ffi/crt/s2n/tests/litani/litani +28 -33
  249. data/aws-crt-ffi/crt/s2n/tests/litani/script/release +220 -0
  250. data/aws-crt-ffi/crt/s2n/tests/litani/templates/dashboard.jinja.html +78 -15
  251. data/aws-crt-ffi/crt/s2n/tests/litani/templates/pipeline.jinja.html +21 -5
  252. data/aws-crt-ffi/crt/s2n/tests/litani/test/README +15 -0
  253. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/run +56 -33
  254. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/custom_stages.py +1 -0
  255. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/cwd.py +1 -0
  256. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/dump_run.py +1 -0
  257. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/graph_line_break.py +1 -0
  258. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/html_node.py +1 -0
  259. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/job_id_env.py +1 -0
  260. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/multiproc_dump_run.py +1 -0
  261. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/no_pool_serialize.py +1 -0
  262. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/no_pool_serialize_graph.py +1 -0
  263. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/no_timed_out.py +1 -0
  264. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/no_timed_out_timeout_ignored.py +1 -0
  265. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/no_timed_out_timeout_ok.py +1 -0
  266. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/pipeline_order.py +53 -0
  267. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/pool_serialize.py +1 -0
  268. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/pool_serialize_graph.py +1 -0
  269. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/single_pool.py +1 -0
  270. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/timed_out.py +1 -0
  271. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/timed_out_subprocess.py +1 -0
  272. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/timed_out_subprocess_multi_shell.py +1 -0
  273. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/timed_out_subprocess_shell.py +1 -0
  274. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/timed_out_timeout_ignored.py +1 -0
  275. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/timed_out_timeout_ok.py +1 -0
  276. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/transform_delete_job.py +54 -0
  277. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/transform_modify_job.py +46 -0
  278. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/transform_no_change_job.py +44 -0
  279. data/aws-crt-ffi/crt/s2n/tests/litani/test/e2e/tests/zero_pool.py +1 -0
  280. data/aws-crt-ffi/crt/s2n/tests/litani/test/run +82 -12
  281. data/aws-crt-ffi/crt/s2n/tests/s2n_test.h +58 -33
  282. data/aws-crt-ffi/crt/s2n/tests/testlib/s2n_key_schedule_testlib.c +18 -6
  283. data/aws-crt-ffi/crt/s2n/tests/testlib/s2n_pq_kat_test_utils.c +4 -4
  284. data/aws-crt-ffi/crt/s2n/tests/testlib/s2n_testlib.h +2 -0
  285. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_client_hello_retry_test.c +66 -2
  286. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_connection_test.c +1 -1
  287. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_drbg_test.c +34 -14
  288. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_fork_generation_number_test.c +28 -5
  289. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_mem_usage_test.c +6 -0
  290. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_override_openssl_random_test.c +1 -1
  291. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_random_test.c +60 -41
  292. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_self_talk_broken_pipe_test.c +2 -2
  293. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_tls13_handshake_early_data_test.c +3 -1
  294. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_tls13_hybrid_shared_secret_test.c +9 -1
  295. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_tls13_key_schedule_rfc8448_test.c +31 -130
  296. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_tls13_key_schedule_test.c +2 -4
  297. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_tls13_pq_handshake_test.c +11 -6
  298. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_tls13_secrets_rfc8448_test.c +19 -21
  299. data/aws-crt-ffi/crt/s2n/tests/unit/s2n_tls13_secrets_test.c +109 -60
  300. data/aws-crt-ffi/crt/s2n/tls/s2n_config.c +1 -0
  301. data/aws-crt-ffi/crt/s2n/tls/s2n_config.h +1 -1
  302. data/aws-crt-ffi/crt/s2n/tls/s2n_connection.c +29 -24
  303. data/aws-crt-ffi/crt/s2n/tls/s2n_connection.h +5 -5
  304. data/aws-crt-ffi/crt/s2n/tls/s2n_handshake_hashes.h +1 -7
  305. data/aws-crt-ffi/crt/s2n/tls/s2n_handshake_io.c +2 -0
  306. data/aws-crt-ffi/crt/s2n/tls/s2n_handshake_transcript.c +0 -44
  307. data/aws-crt-ffi/crt/s2n/tls/s2n_internal.h +0 -1
  308. data/aws-crt-ffi/crt/s2n/tls/s2n_quic_support.h +1 -1
  309. data/aws-crt-ffi/crt/s2n/tls/s2n_tls13_key_schedule.c +1 -2
  310. data/aws-crt-ffi/crt/s2n/tls/s2n_tls13_secrets.c +84 -44
  311. data/aws-crt-ffi/crt/s2n/tls/s2n_tls13_secrets.h +3 -9
  312. data/aws-crt-ffi/crt/s2n/utils/s2n_blob.h +15 -8
  313. data/aws-crt-ffi/crt/s2n/utils/s2n_fork_detection.c +2 -6
  314. data/aws-crt-ffi/crt/s2n/utils/s2n_random.c +9 -9
  315. data/aws-crt-ffi/src/input_stream.c +32 -15
  316. data/ext/compile.rb +13 -5
  317. data/lib/aws-crt/platforms.rb +14 -5
  318. data/lib/aws-crt/string_blob.rb +3 -3
  319. metadata +61 -7
  320. data/aws-crt-ffi/crt/aws-c-auth/source/external/cJSON.c +0 -2987
  321. data/aws-crt-ffi/crt/aws-c-auth/tests/external/cJSON.c +0 -2986
  322. data/aws-crt-ffi/crt/aws-c-io/tests/error_test.c +0 -20
@@ -25,12 +25,23 @@ enum aws_h2_sm_connection_state_type {
25
25
  /* Live with the streams opening, and if there no outstanding pending acquisition and no opening streams on the
26
26
  * connection, this structure should die */
27
27
  struct aws_h2_sm_connection {
28
+ struct aws_allocator *allocator;
28
29
  struct aws_http2_stream_manager *stream_manager;
29
30
  struct aws_http_connection *connection;
30
31
  uint32_t num_streams_assigned; /* From a stream assigned to the connection until the stream completed
31
32
  or failed to be created from the connection. */
32
33
  uint32_t max_concurrent_streams; /* lower bound between user configured and the other side */
33
34
 
35
+ /* task to send ping periodically from connection thread. */
36
+ struct aws_ref_count ref_count;
37
+ struct aws_channel_task ping_task;
38
+ struct aws_channel_task ping_timeout_task;
39
+ struct {
40
+ bool ping_received;
41
+ bool stopped_new_requests;
42
+ uint64_t next_ping_task_time;
43
+ } thread_data;
44
+
34
45
  enum aws_h2_sm_connection_state_type state;
35
46
  };
36
47
 
@@ -82,7 +93,13 @@ struct aws_http2_stream_manager {
82
93
  struct aws_ref_count internal_ref_count;
83
94
  struct aws_client_bootstrap *bootstrap;
84
95
 
96
+ /* Configurations */
85
97
  size_t max_connections;
98
+ /* Connection will be closed if 5xx response received from server. */
99
+ bool close_connection_on_server_error;
100
+
101
+ uint64_t connection_ping_period_ns;
102
+ uint64_t connection_ping_timeout_ns;
86
103
 
87
104
  /**
88
105
  * Default is no limit. 0 will be considered as using the default value.
@@ -64,6 +64,9 @@ enum aws_http_header_name {
64
64
  AWS_HTTP_HEADER_RETRY_AFTER,
65
65
  AWS_HTTP_HEADER_VARY,
66
66
  AWS_HTTP_HEADER_WARNING,
67
+ AWS_HTTP_HEADER_UPGRADE,
68
+ AWS_HTTP_HEADER_KEEP_ALIVE,
69
+ AWS_HTTP_HEADER_PROXY_CONNECTION,
67
70
 
68
71
  AWS_HTTP_HEADER_COUNT, /* Number of enums */
69
72
  };
@@ -64,16 +64,23 @@ int aws_random_access_set_remove(struct aws_random_access_set *set, const void *
64
64
  * Get the pointer to a random element from the data structure. Fails when the data structure is empty.
65
65
  */
66
66
  AWS_HTTP_API
67
- int aws_random_access_set_random_get_ptr(struct aws_random_access_set *set, void **out);
67
+ int aws_random_access_set_random_get_ptr(const struct aws_random_access_set *set, void **out);
68
68
 
69
69
  AWS_HTTP_API
70
- size_t aws_random_access_set_get_size(struct aws_random_access_set *set);
70
+ size_t aws_random_access_set_get_size(const struct aws_random_access_set *set);
71
71
 
72
72
  /**
73
73
  * Check the element exist in the data structure or not.
74
74
  */
75
75
  AWS_HTTP_API
76
- int aws_random_access_set_exist(struct aws_random_access_set *set, const void *element, bool *exist);
76
+ int aws_random_access_set_exist(const struct aws_random_access_set *set, const void *element, bool *exist);
77
+
78
+ /**
79
+ * Get the pointer to an element that currently stored at that index. It may change if operations like remove and add
80
+ * happens. Helpful for debugging and iterating through the whole set.
81
+ */
82
+ AWS_HTTP_API
83
+ int aws_random_access_set_random_get_ptr_index(const struct aws_random_access_set *set, void **out, size_t index);
77
84
 
78
85
  AWS_EXTERN_C_END
79
86
  #endif /* AWS_HTTP_RANDOM_ACCESS_SET_H */
@@ -23,6 +23,9 @@ struct aws_http_stream_vtable {
23
23
  int (*http2_reset_stream)(struct aws_http_stream *http2_stream, uint32_t http2_error);
24
24
  int (*http2_get_received_error_code)(struct aws_http_stream *http2_stream, uint32_t *http2_error);
25
25
  int (*http2_get_sent_error_code)(struct aws_http_stream *http2_stream, uint32_t *http2_error);
26
+ int (*http2_write_data)(
27
+ struct aws_http_stream *http2_stream,
28
+ const struct aws_http2_stream_write_data_options *options);
26
29
  };
27
30
 
28
31
  /**
@@ -62,21 +65,4 @@ struct aws_http_stream {
62
65
  struct aws_http_stream_server_data *server_data;
63
66
  };
64
67
 
65
- AWS_EXTERN_C_BEGIN
66
-
67
- /**
68
- * Create an HTTP/2 message from HTTP/1.1 message.
69
- * pseudo headers will be created from the context and added to the headers of new message.
70
- * Normal headers will be copied to the headers of new message.
71
- * Note: `host` will stay and `:authority` will not be set. (RFC-7540 8.1.2.3). Some sever don't support it.
72
- * TODO: (Maybe more, connection-specific header will be removed, etc...)
73
- * TODO: REFCOUNT INPUT_STREAMS!!! And make it public.
74
- */
75
- AWS_HTTP_API
76
- struct aws_http_message *aws_http2_message_new_from_http1(
77
- struct aws_http_message *http1_msg,
78
- struct aws_allocator *alloc);
79
-
80
- AWS_EXTERN_C_END
81
-
82
68
  #endif /* AWS_HTTP_REQUEST_RESPONSE_IMPL_H */
@@ -233,6 +233,12 @@ struct aws_http_make_request_options {
233
233
  * See `aws_http_on_stream_complete_fn`.
234
234
  */
235
235
  aws_http_on_stream_complete_fn *on_complete;
236
+
237
+ /**
238
+ * When using HTTP/2, request body data will be provided over time. The stream will only be polled for writing
239
+ * when data has been supplied via `aws_http2_stream_write_data`
240
+ */
241
+ bool http2_use_manual_data_writes;
236
242
  };
237
243
 
238
244
  struct aws_http_request_handler_options {
@@ -286,6 +292,21 @@ struct aws_http_request_handler_options {
286
292
  aws_http_on_stream_complete_fn *on_complete;
287
293
  };
288
294
 
295
+ /**
296
+ * Invoked when the data stream of an outgoing HTTP write operation is no longer in use.
297
+ * This is always invoked on the HTTP connection's event-loop thread.
298
+ *
299
+ * @param stream HTTP-stream this write operation was submitted to.
300
+ * @param error_code If error_code is AWS_ERROR_SUCCESS (0), the data was successfully sent.
301
+ * Any other error_code indicates that the HTTP-stream is in the process of terminating.
302
+ * If the error_code is AWS_ERROR_HTTP_STREAM_HAS_COMPLETED,
303
+ * the stream's termination has nothing to do with this write operation.
304
+ * Any other non-zero error code indicates a problem with this particular write
305
+ * operation's data.
306
+ * @param user_data User data for this write operation.
307
+ */
308
+ typedef void aws_http_stream_write_complete_fn(struct aws_http_stream *stream, int error_code, void *user_data);
309
+
289
310
  /**
290
311
  * Invoked when the data of an outgoing HTTP/1.1 chunk is no longer in use.
291
312
  * This is always invoked on the HTTP connection's event-loop thread.
@@ -298,7 +319,7 @@ struct aws_http_request_handler_options {
298
319
  * Any other non-zero error code indicates a problem with this particular chunk's data.
299
320
  * @param user_data User data for this chunk.
300
321
  */
301
- typedef void aws_http1_stream_write_chunk_complete_fn(struct aws_http_stream *stream, int error_code, void *user_data);
322
+ typedef aws_http_stream_write_complete_fn aws_http1_stream_write_chunk_complete_fn;
302
323
 
303
324
  /**
304
325
  * HTTP/1.1 chunk extension for chunked encoding.
@@ -356,6 +377,50 @@ struct aws_http1_chunk_options {
356
377
  void *user_data;
357
378
  };
358
379
 
380
+ /**
381
+ * Invoked when the data of an outgoing HTTP2 data frame is no longer in use.
382
+ * This is always invoked on the HTTP connection's event-loop thread.
383
+ *
384
+ * @param stream HTTP2-stream this write was submitted to.
385
+ * @param error_code If error_code is AWS_ERROR_SUCCESS (0), the data was successfully sent.
386
+ * Any other error_code indicates that the HTTP-stream is in the process of terminating.
387
+ * If the error_code is AWS_ERROR_HTTP_STREAM_HAS_COMPLETED,
388
+ * the stream's termination has nothing to do with this write.
389
+ * Any other non-zero error code indicates a problem with this particular write's data.
390
+ * @param user_data User data for this write.
391
+ */
392
+ typedef aws_http_stream_write_complete_fn aws_http2_stream_write_data_complete_fn;
393
+
394
+ /**
395
+ * Encoding options for manual H2 data frame writes
396
+ */
397
+ struct aws_http2_stream_write_data_options {
398
+ /**
399
+ * The data to be sent.
400
+ * Optional.
401
+ * If not set, input stream with length 0 will be used.
402
+ */
403
+ struct aws_input_stream *data;
404
+
405
+ /**
406
+ * Set true when it's the last chunk to be sent.
407
+ * After a write with end_stream, no more data write will be accepted.
408
+ */
409
+ bool end_stream;
410
+
411
+ /**
412
+ * Invoked when the data stream is no longer in use, whether or not it was successfully sent.
413
+ * Optional.
414
+ * See `aws_http2_stream_write_data_complete_fn`.
415
+ */
416
+ aws_http2_stream_write_data_complete_fn *on_complete;
417
+
418
+ /**
419
+ * User provided data passed to the on_complete callback on its invocation.
420
+ */
421
+ void *user_data;
422
+ };
423
+
359
424
  #define AWS_HTTP_REQUEST_HANDLER_OPTIONS_INIT \
360
425
  { .self_size = sizeof(struct aws_http_request_handler_options), }
361
426
 
@@ -612,6 +677,18 @@ struct aws_http_message *aws_http2_message_new_request(struct aws_allocator *all
612
677
  AWS_HTTP_API
613
678
  struct aws_http_message *aws_http2_message_new_response(struct aws_allocator *allocator);
614
679
 
680
+ /**
681
+ * Create an HTTP/2 message from HTTP/1.1 message.
682
+ * pseudo headers will be created from the context and added to the headers of new message.
683
+ * Normal headers will be copied to the headers of new message.
684
+ * Note: if `host` exist, it will stay and `:authority` will be added using the information.
685
+ * `:scheme` is default to be "https". If a different scheme wants to be used, create the HTTP/2 message directly
686
+ */
687
+ AWS_HTTP_API
688
+ struct aws_http_message *aws_http2_message_new_from_http1(
689
+ struct aws_allocator *alloc,
690
+ const struct aws_http_message *http1_msg);
691
+
615
692
  /**
616
693
  * Acquire a hold on the object, preventing it from being deleted until
617
694
  * aws_http_message_release() is called by all those with a hold on it.
@@ -728,9 +805,37 @@ AWS_HTTP_API int aws_http1_stream_write_chunk(
728
805
  struct aws_http_stream *http1_stream,
729
806
  const struct aws_http1_chunk_options *options);
730
807
 
808
+ /**
809
+ * The stream must have specified `http2_use_manual_data_writes` during request creation.
810
+ * For client streams, activate() must be called before any frames are submitted.
811
+ * For server streams, the response headers must be submitted before any frames.
812
+ * A write with options that has end_stream set to be true will end the stream and prevent any further write.
813
+ *
814
+ * @return AWS_OP_SUCCESS if the write was queued
815
+ * AWS_OP_ERROR indicating the attempt raised an error code.
816
+ * AWS_ERROR_INVALID_STATE will be raised for invalid usage.
817
+ * AWS_ERROR_HTTP_STREAM_HAS_COMPLETED will be raised if the stream ended for reasons behind the scenes.
818
+ *
819
+ * Typical usage will be something like:
820
+ * options.http2_use_manual_data_writes = true;
821
+ * stream = aws_http_connection_make_request(connection, &options);
822
+ * aws_http_stream_activate(stream);
823
+ * ...
824
+ * struct aws_http2_stream_write_data_options write;
825
+ * aws_http2_stream_write_data(stream, &write);
826
+ * ...
827
+ * struct aws_http2_stream_write_data_options last_write;
828
+ * last_write.end_stream = true;
829
+ * aws_http2_stream_write_data(stream, &write);
830
+ * ...
831
+ * aws_http_stream_release(stream);
832
+ */
833
+ AWS_HTTP_API int aws_http2_stream_write_data(
834
+ struct aws_http_stream *http2_stream,
835
+ const struct aws_http2_stream_write_data_options *options);
836
+
731
837
  /**
732
838
  * Add a list of headers to be added as trailing headers sent after the last chunk is sent.
733
- * The stream must have specified "chunked" in a "transfer-encoding" header. The stream should also have
734
839
  * a "Trailer" header field which indicates the fields present in the trailer.
735
840
  *
736
841
  * Certain headers are forbidden in the trailer (e.g., Transfer-Encoding, Content-Length, Host). See RFC-7541
@@ -750,13 +855,12 @@ AWS_HTTP_API int aws_http1_stream_add_chunked_trailer(
750
855
  const struct aws_http_headers *trailing_headers);
751
856
 
752
857
  /**
753
- * Get the message's aws_http_headers.
754
858
  *
755
859
  * This datastructure has more functions for inspecting and modifying headers than
756
860
  * are available on the aws_http_message datastructure.
757
861
  */
758
862
  AWS_HTTP_API
759
- struct aws_http_headers *aws_http_message_get_headers(struct aws_http_message *message);
863
+ struct aws_http_headers *aws_http_message_get_headers(const struct aws_http_message *message);
760
864
 
761
865
  /**
762
866
  * Get the message's const aws_http_headers.
@@ -12,6 +12,7 @@
12
12
 
13
13
  enum aws_crt_http_statistics_category {
14
14
  AWSCRT_STAT_CAT_HTTP1_CHANNEL = AWS_CRT_STATISTICS_CATEGORY_BEGIN_RANGE(AWS_C_HTTP_PACKAGE_ID),
15
+ AWSCRT_STAT_CAT_HTTP2_CHANNEL,
15
16
  };
16
17
 
17
18
  /**
@@ -28,6 +29,16 @@ struct aws_crt_statistics_http1_channel {
28
29
  uint32_t current_incoming_stream_id;
29
30
  };
30
31
 
32
+ struct aws_crt_statistics_http2_channel {
33
+ aws_crt_statistics_category_t category;
34
+
35
+ uint64_t pending_outgoing_stream_ms;
36
+ uint64_t pending_incoming_stream_ms;
37
+
38
+ /* True if during the time of report, there has ever been no active streams on the connection */
39
+ bool was_inactive;
40
+ };
41
+
31
42
  AWS_EXTERN_C_BEGIN
32
43
 
33
44
  /**
@@ -48,6 +59,17 @@ void aws_crt_statistics_http1_channel_cleanup(struct aws_crt_statistics_http1_ch
48
59
  AWS_HTTP_API
49
60
  void aws_crt_statistics_http1_channel_reset(struct aws_crt_statistics_http1_channel *stats);
50
61
 
62
+ /**
63
+ * Initializes a HTTP/2 channel handler statistics struct
64
+ */
65
+ AWS_HTTP_API
66
+ void aws_crt_statistics_http2_channel_init(struct aws_crt_statistics_http2_channel *stats);
67
+ /**
68
+ * Resets a HTTP/2 channel handler statistics struct's statistics
69
+ */
70
+ AWS_HTTP_API
71
+ void aws_crt_statistics_http2_channel_reset(struct aws_crt_statistics_http2_channel *stats);
72
+
51
73
  AWS_EXTERN_C_END
52
74
 
53
75
  #endif /* AWS_HTTP_STATISTICS_H */
@@ -174,6 +174,7 @@ struct aws_http_connection *aws_http_connection_new_channel_handler(
174
174
  }
175
175
  } else {
176
176
  if (prior_knowledge_http2) {
177
+ AWS_LOGF_TRACE(AWS_LS_HTTP_CONNECTION, "Using prior knowledge to start HTTP/2 connection");
177
178
  version = AWS_HTTP_VERSION_2;
178
179
  }
179
180
  }
@@ -253,6 +254,11 @@ void aws_http_connection_close(struct aws_http_connection *connection) {
253
254
  connection->vtable->close(connection);
254
255
  }
255
256
 
257
+ void aws_http_connection_stop_new_requests(struct aws_http_connection *connection) {
258
+ AWS_ASSERT(connection);
259
+ connection->vtable->stop_new_requests(connection);
260
+ }
261
+
256
262
  bool aws_http_connection_is_open(const struct aws_http_connection *connection) {
257
263
  AWS_ASSERT(connection);
258
264
  return connection->vtable->is_open(connection);
@@ -295,7 +301,7 @@ int aws_http2_connection_ping(
295
301
  return http2_connection->vtable->send_ping(http2_connection, optional_opaque_data, on_ack, user_data);
296
302
  }
297
303
 
298
- int aws_http2_connection_send_goaway(
304
+ void aws_http2_connection_send_goaway(
299
305
  struct aws_http_connection *http2_connection,
300
306
  uint32_t http2_error,
301
307
  bool allow_more_streams,
@@ -303,8 +309,7 @@ int aws_http2_connection_send_goaway(
303
309
  AWS_ASSERT(http2_connection);
304
310
  AWS_PRECONDITION(http2_connection->vtable);
305
311
  AWS_FATAL_ASSERT(http2_connection->http_version == AWS_HTTP_VERSION_2);
306
- return http2_connection->vtable->send_goaway(
307
- http2_connection, http2_error, allow_more_streams, optional_debug_data);
312
+ http2_connection->vtable->send_goaway(http2_connection, http2_error, allow_more_streams, optional_debug_data);
308
313
  }
309
314
 
310
315
  int aws_http2_connection_get_sent_goaway(
@@ -240,7 +240,7 @@ struct aws_http_connection_manager {
240
240
  /*
241
241
  * HTTP/2 specific.
242
242
  */
243
- bool prior_knowledge_http2;
243
+ bool http2_prior_knowledge;
244
244
  struct aws_array_list *initial_settings;
245
245
  size_t max_closed_streams;
246
246
  bool http2_conn_manual_window_management;
@@ -812,6 +812,13 @@ struct aws_http_connection_manager *aws_http_connection_manager_new(
812
812
  return NULL;
813
813
  }
814
814
 
815
+ if (options->tls_connection_options && options->http2_prior_knowledge) {
816
+ AWS_LOGF_ERROR(
817
+ AWS_LS_HTTP_CONNECTION_MANAGER, "Invalid options - HTTP/2 prior knowledge cannot be set when TLS is used");
818
+ aws_raise_error(AWS_ERROR_INVALID_ARGUMENT);
819
+ return NULL;
820
+ }
821
+
815
822
  struct aws_http_connection_manager *manager =
816
823
  aws_mem_calloc(allocator, 1, sizeof(struct aws_http_connection_manager));
817
824
  if (manager == NULL) {
@@ -876,7 +883,7 @@ struct aws_http_connection_manager *aws_http_connection_manager_new(
876
883
  }
877
884
  manager->proxy_ev_settings.tls_options = manager->proxy_ev_tls_options;
878
885
  }
879
- manager->prior_knowledge_http2 = options->prior_knowledge_http2;
886
+ manager->http2_prior_knowledge = options->http2_prior_knowledge;
880
887
  if (options->num_initial_settings > 0) {
881
888
  manager->initial_settings = aws_mem_calloc(allocator, 1, sizeof(struct aws_array_list));
882
889
  aws_array_list_init_dynamic(
@@ -988,7 +995,7 @@ static int s_aws_http_connection_manager_new_connection(struct aws_http_connecti
988
995
  options.on_shutdown = s_aws_http_connection_manager_on_connection_shutdown;
989
996
  options.manual_window_management = manager->enable_read_back_pressure;
990
997
  options.proxy_ev_settings = &manager->proxy_ev_settings;
991
- options.prior_knowledge_http2 = manager->prior_knowledge_http2;
998
+ options.prior_knowledge_http2 = manager->http2_prior_knowledge;
992
999
 
993
1000
  struct aws_http2_connection_options h2_options;
994
1001
  AWS_ZERO_STRUCT(h2_options);
@@ -1538,3 +1545,15 @@ static void s_cull_task(struct aws_task *task, void *arg, enum aws_task_status s
1538
1545
 
1539
1546
  s_schedule_connection_culling(manager);
1540
1547
  }
1548
+
1549
+ void aws_http_connection_manager_fetch_metrics(
1550
+ const struct aws_http_connection_manager *manager,
1551
+ struct aws_http_manager_metrics *out_metrics) {
1552
+ AWS_PRECONDITION(manager);
1553
+ AWS_PRECONDITION(out_metrics);
1554
+
1555
+ AWS_FATAL_ASSERT(aws_mutex_lock((struct aws_mutex *)(void *)&manager->lock) == AWS_OP_SUCCESS);
1556
+ out_metrics->available_concurrency = manager->idle_connection_count;
1557
+ out_metrics->pending_concurrency_acquires = manager->pending_acquisition_count;
1558
+ AWS_FATAL_ASSERT(aws_mutex_unlock((struct aws_mutex *)(void *)&manager->lock) == AWS_OP_SUCCESS);
1559
+ }
@@ -32,13 +32,16 @@ static void s_process_statistics(
32
32
  uint64_t pending_write_interval_ms = 0;
33
33
  uint64_t bytes_read = 0;
34
34
  uint64_t bytes_written = 0;
35
- uint32_t current_outgoing_stream_id = 0;
36
- uint32_t current_incoming_stream_id = 0;
35
+ uint32_t h1_current_outgoing_stream_id = 0;
36
+ uint32_t h1_current_incoming_stream_id = 0;
37
37
 
38
38
  /*
39
39
  * Pull out the data needed to perform the throughput calculation
40
40
  */
41
41
  size_t stats_count = aws_array_list_length(stats_list);
42
+ bool h2 = false;
43
+ bool h2_was_inactive = false;
44
+
42
45
  for (size_t i = 0; i < stats_count; ++i) {
43
46
  struct aws_crt_statistics_base *stats_base = NULL;
44
47
  if (aws_array_list_get_at(stats_list, &stats_base, i)) {
@@ -54,13 +57,24 @@ static void s_process_statistics(
54
57
  }
55
58
 
56
59
  case AWSCRT_STAT_CAT_HTTP1_CHANNEL: {
60
+ AWS_ASSERT(!h2);
57
61
  struct aws_crt_statistics_http1_channel *http1_stats =
58
62
  (struct aws_crt_statistics_http1_channel *)stats_base;
59
63
  pending_read_interval_ms = http1_stats->pending_incoming_stream_ms;
60
64
  pending_write_interval_ms = http1_stats->pending_outgoing_stream_ms;
61
- current_outgoing_stream_id = http1_stats->current_outgoing_stream_id;
62
- current_incoming_stream_id = http1_stats->current_incoming_stream_id;
65
+ h1_current_outgoing_stream_id = http1_stats->current_outgoing_stream_id;
66
+ h1_current_incoming_stream_id = http1_stats->current_incoming_stream_id;
67
+
68
+ break;
69
+ }
63
70
 
71
+ case AWSCRT_STAT_CAT_HTTP2_CHANNEL: {
72
+ struct aws_crt_statistics_http2_channel *h2_stats =
73
+ (struct aws_crt_statistics_http2_channel *)stats_base;
74
+ pending_read_interval_ms = h2_stats->pending_incoming_stream_ms;
75
+ pending_write_interval_ms = h2_stats->pending_outgoing_stream_ms;
76
+ h2_was_inactive |= h2_stats->was_inactive;
77
+ h2 = true;
64
78
  break;
65
79
  }
66
80
 
@@ -110,17 +124,21 @@ static void s_process_statistics(
110
124
  bytes_per_second);
111
125
 
112
126
  /*
113
- * Check throughput only if at least one stream exists and was observed in that role previously
114
- *
115
- * ToDo: This logic only makes sense from an h1 perspective. A similar requirement could be placed on
116
- * h2 stats by analyzing/tracking the min and max stream ids (per odd/even) at process timepoints.
127
+ * Check throughput only if the connection has active stream and no gap between.
117
128
  */
118
- bool check_throughput =
119
- (current_incoming_stream_id != 0 && current_incoming_stream_id == impl->last_incoming_stream_id) ||
120
- (current_outgoing_stream_id != 0 && current_outgoing_stream_id == impl->last_outgoing_stream_id);
121
-
122
- impl->last_outgoing_stream_id = current_outgoing_stream_id;
123
- impl->last_incoming_stream_id = current_incoming_stream_id;
129
+ bool check_throughput = false;
130
+ if (h2) {
131
+ /* For HTTP/2, check throughput only if there always has any active stream on the connection */
132
+ check_throughput = !h2_was_inactive;
133
+ } else {
134
+ /* For HTTP/1, check throughput only if at least one stream exists and was observed in that role previously */
135
+ check_throughput =
136
+ (h1_current_incoming_stream_id != 0 && h1_current_incoming_stream_id == impl->last_incoming_stream_id) ||
137
+ (h1_current_outgoing_stream_id != 0 && h1_current_outgoing_stream_id == impl->last_outgoing_stream_id);
138
+
139
+ impl->last_outgoing_stream_id = h1_current_outgoing_stream_id;
140
+ impl->last_incoming_stream_id = h1_current_incoming_stream_id;
141
+ }
124
142
  impl->last_measured_throughput = bytes_per_second;
125
143
 
126
144
  if (!check_throughput) {
@@ -56,6 +56,7 @@ static struct aws_http_stream *s_new_server_request_handler_stream(
56
56
  const struct aws_http_request_handler_options *options);
57
57
  static int s_stream_send_response(struct aws_http_stream *stream, struct aws_http_message *response);
58
58
  static void s_connection_close(struct aws_http_connection *connection_base);
59
+ static void s_connection_stop_new_request(struct aws_http_connection *connection_base);
59
60
  static bool s_connection_is_open(const struct aws_http_connection *connection_base);
60
61
  static bool s_connection_new_requests_allowed(const struct aws_http_connection *connection_base);
61
62
  static int s_decoder_on_request(
@@ -90,6 +91,7 @@ static struct aws_http_connection_vtable s_h1_connection_vtable = {
90
91
  .new_server_request_handler_stream = s_new_server_request_handler_stream,
91
92
  .stream_send_response = s_stream_send_response,
92
93
  .close = s_connection_close,
94
+ .stop_new_requests = s_connection_stop_new_request,
93
95
  .is_open = s_connection_is_open,
94
96
  .new_requests_allowed = s_connection_new_requests_allowed,
95
97
  .change_settings = NULL,
@@ -196,6 +198,18 @@ static void s_connection_close(struct aws_http_connection *connection_base) {
196
198
  s_stop(connection, false /*stop_reading*/, false /*stop_writing*/, true /*schedule_shutdown*/, AWS_ERROR_SUCCESS);
197
199
  }
198
200
 
201
+ static void s_connection_stop_new_request(struct aws_http_connection *connection_base) {
202
+ struct aws_h1_connection *connection = AWS_CONTAINER_OF(connection_base, struct aws_h1_connection, base);
203
+
204
+ { /* BEGIN CRITICAL SECTION */
205
+ aws_h1_connection_lock_synced_data(connection);
206
+ if (!connection->synced_data.new_stream_error_code) {
207
+ connection->synced_data.new_stream_error_code = AWS_ERROR_HTTP_CONNECTION_CLOSED;
208
+ }
209
+ aws_h1_connection_unlock_synced_data(connection);
210
+ } /* END CRITICAL SECTION */
211
+ }
212
+
199
213
  static bool s_connection_is_open(const struct aws_http_connection *connection_base) {
200
214
  struct aws_h1_connection *connection = AWS_CONTAINER_OF(connection_base, struct aws_h1_connection, base);
201
215
  bool is_open;
@@ -243,6 +243,7 @@ static void s_write_headers(struct aws_byte_buf *dst, const struct aws_http_head
243
243
  wrote_all &= s_write_crlf(dst);
244
244
  }
245
245
  AWS_ASSERT(wrote_all);
246
+ (void)wrote_all;
246
247
  }
247
248
 
248
249
  int aws_h1_encoder_message_init_from_request(
@@ -255,7 +256,7 @@ int aws_h1_encoder_message_init_from_request(
255
256
 
256
257
  AWS_ZERO_STRUCT(*message);
257
258
 
258
- message->body = aws_http_message_get_body_stream(request);
259
+ message->body = aws_input_stream_acquire(aws_http_message_get_body_stream(request));
259
260
  message->pending_chunk_list = pending_chunk_list;
260
261
 
261
262
  struct aws_byte_cursor method;
@@ -351,7 +352,7 @@ int aws_h1_encoder_message_init_from_response(
351
352
 
352
353
  AWS_ZERO_STRUCT(*message);
353
354
 
354
- message->body = aws_http_message_get_body_stream(response);
355
+ message->body = aws_input_stream_acquire(aws_http_message_get_body_stream(response));
355
356
  message->pending_chunk_list = pending_chunk_list;
356
357
 
357
358
  struct aws_byte_cursor version = aws_http_version_to_str(AWS_HTTP_VERSION_1_1);
@@ -431,6 +432,7 @@ error:
431
432
  }
432
433
 
433
434
  void aws_h1_encoder_message_clean_up(struct aws_h1_encoder_message *message) {
435
+ aws_input_stream_release(message->body);
434
436
  aws_byte_buf_clean_up(&message->outgoing_head_buf);
435
437
  aws_h1_trailer_destroy(message->trailer);
436
438
  AWS_ZERO_STRUCT(*message);
@@ -506,6 +508,7 @@ static void s_populate_chunk_line_buffer(
506
508
  }
507
509
  wrote_chunk_line &= s_write_crlf(chunk_line);
508
510
  AWS_ASSERT(wrote_chunk_line);
511
+ (void)wrote_chunk_line;
509
512
  }
510
513
 
511
514
  struct aws_h1_trailer *aws_h1_trailer_new(
@@ -545,18 +548,18 @@ struct aws_h1_chunk *aws_h1_chunk_new(struct aws_allocator *allocator, const str
545
548
  }
546
549
 
547
550
  chunk->allocator = allocator;
548
- chunk->data = options->chunk_data;
551
+ chunk->data = aws_input_stream_acquire(options->chunk_data);
549
552
  chunk->data_size = options->chunk_data_size;
550
553
  chunk->on_complete = options->on_complete;
551
554
  chunk->user_data = options->user_data;
552
555
  chunk->chunk_line = aws_byte_buf_from_empty_array(chunk_line_storage, chunk_line_size);
553
556
  s_populate_chunk_line_buffer(&chunk->chunk_line, options);
554
-
555
557
  return chunk;
556
558
  }
557
559
 
558
560
  void aws_h1_chunk_destroy(struct aws_h1_chunk *chunk) {
559
561
  AWS_PRECONDITION(chunk);
562
+ aws_input_stream_release(chunk->data);
560
563
  aws_mem_release(chunk->allocator, chunk);
561
564
  }
562
565