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
@@ -116,7 +116,10 @@ static void s_event_loop_shutdown_callback(void *user_data) {
116
116
  aws_condition_variable_notify_one(&test_data->shutdown_cvar);
117
117
  }
118
118
 
119
- static int s_fixture_setup(struct aws_allocator *allocator, void *ctx) {
119
+ static int s_fixture_setup_shared(
120
+ struct aws_allocator *allocator,
121
+ void *ctx,
122
+ aws_event_stream_rpc_server_on_incoming_stream_fn *on_incoming_stream) {
120
123
  aws_event_stream_library_init(allocator);
121
124
  struct test_data *test_data = ctx;
122
125
  AWS_ZERO_STRUCT(*test_data);
@@ -169,6 +172,94 @@ static int s_fixture_setup(struct aws_allocator *allocator, void *ctx) {
169
172
  };
170
173
  ASSERT_SUCCESS(testing_channel_init(&test_data->testing_channel, allocator, &testing_channel_options));
171
174
 
175
+ struct aws_event_stream_rpc_connection_options connection_options = {
176
+ .on_connection_protocol_message = s_fixture_on_protocol_message,
177
+ .on_incoming_stream = on_incoming_stream,
178
+ .user_data = test_data,
179
+ };
180
+
181
+ test_data->connection = aws_event_stream_rpc_server_connection_from_existing_channel(
182
+ test_data->listener, test_data->testing_channel.channel, &connection_options);
183
+ ASSERT_NOT_NULL(test_data->connection);
184
+
185
+ testing_channel_run_currently_queued_tasks(&test_data->testing_channel);
186
+
187
+ return AWS_OP_SUCCESS;
188
+ }
189
+
190
+ static int s_on_server_incoming_stream_failure(
191
+ struct aws_event_stream_rpc_server_connection *connection,
192
+ struct aws_event_stream_rpc_server_continuation_token *token,
193
+ struct aws_byte_cursor operation_name,
194
+ struct aws_event_stream_rpc_server_stream_continuation_options *continuation_options,
195
+ void *user_data) {
196
+
197
+ (void)connection;
198
+ (void)token;
199
+ (void)operation_name;
200
+ (void)continuation_options;
201
+ (void)user_data;
202
+
203
+ return AWS_OP_ERR;
204
+ }
205
+
206
+ static int s_fixture_setup_new_stream_failure(struct aws_allocator *allocator, void *ctx) {
207
+ return s_fixture_setup_shared(allocator, ctx, s_on_server_incoming_stream_failure);
208
+ }
209
+
210
+ static int s_fixture_setup(struct aws_allocator *allocator, void *ctx) {
211
+ return s_fixture_setup_shared(allocator, ctx, s_on_server_incoming_stream_shim);
212
+ }
213
+
214
+ static int s_fixture_setup_port0(struct aws_allocator *allocator, void *ctx) {
215
+ aws_event_stream_library_init(allocator);
216
+ struct test_data *test_data = ctx;
217
+ AWS_ZERO_STRUCT(*test_data);
218
+
219
+ struct aws_shutdown_callback_options el_shutdown_options = {
220
+ .shutdown_callback_fn = s_event_loop_shutdown_callback,
221
+ .shutdown_callback_user_data = test_data,
222
+ };
223
+ test_data->el_group = aws_event_loop_group_new_default(allocator, 0, &el_shutdown_options);
224
+ ASSERT_NOT_NULL(test_data->el_group);
225
+ test_data->server_bootstrap = aws_server_bootstrap_new(allocator, test_data->el_group);
226
+ ASSERT_NOT_NULL(test_data->server_bootstrap);
227
+
228
+ ASSERT_SUCCESS(aws_mutex_init(&test_data->shutdown_lock));
229
+ ASSERT_SUCCESS(aws_condition_variable_init(&test_data->shutdown_cvar));
230
+
231
+ struct aws_socket_options socket_options = {
232
+ .connect_timeout_ms = 3000,
233
+ .domain = AWS_SOCKET_IPV4,
234
+ .type = AWS_SOCKET_STREAM,
235
+ };
236
+
237
+ /* Find a random open port directly by ask bind() with port 0 */
238
+ uint16_t test_port = 0;
239
+ struct aws_event_stream_rpc_server_listener_options listener_options = {
240
+ .socket_options = &socket_options,
241
+ .host_name = "127.0.0.1",
242
+ .port = test_port,
243
+ .bootstrap = test_data->server_bootstrap,
244
+ .user_data = test_data,
245
+ .on_new_connection = s_fixture_on_new_server_connection,
246
+ .on_connection_shutdown = s_fixture_on_server_connection_shutdown,
247
+ .on_destroy_callback = s_on_listener_destroy,
248
+ };
249
+
250
+ test_data->listener = aws_event_stream_rpc_server_new_listener(allocator, &listener_options);
251
+ ASSERT_NOT_NULL(test_data->listener);
252
+
253
+ uint16_t actual_port = aws_event_stream_rpc_server_listener_get_bound_port(test_data->listener);
254
+ ASSERT_TRUE(actual_port > 0);
255
+
256
+ test_data->allocator = allocator;
257
+
258
+ struct aws_testing_channel_options testing_channel_options = {
259
+ .clock_fn = aws_high_res_clock_get_ticks,
260
+ };
261
+ ASSERT_SUCCESS(testing_channel_init(&test_data->testing_channel, allocator, &testing_channel_options));
262
+
172
263
  struct aws_event_stream_rpc_connection_options connection_options = {
173
264
  .on_connection_protocol_message = s_fixture_on_protocol_message,
174
265
  .on_incoming_stream = s_on_server_incoming_stream_shim,
@@ -208,6 +299,7 @@ static int s_fixture_shutdown(struct aws_allocator *allocator, int setup_result,
208
299
  aws_condition_variable_wait_pred(
209
300
  &test_data->shutdown_cvar, &test_data->shutdown_lock, s_shutdown_predicate_fn, test_data);
210
301
  aws_mutex_unlock(&test_data->shutdown_lock);
302
+ aws_thread_join_all_managed();
211
303
  aws_mutex_clean_up(&test_data->shutdown_lock);
212
304
  aws_condition_variable_clean_up(&test_data->shutdown_cvar);
213
305
  }
@@ -233,6 +325,13 @@ AWS_TEST_CASE_FIXTURE(
233
325
  s_fixture_shutdown,
234
326
  &s_test_data)
235
327
 
328
+ AWS_TEST_CASE_FIXTURE(
329
+ test_event_stream_rpc_server_connection_setup_and_teardown_with_bind_to_zero_port,
330
+ s_fixture_setup_port0,
331
+ s_test_event_stream_rpc_server_connection_setup_and_teardown,
332
+ s_fixture_shutdown,
333
+ &s_test_data)
334
+
236
335
  struct received_protocol_message_data {
237
336
  struct aws_allocator *allocator;
238
337
  enum aws_event_stream_rpc_message_type message_type;
@@ -1214,6 +1313,74 @@ AWS_TEST_CASE_FIXTURE(
1214
1313
  s_fixture_shutdown,
1215
1314
  &s_test_data)
1216
1315
 
1316
+ static int s_test_event_stream_rpc_server_connection_continuation_failure(struct aws_allocator *allocator, void *ctx) {
1317
+ struct test_data *test_data = ctx;
1318
+
1319
+ struct received_protocol_message_data message_data = {
1320
+ .allocator = allocator,
1321
+ };
1322
+
1323
+ test_data->user_data = &message_data;
1324
+ test_data->received_fn = s_on_recieved_protocol_message;
1325
+ test_data->continuation_user_data = &message_data;
1326
+ test_data->on_continuation = s_on_continuation_message;
1327
+ test_data->on_continuation_closed = s_on_continuation_closed;
1328
+
1329
+ s_do_connect(allocator, test_data, &message_data);
1330
+
1331
+ struct aws_byte_buf payload = aws_byte_buf_from_c_str("test operation payload!");
1332
+ struct aws_event_stream_message message;
1333
+ struct aws_array_list headers_list;
1334
+ ASSERT_SUCCESS(aws_event_stream_headers_list_init(&headers_list, allocator));
1335
+
1336
+ struct aws_byte_cursor operation_name = aws_byte_cursor_from_c_str("testOperation");
1337
+ ASSERT_SUCCESS(aws_event_stream_add_int32_header(
1338
+ &headers_list,
1339
+ (const char *)aws_event_stream_rpc_message_type_name.ptr,
1340
+ (uint8_t)aws_event_stream_rpc_message_type_name.len,
1341
+ AWS_EVENT_STREAM_RPC_MESSAGE_TYPE_APPLICATION_MESSAGE));
1342
+ ASSERT_SUCCESS(aws_event_stream_add_int32_header(
1343
+ &headers_list,
1344
+ (const char *)aws_event_stream_rpc_message_flags_name.ptr,
1345
+ (uint8_t)aws_event_stream_rpc_message_flags_name.len,
1346
+ 0));
1347
+ ASSERT_SUCCESS(aws_event_stream_add_int32_header(
1348
+ &headers_list,
1349
+ (const char *)aws_event_stream_rpc_stream_id_name.ptr,
1350
+ (uint8_t)aws_event_stream_rpc_stream_id_name.len,
1351
+ 1));
1352
+ ASSERT_SUCCESS(aws_event_stream_add_string_header(
1353
+ &headers_list,
1354
+ (const char *)aws_event_stream_rpc_operation_name.ptr,
1355
+ (uint8_t)aws_event_stream_rpc_operation_name.len,
1356
+ (const char *)operation_name.ptr,
1357
+ (uint16_t)operation_name.len,
1358
+ 0));
1359
+
1360
+ ASSERT_SUCCESS(aws_event_stream_message_init(&message, allocator, &headers_list, &payload));
1361
+
1362
+ struct aws_byte_cursor send_data = aws_byte_cursor_from_array(
1363
+ aws_event_stream_message_buffer(&message), aws_event_stream_message_total_length(&message));
1364
+ ASSERT_SUCCESS(testing_channel_push_read_data(&test_data->testing_channel, send_data));
1365
+ testing_channel_drain_queued_tasks(&test_data->testing_channel);
1366
+ aws_event_stream_message_clean_up(&message);
1367
+ aws_array_list_clean_up(&headers_list);
1368
+
1369
+ ASSERT_NULL(message_data.continuation_token);
1370
+
1371
+ aws_event_stream_rpc_server_connection_close(test_data->connection, AWS_ERROR_SUCCESS);
1372
+ testing_channel_drain_queued_tasks(&test_data->testing_channel);
1373
+
1374
+ return AWS_OP_SUCCESS;
1375
+ }
1376
+
1377
+ AWS_TEST_CASE_FIXTURE(
1378
+ test_event_stream_rpc_server_connection_continuation_failure,
1379
+ s_fixture_setup_new_stream_failure,
1380
+ s_test_event_stream_rpc_server_connection_continuation_failure,
1381
+ s_fixture_shutdown,
1382
+ &s_test_data)
1383
+
1217
1384
  static int s_test_event_stream_rpc_server_connection_continuation_missing_operation(
1218
1385
  struct aws_allocator *allocator,
1219
1386
  void *ctx) {
@@ -15,7 +15,8 @@ static int s_test_outgoing_no_op_valid_fn(struct aws_allocator *allocator, void
15
15
  struct aws_event_stream_message message;
16
16
  struct aws_byte_buf test_buf = aws_byte_buf_from_array(test_data, sizeof(test_data));
17
17
  ASSERT_SUCCESS(
18
- aws_event_stream_message_from_buffer(&message, NULL, &test_buf), "Message validation should have succeeded");
18
+ aws_event_stream_message_from_buffer(&message, allocator, &test_buf),
19
+ "Message validation should have succeeded");
19
20
 
20
21
  ASSERT_INT_EQUALS(
21
22
  0x00000010, aws_event_stream_message_total_length(&message), "Message length should have been 0x10");
@@ -43,7 +44,8 @@ static int s_test_outgoing_application_data_no_headers_valid_fn(struct aws_alloc
43
44
  struct aws_byte_buf test_buf = aws_byte_buf_from_array(test_data, sizeof(test_data));
44
45
 
45
46
  ASSERT_SUCCESS(
46
- aws_event_stream_message_from_buffer(&message, NULL, &test_buf), "Message validation should have succeeded");
47
+ aws_event_stream_message_from_buffer(&message, allocator, &test_buf),
48
+ "Message validation should have succeeded");
47
49
 
48
50
  ASSERT_INT_EQUALS(
49
51
  0x0000001D, aws_event_stream_message_total_length(&message), "Message length should have been 0x0000001D");
@@ -6,6 +6,7 @@ if (POLICY CMP0069)
6
6
  endif()
7
7
 
8
8
  option(ENABLE_PROXY_INTEGRATION_TESTS "Whether to run the proxy integration tests that rely on pre-configured proxy" OFF)
9
+ option(ENABLE_LOCALHOST_INTEGRATION_TESTS "Whether to run the integration tests that rely on pre-configured localhost" OFF)
9
10
 
10
11
  if (DEFINED CMAKE_PREFIX_PATH)
11
12
  file(TO_CMAKE_PATH "${CMAKE_PREFIX_PATH}" CMAKE_PREFIX_PATH)
@@ -51,3 +51,11 @@ git clone git@github.com:awslabs/aws-c-http.git
51
51
  cmake -S aws-c-http -B aws-c-http/build -DCMAKE_INSTALL_PREFIX=<install-path> -DCMAKE_PREFIX_PATH=<install-path>
52
52
  cmake --build aws-c-http/build --target install
53
53
  ```
54
+
55
+ #### Run Integration Tests with localhost
56
+
57
+ To run some of the integration tests (start with localhost_integ_*), you need to set up a localhost that echo the request headers from `/echo` back first.
58
+
59
+ To do that, check [localhost](./tests/py_localhost/) script we have.
60
+
61
+ After that, configure and build your cmake project with `-DENABLE_LOCALHOST_INTEGRATION_TESTS=true` to build the tests with localhost and run them from `ctest --output-on-failure -R localhost_integ_*`.
@@ -763,7 +763,7 @@ int main(int argc, char **argv) {
763
763
  }
764
764
 
765
765
  if (app_ctx.input_body) {
766
- aws_input_stream_destroy(app_ctx.input_body);
766
+ aws_input_stream_release(app_ctx.input_body);
767
767
  }
768
768
 
769
769
  if (app_ctx.input_file) {
@@ -11,10 +11,11 @@
11
11
  { "name": "aws-c-compression" }
12
12
  ],
13
13
  "downstream": [
14
- { "name": "aws-c-auth" }
14
+ { "name": "aws-c-auth" },
15
+ { "name": "aws-c-mqtt" }
15
16
  ],
16
17
  "test_steps": [
17
- ["bash", "./.builder/action/aws-c-http-test.sh"],
18
- ["{python}", "./integration-testing/http_client_test.py", "{install_dir}/bin/elasticurl{exe}"]
18
+ "aws-c-http-test",
19
+ ["{python}", "{source_dir}/integration-testing/http_client_test.py", "{install_dir}/bin/elasticurl{exe}"]
19
20
  ]
20
21
  }
@@ -463,6 +463,13 @@ void aws_http_connection_release(struct aws_http_connection *connection);
463
463
  AWS_HTTP_API
464
464
  void aws_http_connection_close(struct aws_http_connection *connection);
465
465
 
466
+ /**
467
+ * Stop accepting new requests for the connection. It will NOT start the shutdown process for the connection. The
468
+ * requests that are already open can still wait to be completed, but new requests will fail to be created,
469
+ */
470
+ AWS_HTTP_API
471
+ void aws_http_connection_stop_new_requests(struct aws_http_connection *connection);
472
+
466
473
  /**
467
474
  * Returns true unless the connection is closed or closing.
468
475
  */
@@ -597,7 +604,7 @@ void aws_http2_connection_get_remote_settings(
597
604
  */
598
605
 
599
606
  AWS_HTTP_API
600
- int aws_http2_connection_send_goaway(
607
+ void aws_http2_connection_send_goaway(
601
608
  struct aws_http_connection *http2_connection,
602
609
  uint32_t http2_error,
603
610
  bool allow_more_streams,
@@ -25,6 +25,23 @@ typedef void(aws_http_connection_manager_on_connection_setup_fn)(
25
25
 
26
26
  typedef void(aws_http_connection_manager_shutdown_complete_fn)(void *user_data);
27
27
 
28
+ /**
29
+ * Metrics for logging and debugging purpose.
30
+ */
31
+ struct aws_http_manager_metrics {
32
+ /**
33
+ * The number of additional concurrent requests that can be supported by the HTTP manager without needing to
34
+ * establish additional connections to the target server.
35
+ *
36
+ * For connection manager, it equals to connections that's idle.
37
+ * For stream manager, it equals to the number of streams that are possible to be made without creating new
38
+ * connection, although the implementation can create new connection without fully filling it.
39
+ */
40
+ size_t available_concurrency;
41
+ /* The number of requests that are awaiting concurrency to be made available from the HTTP manager. */
42
+ size_t pending_concurrency_acquires;
43
+ };
44
+
28
45
  /*
29
46
  * Connection manager configuration struct.
30
47
  *
@@ -38,11 +55,28 @@ struct aws_http_connection_manager_options {
38
55
  struct aws_client_bootstrap *bootstrap;
39
56
  size_t initial_window_size;
40
57
  const struct aws_socket_options *socket_options;
58
+
59
+ /**
60
+ * Options to create secure (HTTPS) connections.
61
+ * For secure connections, set "h2" in the ALPN string for HTTP/2, otherwise HTTP/1.1 is used.
62
+ *
63
+ * Leave NULL to create cleartext (HTTP) connections.
64
+ * For cleartext connections, use `http2_prior_knowledge` (RFC-7540 3.4)
65
+ * to control whether that are treated as HTTP/1.1 or HTTP/2.
66
+ */
41
67
  const struct aws_tls_connection_options *tls_connection_options;
68
+
69
+ /**
70
+ * Specify whether you have prior knowledge that cleartext (HTTP) connections are HTTP/2 (RFC-7540 3.4).
71
+ * If false, then cleartext connections are treated as HTTP/1.1.
72
+ * It is illegal to set this true when secure connections are being used.
73
+ * Note that upgrading from HTTP/1.1 to HTTP/2 is not supported (RFC-7540 3.2).
74
+ */
75
+ bool http2_prior_knowledge;
76
+
42
77
  const struct aws_http_connection_monitoring_options *monitoring_options;
43
78
  struct aws_byte_cursor host;
44
79
  uint16_t port;
45
- bool prior_knowledge_http2;
46
80
 
47
81
  /**
48
82
  * Optional.
@@ -137,12 +171,22 @@ void aws_http_connection_manager_acquire_connection(
137
171
  /*
138
172
  * Returns a connection back to the manager. All acquired connections must
139
173
  * eventually be released back to the manager in order to avoid a resource leak.
174
+ *
175
+ * Note: it can lead to another acquired callback to be invoked within the thread.
140
176
  */
141
177
  AWS_HTTP_API
142
178
  int aws_http_connection_manager_release_connection(
143
179
  struct aws_http_connection_manager *manager,
144
180
  struct aws_http_connection *connection);
145
181
 
182
+ /**
183
+ * Fetch the current manager metrics from connection manager.
184
+ */
185
+ AWS_HTTP_API
186
+ void aws_http_connection_manager_fetch_metrics(
187
+ const struct aws_http_connection_manager *manager,
188
+ struct aws_http_manager_metrics *out_metrics);
189
+
146
190
  AWS_EXTERN_C_END
147
191
 
148
192
  #endif /* AWS_HTTP_CONNECTION_MANAGER_H */
@@ -18,6 +18,7 @@ struct proxy_env_var_settings;
18
18
  struct aws_http2_setting;
19
19
  struct aws_http_make_request_options;
20
20
  struct aws_http_stream;
21
+ struct aws_http_manager_metrics;
21
22
 
22
23
  /**
23
24
  * Always invoked asynchronously when the stream was created, successfully or not.
@@ -47,29 +48,48 @@ struct aws_http2_stream_manager_options {
47
48
  */
48
49
  struct aws_client_bootstrap *bootstrap;
49
50
  const struct aws_socket_options *socket_options;
51
+
50
52
  /**
51
- * If TLS options is set, you also need to handle ALPN, otherwise, may not able to get HTTP/2 connection and fail
52
- * the stream manager.
53
- * If TLS options not set, prior knowledge will be used.
53
+ * Options to create secure (HTTPS) connections.
54
+ * For secure connections, the ALPN string must be "h2".
55
+ *
56
+ * To create cleartext (HTTP) connections, leave this NULL
57
+ * and set `http2_prior_knowledge` (RFC-7540 3.4).
54
58
  */
55
59
  const struct aws_tls_connection_options *tls_connection_options;
60
+
61
+ /**
62
+ * Specify whether you have prior knowledge that cleartext (HTTP) connections are HTTP/2 (RFC-7540 3.4).
63
+ * It is illegal to set this true when secure connections are being used.
64
+ * Note that upgrading from HTTP/1.1 to HTTP/2 is not supported (RFC-7540 3.2).
65
+ */
66
+ bool http2_prior_knowledge;
67
+
56
68
  struct aws_byte_cursor host;
57
69
  uint16_t port;
58
70
 
71
+ /**
72
+ * Optional.
73
+ * HTTP/2 connection configuration. Check `struct aws_http2_connection_options` for details of each config.
74
+ * Notes for window control:
75
+ * - By default, client will will maintain its flow-control windows such that no back-pressure is applied and data
76
+ * arrives as fast as possible.
77
+ * - For connection level window control, `conn_manual_window_management` will enable manual control. The
78
+ * inital window size is not controllable.
79
+ * - For stream level window control, `enable_read_back_pressure` will enable manual control. The initial window
80
+ * size needs to be set through `initial_settings_array`.
81
+ */
82
+ struct aws_http2_setting *initial_settings_array;
83
+ size_t num_initial_settings;
84
+ size_t max_closed_streams;
85
+ bool conn_manual_window_management;
86
+
59
87
  /**
60
88
  * HTTP/2 Stream window control.
61
89
  * If set to true, the read back pressure mechanism will be enabled for streams created.
62
- * The initial window size can be set through `initial window size`
90
+ * The initial window size can be set by `AWS_HTTP2_SETTINGS_INITIAL_WINDOW_SIZE` via `initial_settings_array`
63
91
  */
64
92
  bool enable_read_back_pressure;
65
- /**
66
- * Optional.
67
- * If set, it will be sent to the peer as the `AWS_HTTP2_SETTINGS_INITIAL_WINDOW_SIZE` in the initial settings for
68
- * HTTP/2 connection.
69
- * If not set, the default will be used, which is 65,535 (2^16-1)(RFC-7540 6.5.2)
70
- * Ignored if enable_read_back_pressure is false.
71
- */
72
- uint32_t initial_window_size;
73
93
 
74
94
  /* Connection monitor for the underlying connections made */
75
95
  const struct aws_http_connection_monitoring_options *monitoring_options;
@@ -85,6 +105,26 @@ struct aws_http2_stream_manager_options {
85
105
  void *shutdown_complete_user_data;
86
106
  aws_http2_stream_manager_shutdown_complete_fn *shutdown_complete_callback;
87
107
 
108
+ /**
109
+ * Optional.
110
+ * When set, connection will be closed if 5xx response received from server.
111
+ */
112
+ bool close_connection_on_server_error;
113
+ /**
114
+ * Optional.
115
+ * The period for all the connections held by stream manager to send a PING in milliseconds.
116
+ * If you specify 0, manager will NOT send any PING.
117
+ * Note: if set, it must be large than the time of ping timeout setting.
118
+ */
119
+ size_t connection_ping_period_ms;
120
+ /**
121
+ * Optional.
122
+ * Network connection will be closed if a ping response is not received
123
+ * within this amount of time (milliseconds).
124
+ * If you specify 0, a default value will be used.
125
+ */
126
+ size_t connection_ping_timeout_ms;
127
+
88
128
  /* TODO: More flexible policy about the connections, but will always has these three values below. */
89
129
  /**
90
130
  * Optional.
@@ -160,5 +200,16 @@ void aws_http2_stream_manager_acquire_stream(
160
200
  struct aws_http2_stream_manager *http2_stream_manager,
161
201
  const struct aws_http2_stream_manager_acquire_stream_options *acquire_stream_option);
162
202
 
203
+ /**
204
+ * Fetch the current metrics from stream manager.
205
+ *
206
+ * @param http2_stream_manager
207
+ * @param out_metrics The metrics to be fetched
208
+ */
209
+ AWS_HTTP_API
210
+ void aws_http2_stream_manager_fetch_metrics(
211
+ const struct aws_http2_stream_manager *http2_stream_manager,
212
+ struct aws_http_manager_metrics *out_metrics);
213
+
163
214
  AWS_EXTERN_C_END
164
215
  #endif /* AWS_HTTP2_STREAM_MANAGER_H */
@@ -40,6 +40,7 @@ struct aws_http_connection_vtable {
40
40
  const struct aws_http_request_handler_options *options);
41
41
  int (*stream_send_response)(struct aws_http_stream *stream, struct aws_http_message *response);
42
42
  void (*close)(struct aws_http_connection *connection);
43
+ void (*stop_new_requests)(struct aws_http_connection *connection);
43
44
  bool (*is_open)(const struct aws_http_connection *connection);
44
45
  bool (*new_requests_allowed)(const struct aws_http_connection *connection);
45
46
 
@@ -56,7 +57,7 @@ struct aws_http_connection_vtable {
56
57
  const struct aws_byte_cursor *optional_opaque_data,
57
58
  aws_http2_on_ping_complete_fn *on_completed,
58
59
  void *user_data);
59
- int (*send_goaway)(
60
+ void (*send_goaway)(
60
61
  struct aws_http_connection *http2_connection,
61
62
  uint32_t http2_error,
62
63
  bool allow_more_streams,
@@ -13,6 +13,7 @@
13
13
 
14
14
  #include <aws/http/private/connection_impl.h>
15
15
  #include <aws/http/private/h2_frames.h>
16
+ #include <aws/http/statistics.h>
16
17
 
17
18
  struct aws_h2_decoder;
18
19
  struct aws_h2_stream;
@@ -70,6 +71,14 @@ struct aws_h2_connection {
70
71
  * Waiting for WINDOW_UPDATE to set them free */
71
72
  struct aws_linked_list stalled_window_streams_list;
72
73
 
74
+ /* List using aws_h2_stream.node.
75
+ * Contains all streams that are open, but are only sending data when notified, rather than polling
76
+ * for it (e.g. event streams)
77
+ * Streams are moved to the outgoing_streams_list until they send pending data, then are moved back
78
+ * to this list to sleep until more data comes in
79
+ */
80
+ struct aws_linked_list waiting_streams_list;
81
+
73
82
  /* List using aws_h2_frame.node.
74
83
  * Queues all frames (except DATA frames) for connection to send.
75
84
  * When queue is empty, then we send DATA frames from the outgoing_streams_list */
@@ -108,6 +117,14 @@ struct aws_h2_connection {
108
117
  int channel_shutdown_error_code;
109
118
  bool channel_shutdown_immediately;
110
119
  bool channel_shutdown_waiting_for_goaway_to_be_written;
120
+
121
+ /* TODO: Consider adding stream monitor */
122
+ struct aws_crt_statistics_http2_channel stats;
123
+
124
+ /* Timestamp when connection has data to send, which is when there is an active stream with body to send */
125
+ uint64_t outgoing_timestamp_ns;
126
+ /* Timestamp when connection has data to receive, which is when there is an active stream */
127
+ uint64_t incoming_timestamp_ns;
111
128
  } thread_data;
112
129
 
113
130
  /* Any thread may touch this data, but the lock must be held (unless it's an atomic) */
@@ -200,8 +217,9 @@ enum aws_h2_stream_closed_when {
200
217
  enum aws_h2_data_encode_status {
201
218
  AWS_H2_DATA_ENCODE_COMPLETE,
202
219
  AWS_H2_DATA_ENCODE_ONGOING,
203
- AWS_H2_DATA_ENCODE_ONGOING_BODY_STALLED,
204
- AWS_H2_DATA_ENCODE_ONGOING_WINDOW_STALLED,
220
+ AWS_H2_DATA_ENCODE_ONGOING_BODY_STREAM_STALLED, /* stalled reading from body stream */
221
+ AWS_H2_DATA_ENCODE_ONGOING_WAITING_FOR_WRITES, /* waiting for next manual write */
222
+ AWS_H2_DATA_ENCODE_ONGOING_WINDOW_STALLED, /* stalled due to reduced window size */
205
223
  };
206
224
 
207
225
  /* When window size is too small to fit the possible padding into it, we stop sending data and wait for WINDOW_UPDATE */
@@ -55,6 +55,7 @@ struct aws_h2err {
55
55
  #define AWS_H2_WINDOW_UPDATE_MAX (0x7FFFFFFF) /* cannot use high bit */
56
56
  #define AWS_H2_STREAM_ID_MAX (0x7FFFFFFF) /* cannot use high bit */
57
57
  #define AWS_H2_FRAME_PREFIX_SIZE (9)
58
+ #define AWS_H2_INIT_WINDOW_SIZE (65535) /* Defined initial window size */
58
59
 
59
60
  /* Legal min(inclusive) and max(inclusive) for each setting */
60
61
  extern const uint32_t aws_h2_settings_bounds[AWS_HTTP2_SETTINGS_END_RANGE][2];
@@ -53,6 +53,23 @@ enum aws_h2_stream_api_state {
53
53
  AWS_H2_STREAM_API_STATE_COMPLETE,
54
54
  };
55
55
 
56
+ /* Indicates the state of the body of the HTTP/2 stream */
57
+ enum aws_h2_stream_body_state {
58
+ AWS_H2_STREAM_BODY_STATE_NONE, /* Has no body for the HTTP/2 stream */
59
+ AWS_H2_STREAM_BODY_STATE_WAITING_WRITES, /* Has no active body, but waiting for more to be
60
+ write */
61
+ AWS_H2_STREAM_BODY_STATE_ONGOING, /* Has active ongoing body */
62
+ };
63
+
64
+ /* represents a write operation, which will be turned into a data frame */
65
+ struct aws_h2_stream_data_write {
66
+ struct aws_linked_list_node node;
67
+ struct aws_input_stream *data_stream;
68
+ aws_http2_stream_write_data_complete_fn *on_complete;
69
+ void *user_data;
70
+ bool end_stream;
71
+ };
72
+
56
73
  struct aws_h2_stream {
57
74
  struct aws_http_stream base;
58
75
 
@@ -68,7 +85,21 @@ struct aws_h2_stream {
68
85
  * We leave it up to the remote peer to detect whether the max window size has been exceeded. */
69
86
  int64_t window_size_self;
70
87
  struct aws_http_message *outgoing_message;
88
+ /* All queued writes. If the message provides a body stream, it will be first in this list
89
+ * This list can drain, which results in the stream being put to sleep (moved to waiting_streams_list in
90
+ * h2_connection). */
91
+ struct aws_linked_list outgoing_writes; /* aws_http2_stream_data_write */
71
92
  bool received_main_headers;
93
+
94
+ bool content_length_received;
95
+ /* Set if incoming message has content-length header */
96
+ uint64_t incoming_content_length;
97
+ /* The total length of payload of data frame received */
98
+ uint64_t incoming_data_length;
99
+ /* Indicates that the stream is currently in the waiting_streams_list and is
100
+ * asleep. When stream needs to be awaken, moving the stream back to the outgoing_streams_list and set this bool
101
+ * to false */
102
+ bool waiting_for_writes;
72
103
  } thread_data;
73
104
 
74
105
  /* Any thread may touch this data, but the lock must be held (unless it's an atomic) */
@@ -84,22 +115,21 @@ struct aws_h2_stream {
84
115
  * code we want to inform user about. */
85
116
  struct aws_h2err reset_error;
86
117
  bool reset_called;
118
+ bool manual_write_ended;
87
119
 
88
120
  /* Simplified stream state. */
89
121
  enum aws_h2_stream_api_state api_state;
122
+
123
+ /* any data streams sent manually via aws_http2_stream_write_data */
124
+ struct aws_linked_list pending_write_list; /* aws_h2_stream_pending_data */
90
125
  } synced_data;
126
+ bool manual_write;
91
127
 
92
128
  /* Store the sent reset HTTP/2 error code, set to -1, if none has sent so far */
93
129
  int64_t sent_reset_error_code;
94
130
 
95
131
  /* Store the received reset HTTP/2 error code, set to -1, if none has received so far */
96
132
  int64_t received_reset_error_code;
97
-
98
- /**
99
- * Back up the message if we create a new message from it to keep the underlying input stream alive.
100
- * TODO: remove this once we have input stream refcounted
101
- */
102
- struct aws_http_message *backup_outgoing_message;
103
133
  };
104
134
 
105
135
  const char *aws_h2_stream_state_to_str(enum aws_h2_stream_state state);
@@ -113,16 +143,15 @@ enum aws_h2_stream_state aws_h2_stream_get_state(const struct aws_h2_stream *str
113
143
  struct aws_h2err aws_h2_stream_window_size_change(struct aws_h2_stream *stream, int32_t size_changed, bool self);
114
144
 
115
145
  /* Connection is ready to send frames from stream now */
116
- int aws_h2_stream_on_activated(struct aws_h2_stream *stream, bool *out_has_outgoing_data);
146
+ int aws_h2_stream_on_activated(struct aws_h2_stream *stream, enum aws_h2_stream_body_state *body_state);
147
+
148
+ /* Completes stream for one reason or another, clean up any pending writes/resources. */
149
+ void aws_h2_stream_complete(struct aws_h2_stream *stream, int error_code);
117
150
 
118
151
  /* Connection is ready to send data from stream now.
119
152
  * Stream may complete itself during this call.
120
- * data_encode_status:
121
- * AWS_H2_DATA_ENCODE_COMPLETE: Finished encoding data for the stream
122
- * AWS_H2_DATA_ENCODE_ONGOING: Stream has more data to send.
123
- * AWS_H2_DATA_ENCODE_ONGOING_BODY_STALLED: Stream has more data to send, but it's not ready right now
124
- * AWS_H2_DATA_ENCODE_ONGOING_WINDOW_STALLED: Stream has more data to send but its window size is too small, and stream
125
- * will be moved to stalled_window_stream_list */
153
+ * data_encode_status: see `aws_h2_data_encode_status`
154
+ */
126
155
  int aws_h2_stream_encode_data_frame(
127
156
  struct aws_h2_stream *stream,
128
157
  struct aws_h2_frame_encoder *encoder,