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
@@ -0,0 +1,329 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Minor change based on the example from hyper h2 server
3
+ # https://github.com/python-hyper/h2/blob/master/examples/asyncio/asyncio-server.py
4
+
5
+ """
6
+ asyncio-server.py
7
+ ~~~~~~~~~~~~~~~~~
8
+
9
+ A fully-functional HTTP/2 server using asyncio. Requires Python 3.5+.
10
+
11
+ This example demonstrates handling requests with bodies, as well as handling
12
+ those without. In particular, it demonstrates the fact that DataReceived may
13
+ be called multiple times, and that applications must handle that possibility.
14
+ """
15
+ import asyncio
16
+ import io
17
+ import json
18
+ import ssl
19
+ import time
20
+ import os
21
+ import collections
22
+ from typing import List, Tuple
23
+
24
+ from h2.config import H2Configuration
25
+ from h2.connection import H2Connection
26
+ from h2.events import (
27
+ ConnectionTerminated, DataReceived, RemoteSettingsChanged,
28
+ RequestReceived, StreamEnded, StreamReset, WindowUpdated
29
+ )
30
+ from h2.errors import ErrorCodes
31
+ from h2.exceptions import ProtocolError, StreamClosedError
32
+ from h2.settings import SettingCodes
33
+
34
+
35
+ RequestData = collections.namedtuple('RequestData', ['headers', 'data'])
36
+
37
+
38
+ class H2Protocol(asyncio.Protocol):
39
+ def __init__(self):
40
+ config = H2Configuration(client_side=False, header_encoding='utf-8')
41
+ self.conn = H2Connection(config=config)
42
+ self.transport = None
43
+ self.stream_data = {}
44
+ self.flow_control_futures = {}
45
+ self.file_path = None
46
+ self.num_sentence_received = {}
47
+ self.raw_headers = None
48
+ self.download_test_length = 2500000000
49
+ self.out_bytes_per_second = 900
50
+
51
+ def connection_made(self, transport: asyncio.Transport):
52
+ self.transport = transport
53
+ self.conn.initiate_connection()
54
+ self.transport.write(self.conn.data_to_send())
55
+
56
+ def connection_lost(self, exc):
57
+ for future in self.flow_control_futures.values():
58
+ future.cancel()
59
+ self.flow_control_futures = {}
60
+
61
+ def data_received(self, data: bytes):
62
+ try:
63
+ events = self.conn.receive_data(data)
64
+ except ProtocolError as e:
65
+ self.transport.write(self.conn.data_to_send())
66
+ self.transport.close()
67
+ else:
68
+ self.transport.write(self.conn.data_to_send())
69
+ for event in events:
70
+ if isinstance(event, RequestReceived):
71
+ self.request_received(event.headers, event.stream_id)
72
+ elif isinstance(event, DataReceived):
73
+ self.receive_data(event.data, event.stream_id)
74
+ elif isinstance(event, StreamEnded):
75
+ self.stream_complete(event.stream_id)
76
+ elif isinstance(event, ConnectionTerminated):
77
+ self.transport.close()
78
+ elif isinstance(event, StreamReset):
79
+ self.stream_reset(event.stream_id)
80
+ elif isinstance(event, WindowUpdated):
81
+ self.window_updated(event.stream_id, event.delta)
82
+ elif isinstance(event, RemoteSettingsChanged):
83
+ if SettingCodes.INITIAL_WINDOW_SIZE in event.changed_settings:
84
+ self.window_updated(None, 0)
85
+
86
+ self.transport.write(self.conn.data_to_send())
87
+
88
+ def request_received(self, headers: List[Tuple[str, str]], stream_id: int):
89
+ self.raw_headers = headers
90
+ headers = collections.OrderedDict(headers)
91
+ path = headers[':path']
92
+ method = headers[':method']
93
+ if method == "PUT" or method == "POST":
94
+ self.file_path = os.path.join(os.path.curdir, path[1:])
95
+ if os.path.exists(self.file_path):
96
+ os.remove(self.file_path)
97
+
98
+ # Store off the request data.
99
+ request_data = RequestData(headers, io.BytesIO())
100
+ self.stream_data[stream_id] = request_data
101
+
102
+ def handle_request_echo(self, stream_id: int, request_data: RequestData):
103
+ response_headers = [(':status', '200')]
104
+ for i in self.raw_headers:
105
+ # Response headers back and exclude pseudo headers
106
+ if i[0][0] != ':':
107
+ response_headers.append(i)
108
+ body = request_data.data.getvalue().decode('utf-8')
109
+ data = json.dumps(
110
+ {"body": body}, indent=4
111
+ ).encode("utf8")
112
+ self.conn.send_headers(stream_id, response_headers)
113
+ asyncio.ensure_future(self.send_data(data, stream_id))
114
+
115
+ def stream_complete(self, stream_id: int):
116
+ """
117
+ When a stream is complete, we can send our response.
118
+ """
119
+ try:
120
+ request_data = self.stream_data[stream_id]
121
+ except KeyError:
122
+ # Just return, we probably 405'd this already
123
+ return
124
+
125
+ path = request_data.headers[':path']
126
+ method = request_data.headers[':method']
127
+ if method == "PUT" or method == "POST":
128
+ self.conn.send_headers(stream_id, [(':status', '200')])
129
+ asyncio.ensure_future(self.send_data(
130
+ str(self.num_sentence_received[stream_id]).encode(), stream_id))
131
+ elif path == '/echo':
132
+ self.handle_request_echo(stream_id, request_data)
133
+ elif path == '/downloadTest':
134
+ length = self.download_test_length
135
+ self.conn.send_headers(
136
+ stream_id, [(':status', '200'), ('content-length', str(length))])
137
+ asyncio.ensure_future(self.send_repeat_data(length, stream_id))
138
+ elif path == '/slowConnTest':
139
+ length = int(self.download_test_length/1000)
140
+ self.conn.send_headers(
141
+ stream_id, [(':status', '200'), ('content-length', str(length))])
142
+ asyncio.ensure_future(
143
+ self.send_slow_repeat_data(length, stream_id))
144
+ else:
145
+ self.conn.send_headers(stream_id, [(':status', '404')])
146
+ asyncio.ensure_future(self.send_data(b"Not Found", stream_id))
147
+
148
+ def receive_data(self, data: bytes, stream_id: int):
149
+ """
150
+ We've received some data on a stream. If that stream is one we're
151
+ expecting data on, save it off. Otherwise, reset the stream.
152
+ """
153
+ try:
154
+ stream_data = self.stream_data[stream_id]
155
+ except KeyError:
156
+ self.conn.reset_stream(
157
+ stream_id, error_code=ErrorCodes.PROTOCOL_ERROR
158
+ )
159
+ else:
160
+ method = stream_data.headers[':method']
161
+ if method == "PUT" or method == "POST":
162
+ if stream_id in self.num_sentence_received:
163
+ self.num_sentence_received[stream_id] = self.num_sentence_received[stream_id] + \
164
+ len(data)
165
+ else:
166
+ self.num_sentence_received[stream_id] = len(data)
167
+ # update window for stream
168
+ if len(data) > 0:
169
+ self.conn.increment_flow_control_window(len(data))
170
+ self.conn.increment_flow_control_window(
171
+ len(data), stream_id)
172
+ else:
173
+ stream_data.data.write(data)
174
+
175
+ def stream_reset(self, stream_id):
176
+ """
177
+ A stream reset was sent. Stop sending data.
178
+ """
179
+ if stream_id in self.flow_control_futures:
180
+ future = self.flow_control_futures.pop(stream_id)
181
+ future.cancel()
182
+
183
+ async def send_data(self, data, stream_id):
184
+ """
185
+ Send data according to the flow control rules.
186
+ """
187
+ while data:
188
+ while self.conn.local_flow_control_window(stream_id) < 1:
189
+ try:
190
+ await self.wait_for_flow_control(stream_id)
191
+ except asyncio.CancelledError:
192
+ return
193
+
194
+ chunk_size = min(
195
+ self.conn.local_flow_control_window(stream_id),
196
+ len(data),
197
+ self.conn.max_outbound_frame_size,
198
+ )
199
+
200
+ try:
201
+ self.conn.send_data(
202
+ stream_id,
203
+ data[:chunk_size],
204
+ end_stream=(chunk_size == len(data))
205
+ )
206
+ except (StreamClosedError, ProtocolError):
207
+ # The stream got closed and we didn't get told. We're done
208
+ # here.
209
+ break
210
+
211
+ self.transport.write(self.conn.data_to_send())
212
+ data = data[chunk_size:]
213
+
214
+ async def send_repeat_data(self, length, stream_id):
215
+ """
216
+ Send data with length according to the flow control rules.
217
+ """
218
+ while length > 0:
219
+ while self.conn.local_flow_control_window(stream_id) < 1:
220
+ try:
221
+ await self.wait_for_flow_control(stream_id)
222
+ except asyncio.CancelledError:
223
+ return
224
+
225
+ chunk_size = min(
226
+ self.conn.local_flow_control_window(stream_id),
227
+ length,
228
+ self.conn.max_outbound_frame_size,
229
+ )
230
+ repeated = b"This is CRT HTTP test."
231
+ data = int(chunk_size/len(repeated)) * repeated + \
232
+ repeated[:chunk_size % len(repeated)]
233
+
234
+ try:
235
+ self.conn.send_data(
236
+ stream_id,
237
+ data,
238
+ end_stream=(chunk_size == length)
239
+ )
240
+ except (StreamClosedError, ProtocolError):
241
+ # The stream got closed and we didn't get told. We're done
242
+ # here.
243
+ break
244
+
245
+ self.transport.write(self.conn.data_to_send())
246
+ length = length - chunk_size
247
+
248
+ async def send_slow_repeat_data(self, length, stream_id):
249
+ """
250
+ Send data with length slowly (less than 1000 bytes per second)
251
+ """
252
+ while length > 0:
253
+ while self.conn.local_flow_control_window(stream_id) < 1:
254
+ try:
255
+ await self.wait_for_flow_control(stream_id)
256
+ except asyncio.CancelledError:
257
+ return
258
+
259
+ chunk_size = min(
260
+ self.conn.local_flow_control_window(stream_id),
261
+ length,
262
+ self.conn.max_outbound_frame_size,
263
+ self.out_bytes_per_second
264
+ )
265
+ repeated = b"This is CRT HTTP test."
266
+ data = int(chunk_size/len(repeated)) * repeated + \
267
+ repeated[:chunk_size % len(repeated)]
268
+
269
+ try:
270
+ # Sleep for a sec to make the out bytes per second slower than the expected
271
+ time.sleep(1)
272
+ self.conn.send_data(
273
+ stream_id,
274
+ data,
275
+ end_stream=(chunk_size == length)
276
+ )
277
+ except (StreamClosedError, ProtocolError):
278
+ # The stream got closed and we didn't get told. We're done
279
+ # here.
280
+ break
281
+
282
+ self.transport.write(self.conn.data_to_send())
283
+ length = length - chunk_size
284
+
285
+ async def wait_for_flow_control(self, stream_id):
286
+ """
287
+ Waits for a Future that fires when the flow control window is opened.
288
+ """
289
+ f = asyncio.Future()
290
+ self.flow_control_futures[stream_id] = f
291
+ await f
292
+
293
+ def window_updated(self, stream_id, delta):
294
+ """
295
+ A window update frame was received. Unblock some number of flow control
296
+ Futures.
297
+ """
298
+ if stream_id and stream_id in self.flow_control_futures:
299
+ f = self.flow_control_futures.pop(stream_id)
300
+ f.set_result(delta)
301
+ elif not stream_id:
302
+ for f in self.flow_control_futures.values():
303
+ f.set_result(delta)
304
+
305
+ self.flow_control_futures = {}
306
+
307
+
308
+ ssl_context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
309
+ ssl_context.options |= (ssl.OP_NO_COMPRESSION)
310
+ ssl_context.load_cert_chain(
311
+ certfile="../resources/unittests.crt", keyfile="../resources/unittests.key")
312
+ ssl_context.set_alpn_protocols(["h2"])
313
+
314
+ loop = asyncio.new_event_loop()
315
+ # Each client connection will create a new protocol instance
316
+ coro = loop.create_server(H2Protocol, '127.0.0.1', 8443, ssl=ssl_context)
317
+ server = loop.run_until_complete(coro)
318
+
319
+ # Serve requests until Ctrl+C is pressed
320
+ print('Serving on {}'.format(server.sockets[0].getsockname()))
321
+ try:
322
+ loop.run_forever()
323
+ except KeyboardInterrupt:
324
+ pass
325
+
326
+ # Close the server
327
+ server.close()
328
+ loop.run_until_complete(server.wait_closed())
329
+ loop.close()
@@ -212,7 +212,7 @@ static int s_cm_tester_init(struct cm_tester_options *options) {
212
212
  .shutdown_complete_user_data = tester,
213
213
  .shutdown_complete_callback = s_cm_tester_on_cm_shutdown_complete,
214
214
  .max_connection_idle_in_milliseconds = options->max_connection_idle_in_ms,
215
- .prior_knowledge_http2 = !options->use_tls && options->http2,
215
+ .http2_prior_knowledge = !options->use_tls && options->http2,
216
216
  .initial_settings_array = options->initial_settings_array,
217
217
  .num_initial_settings = options->num_initial_settings,
218
218
  };
@@ -17,7 +17,7 @@
17
17
  #include <aws/testing/io_testing_channel.h>
18
18
 
19
19
  #ifdef _MSC_VER
20
- # pragma warning(disable : 4996) /* Disable warnings about sptrintf() being insecure */
20
+ # pragma warning(disable : 4996) /* Disable warnings about sprintf() being insecure */
21
21
  #endif
22
22
 
23
23
  static int s_test_http_connection_monitor_options_is_valid(struct aws_allocator *allocator, void *ctx) {
@@ -147,7 +147,7 @@ static void s_clean_up_monitor_test(void) {
147
147
  if (request_info) {
148
148
  aws_http_message_destroy(request_info->request);
149
149
  aws_http_stream_release(request_info->stream);
150
- aws_input_stream_destroy(request_info->body);
150
+ aws_input_stream_release(request_info->body);
151
151
  }
152
152
  }
153
153
 
@@ -33,7 +33,7 @@ static void s_destroy_stream_on_complete(struct aws_http_stream *stream, int err
33
33
  (void)stream;
34
34
  (void)error_code;
35
35
  struct aws_input_stream *data_stream = user_data;
36
- aws_input_stream_destroy(data_stream);
36
+ aws_input_stream_release(data_stream);
37
37
  }
38
38
 
39
39
  static struct aws_http1_chunk_options s_default_chunk_options(struct aws_input_stream *stream, size_t stream_size) {
@@ -274,7 +274,7 @@ H1_CLIENT_TEST_CASE(h1_client_request_send_body) {
274
274
  ASSERT_SUCCESS(testing_channel_check_written_messages_str(&tester.testing_channel, allocator, expected));
275
275
 
276
276
  /* clean up */
277
- aws_input_stream_destroy(body_stream);
277
+ aws_input_stream_release(body_stream);
278
278
  aws_http_message_destroy(request);
279
279
  aws_http_stream_release(stream);
280
280
 
@@ -892,7 +892,7 @@ static void s_on_chunk_complete_write_another_chunk(struct aws_http_stream *stre
892
892
  AWS_FATAL_ASSERT(0 == error_code);
893
893
  struct chunk_that_writes_another *chunk = user_data;
894
894
 
895
- aws_input_stream_destroy(chunk->body_data);
895
+ aws_input_stream_release(chunk->body_data);
896
896
 
897
897
  const struct aws_byte_cursor chunk2_body = aws_byte_cursor_from_c_str("chunk 2.");
898
898
  struct aws_input_stream *chunk2_body_stream = aws_input_stream_new_from_cursor(chunk->allocator, &chunk2_body);
@@ -1083,7 +1083,7 @@ H1_CLIENT_TEST_CASE(h1_client_request_content_length_0_ok) {
1083
1083
  ASSERT_SUCCESS(testing_channel_check_written_message_str(&tester.testing_channel, expected));
1084
1084
 
1085
1085
  /* clean up */
1086
- aws_input_stream_destroy(body_stream);
1086
+ aws_input_stream_release(body_stream);
1087
1087
  aws_http_message_destroy(request);
1088
1088
  aws_http_stream_release(stream);
1089
1089
 
@@ -1236,7 +1236,7 @@ H1_CLIENT_TEST_CASE(h1_client_request_send_large_body) {
1236
1236
  &tester.testing_channel, allocator, aws_byte_cursor_from_buf(&expected_buf)));
1237
1237
 
1238
1238
  /* clean up */
1239
- aws_input_stream_destroy(body_stream);
1239
+ aws_input_stream_release(body_stream);
1240
1240
  aws_http_message_destroy(request);
1241
1241
  aws_http_stream_release(stream);
1242
1242
 
@@ -2135,6 +2135,7 @@ H1_CLIENT_TEST_CASE(h1_client_response_with_too_much_data_shuts_down_connection)
2135
2135
  }
2136
2136
 
2137
2137
  struct slow_body_sender {
2138
+ struct aws_input_stream base;
2138
2139
  struct aws_stream_status status;
2139
2140
  struct aws_byte_cursor cursor;
2140
2141
  size_t delay_ticks; /* Don't send anything the first N ticks */
@@ -2142,7 +2143,7 @@ struct slow_body_sender {
2142
2143
  };
2143
2144
 
2144
2145
  static int s_slow_stream_read(struct aws_input_stream *stream, struct aws_byte_buf *dest) {
2145
- struct slow_body_sender *sender = stream->impl;
2146
+ struct slow_body_sender *sender = AWS_CONTAINER_OF(stream, struct slow_body_sender, base);
2146
2147
 
2147
2148
  size_t dst_available = dest->capacity - dest->len;
2148
2149
  size_t writing = 0;
@@ -2170,17 +2171,17 @@ static int s_slow_stream_read(struct aws_input_stream *stream, struct aws_byte_b
2170
2171
  return AWS_OP_SUCCESS;
2171
2172
  }
2172
2173
  static int s_slow_stream_get_status(struct aws_input_stream *stream, struct aws_stream_status *status) {
2173
- struct slow_body_sender *sender = stream->impl;
2174
+ struct slow_body_sender *sender = AWS_CONTAINER_OF(stream, struct slow_body_sender, base);
2174
2175
  *status = sender->status;
2175
2176
  return AWS_OP_SUCCESS;
2176
2177
  }
2177
2178
  static int s_slow_stream_get_length(struct aws_input_stream *stream, int64_t *out_length) {
2178
- struct slow_body_sender *sender = stream->impl;
2179
+ struct slow_body_sender *sender = AWS_CONTAINER_OF(stream, struct slow_body_sender, base);
2179
2180
  *out_length = sender->cursor.len;
2180
2181
  return AWS_OP_SUCCESS;
2181
2182
  }
2182
2183
  static void s_slow_stream_destroy(struct aws_input_stream *stream) {
2183
- aws_mem_release(stream->allocator, stream);
2184
+ (void)stream;
2184
2185
  }
2185
2186
 
2186
2187
  static struct aws_input_stream_vtable s_slow_stream_vtable = {
@@ -2188,7 +2189,6 @@ static struct aws_input_stream_vtable s_slow_stream_vtable = {
2188
2189
  .read = s_slow_stream_read,
2189
2190
  .get_status = s_slow_stream_get_status,
2190
2191
  .get_length = s_slow_stream_get_length,
2191
- .destroy = s_slow_stream_destroy,
2192
2192
  };
2193
2193
 
2194
2194
  /* It should be fine to receive a response before the request has finished sending */
@@ -2198,7 +2198,10 @@ H1_CLIENT_TEST_CASE(h1_client_response_arrives_before_request_done_sending_is_ok
2198
2198
  ASSERT_SUCCESS(s_tester_init(&tester, allocator));
2199
2199
 
2200
2200
  /* set up request whose body won't send immediately */
2201
+ struct aws_input_stream empty_stream_base;
2202
+ AWS_ZERO_STRUCT(empty_stream_base);
2201
2203
  struct slow_body_sender body_sender = {
2204
+ .base = empty_stream_base,
2202
2205
  .status =
2203
2206
  {
2204
2207
  .is_end_of_stream = false,
@@ -2208,11 +2211,11 @@ H1_CLIENT_TEST_CASE(h1_client_response_arrives_before_request_done_sending_is_ok
2208
2211
  .delay_ticks = 5,
2209
2212
  .bytes_per_tick = 1,
2210
2213
  };
2211
- struct aws_input_stream body_stream = {
2212
- .allocator = allocator,
2213
- .impl = &body_sender,
2214
- .vtable = &s_slow_stream_vtable,
2215
- };
2214
+ body_sender.base.vtable = &s_slow_stream_vtable;
2215
+ aws_ref_count_init(
2216
+ &body_sender.base.ref_count, &body_sender, (aws_simple_completion_callback *)s_slow_stream_destroy);
2217
+
2218
+ struct aws_input_stream *body_stream = &body_sender.base;
2216
2219
 
2217
2220
  struct aws_http_header headers[] = {
2218
2221
  {
@@ -2226,7 +2229,7 @@ H1_CLIENT_TEST_CASE(h1_client_response_arrives_before_request_done_sending_is_ok
2226
2229
  ASSERT_SUCCESS(aws_http_message_set_request_method(request, aws_byte_cursor_from_c_str("PUT")));
2227
2230
  ASSERT_SUCCESS(aws_http_message_set_request_path(request, aws_byte_cursor_from_c_str("/plan.txt")));
2228
2231
  ASSERT_SUCCESS(aws_http_message_add_header_array(request, headers, AWS_ARRAY_SIZE(headers)));
2229
- aws_http_message_set_body_stream(request, &body_stream);
2232
+ aws_http_message_set_body_stream(request, body_stream);
2230
2233
 
2231
2234
  struct client_stream_tester stream_tester;
2232
2235
  ASSERT_SUCCESS(s_stream_tester_init(&stream_tester, &tester, request));
@@ -2236,6 +2239,7 @@ H1_CLIENT_TEST_CASE(h1_client_response_arrives_before_request_done_sending_is_ok
2236
2239
 
2237
2240
  /* Ensure the request can be destroyed after request is sent */
2238
2241
  aws_http_message_destroy(request);
2242
+ aws_input_stream_release(body_stream);
2239
2243
 
2240
2244
  /* send response */
2241
2245
  ASSERT_SUCCESS(testing_channel_push_read_str(&tester.testing_channel, "HTTP/1.1 200 OK\r\n\r\n"));
@@ -2277,7 +2281,10 @@ H1_CLIENT_TEST_CASE(h1_client_response_arrives_before_request_chunks_done_sendin
2277
2281
  ASSERT_SUCCESS(s_tester_init(&tester, allocator));
2278
2282
 
2279
2283
  /* set up request whose body won't send immediately */
2284
+ struct aws_input_stream empty_stream_base;
2285
+ AWS_ZERO_STRUCT(empty_stream_base);
2280
2286
  struct slow_body_sender body_sender = {
2287
+ .base = empty_stream_base,
2281
2288
  .status =
2282
2289
  {
2283
2290
  .is_end_of_stream = false,
@@ -2287,11 +2294,11 @@ H1_CLIENT_TEST_CASE(h1_client_response_arrives_before_request_chunks_done_sendin
2287
2294
  .delay_ticks = 5,
2288
2295
  .bytes_per_tick = 1,
2289
2296
  };
2290
- struct aws_input_stream body_stream = {
2291
- .allocator = allocator,
2292
- .impl = &body_sender,
2293
- .vtable = &s_slow_stream_vtable,
2294
- };
2297
+ body_sender.base.vtable = &s_slow_stream_vtable;
2298
+ aws_ref_count_init(
2299
+ &body_sender.base.ref_count, &body_sender, (aws_simple_completion_callback *)s_slow_stream_destroy);
2300
+
2301
+ struct aws_input_stream *body_stream = &body_sender.base;
2295
2302
 
2296
2303
  struct aws_http_message *request = s_new_default_chunked_put_request(allocator);
2297
2304
  struct client_stream_tester stream_tester;
@@ -2305,13 +2312,14 @@ H1_CLIENT_TEST_CASE(h1_client_response_arrives_before_request_chunks_done_sendin
2305
2312
 
2306
2313
  testing_channel_run_currently_queued_tasks(&tester.testing_channel);
2307
2314
 
2308
- struct aws_http1_chunk_options options = s_default_chunk_options(&body_stream, body_sender.cursor.len);
2315
+ struct aws_http1_chunk_options options = s_default_chunk_options(body_stream, body_sender.cursor.len);
2309
2316
  options.on_complete = NULL; /* The stream_tester takes care of the stream deletion */
2310
2317
  ASSERT_SUCCESS(aws_http1_stream_write_chunk(stream_tester.stream, &options));
2311
2318
  ASSERT_SUCCESS(s_write_termination_chunk(allocator, stream_tester.stream));
2312
2319
 
2313
2320
  /* Ensure the request can be destroyed after request is sent */
2314
2321
  aws_http_message_destroy(request);
2322
+ aws_input_stream_release(body_stream);
2315
2323
 
2316
2324
  /* tick loop until body finishes sending.*/
2317
2325
  while (body_sender.cursor.len > 0) {
@@ -3060,7 +3068,7 @@ static int s_test_content_length_mismatch_is_error(
3060
3068
  ASSERT_INT_EQUALS(AWS_ERROR_HTTP_OUTGOING_STREAM_LENGTH_INCORRECT, completion_error_code);
3061
3069
 
3062
3070
  /* clean up */
3063
- aws_input_stream_destroy(body_stream);
3071
+ aws_input_stream_release(body_stream);
3064
3072
  aws_http_message_destroy(request);
3065
3073
  aws_http_stream_release(stream);
3066
3074
 
@@ -3302,11 +3310,13 @@ enum request_callback {
3302
3310
  static const int ERROR_FROM_CALLBACK_ERROR_CODE = (int)0xBEEFCAFE;
3303
3311
 
3304
3312
  struct error_from_callback_tester {
3313
+ struct aws_input_stream base;
3305
3314
  enum request_callback error_at;
3306
3315
  int callback_counts[REQUEST_CALLBACK_COUNT];
3307
3316
  bool has_errored;
3308
3317
  struct aws_stream_status status;
3309
3318
  int on_complete_error_code;
3319
+ struct aws_allocator *alloc;
3310
3320
  };
3311
3321
 
3312
3322
  static int s_error_from_callback_common(
@@ -3330,7 +3340,7 @@ static int s_error_from_outgoing_body_read(struct aws_input_stream *body, struct
3330
3340
 
3331
3341
  (void)dest;
3332
3342
 
3333
- struct error_from_callback_tester *error_tester = body->impl;
3343
+ struct error_from_callback_tester *error_tester = AWS_CONTAINER_OF(body, struct error_from_callback_tester, base);
3334
3344
  if (s_error_from_callback_common(error_tester, REQUEST_CALLBACK_OUTGOING_BODY)) {
3335
3345
  return AWS_OP_ERR;
3336
3346
  }
@@ -3342,13 +3352,13 @@ static int s_error_from_outgoing_body_read(struct aws_input_stream *body, struct
3342
3352
  }
3343
3353
 
3344
3354
  static int s_error_from_outgoing_body_get_status(struct aws_input_stream *body, struct aws_stream_status *status) {
3345
- struct error_from_callback_tester *error_tester = body->impl;
3355
+ struct error_from_callback_tester *error_tester = AWS_CONTAINER_OF(body, struct error_from_callback_tester, base);
3346
3356
  *status = error_tester->status;
3347
3357
  return AWS_OP_SUCCESS;
3348
3358
  }
3349
3359
 
3350
3360
  static void s_error_from_outgoing_body_destroy(struct aws_input_stream *stream) {
3351
- aws_mem_release(stream->allocator, stream);
3361
+ (void)stream;
3352
3362
  }
3353
3363
 
3354
3364
  static struct aws_input_stream_vtable s_error_from_outgoing_body_vtable = {
@@ -3356,7 +3366,6 @@ static struct aws_input_stream_vtable s_error_from_outgoing_body_vtable = {
3356
3366
  .read = s_error_from_outgoing_body_read,
3357
3367
  .get_status = s_error_from_outgoing_body_get_status,
3358
3368
  .get_length = NULL,
3359
- .destroy = s_error_from_outgoing_body_destroy,
3360
3369
  };
3361
3370
 
3362
3371
  static int s_error_from_incoming_headers(
@@ -3403,7 +3412,10 @@ static int s_test_error_from_callback(struct aws_allocator *allocator, enum requ
3403
3412
  struct tester tester;
3404
3413
  ASSERT_SUCCESS(s_tester_init(&tester, allocator));
3405
3414
 
3415
+ struct aws_input_stream empty_stream_base;
3416
+ AWS_ZERO_STRUCT(empty_stream_base);
3406
3417
  struct error_from_callback_tester error_tester = {
3418
+ .base = empty_stream_base,
3407
3419
  .error_at = error_at,
3408
3420
  .status =
3409
3421
  {
@@ -3411,12 +3423,12 @@ static int s_test_error_from_callback(struct aws_allocator *allocator, enum requ
3411
3423
  .is_end_of_stream = false,
3412
3424
  },
3413
3425
  };
3414
- struct aws_input_stream error_from_outgoing_body_stream = {
3415
- .allocator = allocator,
3416
- .impl = &error_tester,
3417
- .vtable = &s_error_from_outgoing_body_vtable,
3418
- };
3419
-
3426
+ error_tester.base.vtable = &s_error_from_outgoing_body_vtable;
3427
+ aws_ref_count_init(
3428
+ &error_tester.base.ref_count,
3429
+ &error_tester,
3430
+ (aws_simple_completion_callback *)s_error_from_outgoing_body_destroy);
3431
+ struct aws_input_stream *error_from_outgoing_body_stream = &error_tester.base;
3420
3432
  /* send request */
3421
3433
  struct aws_http_header headers[] = {
3422
3434
  {
@@ -3430,7 +3442,7 @@ static int s_test_error_from_callback(struct aws_allocator *allocator, enum requ
3430
3442
  ASSERT_SUCCESS(aws_http_message_set_request_method(request, aws_http_method_post));
3431
3443
  ASSERT_SUCCESS(aws_http_message_set_request_path(request, aws_byte_cursor_from_c_str("/")));
3432
3444
  ASSERT_SUCCESS(aws_http_message_add_header_array(request, headers, AWS_ARRAY_SIZE(headers)));
3433
- aws_http_message_set_body_stream(request, &error_from_outgoing_body_stream);
3445
+ aws_http_message_set_body_stream(request, error_from_outgoing_body_stream);
3434
3446
 
3435
3447
  struct aws_http_make_request_options opt = {
3436
3448
  .self_size = sizeof(opt),
@@ -3450,6 +3462,7 @@ static int s_test_error_from_callback(struct aws_allocator *allocator, enum requ
3450
3462
 
3451
3463
  /* Ensure the request can be destroyed after request is sent */
3452
3464
  aws_http_message_destroy(opt.request);
3465
+ aws_input_stream_release(error_from_outgoing_body_stream);
3453
3466
 
3454
3467
  /* send response */
3455
3468
  ASSERT_SUCCESS(testing_channel_push_read_str_ignore_errors(
@@ -76,7 +76,7 @@ H1_ENCODER_TEST_CASE(h1_encoder_content_length_put_request_headers) {
76
76
  ASSERT_FALSE(encoder_message.has_connection_close_header);
77
77
  ASSERT_UINT_EQUALS(body.len, encoder_message.content_length);
78
78
 
79
- aws_input_stream_destroy(body_stream);
79
+ aws_input_stream_release(body_stream);
80
80
  aws_http_message_destroy(request);
81
81
  aws_h1_encoder_message_clean_up(&encoder_message);
82
82
  aws_h1_encoder_clean_up(&encoder);
@@ -232,7 +232,7 @@ H1_ENCODER_TEST_CASE(h1_encoder_transfer_encoding_not_chunked_put_request_header
232
232
  ASSERT_FALSE(encoder_message.has_connection_close_header);
233
233
  ASSERT_UINT_EQUALS(0, encoder_message.content_length);
234
234
 
235
- aws_input_stream_destroy(body_stream);
235
+ aws_input_stream_release(body_stream);
236
236
  aws_http_message_destroy(request);
237
237
  aws_h1_encoder_message_clean_up(&encoder_message);
238
238
  aws_h1_encoder_clean_up(&encoder);
@@ -274,7 +274,7 @@ H1_ENCODER_TEST_CASE(h1_encoder_transfer_encoding_set_body_stream_errors) {
274
274
  ASSERT_FALSE(encoder_message.has_connection_close_header);
275
275
  ASSERT_UINT_EQUALS(0, encoder_message.content_length);
276
276
 
277
- aws_input_stream_destroy(body_stream);
277
+ aws_input_stream_release(body_stream);
278
278
  aws_http_message_destroy(request);
279
279
  aws_h1_encoder_message_clean_up(&encoder_message);
280
280
  aws_h1_encoder_clean_up(&encoder);
@@ -396,7 +396,7 @@ H1_ENCODER_TEST_CASE(h1_encoder_transfer_encoding_chunked_and_content_length_put
396
396
  ASSERT_INT_EQUALS(
397
397
  AWS_OP_ERR, aws_h1_encoder_message_init_from_request(&encoder_message, allocator, request, &chunk_list));
398
398
 
399
- aws_input_stream_destroy(body_stream);
399
+ aws_input_stream_release(body_stream);
400
400
  aws_http_message_destroy(request);
401
401
  aws_h1_encoder_message_clean_up(&encoder_message);
402
402
  aws_h1_encoder_clean_up(&encoder);