es_cli 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (485) hide show
  1. checksums.yaml +7 -0
  2. data/.bundle/config +2 -0
  3. data/LICENSE.txt +21 -0
  4. data/README.md +39 -0
  5. data/Rakefile +12 -0
  6. data/exe/es +8 -0
  7. data/lib/es_cli/cli.rb +247 -0
  8. data/lib/es_cli/version.rb +5 -0
  9. data/lib/es_cli.rb +11 -0
  10. data/readme.org +78 -0
  11. data/sig/es_cli.rbs +4 -0
  12. data/vendor/bundle/ruby/3.1.0/bin/rake +29 -0
  13. data/vendor/bundle/ruby/3.1.0/bin/thor +29 -0
  14. data/vendor/bundle/ruby/3.1.0/cache/event_stream_parser-1.0.0.gem +0 -0
  15. data/vendor/bundle/ruby/3.1.0/cache/faraday-2.12.2.gem +0 -0
  16. data/vendor/bundle/ruby/3.1.0/cache/faraday-multipart-1.1.0.gem +0 -0
  17. data/vendor/bundle/ruby/3.1.0/cache/faraday-net_http-3.4.0.gem +0 -0
  18. data/vendor/bundle/ruby/3.1.0/cache/json-2.9.1.gem +0 -0
  19. data/vendor/bundle/ruby/3.1.0/cache/logger-1.6.5.gem +0 -0
  20. data/vendor/bundle/ruby/3.1.0/cache/multipart-post-2.4.1.gem +0 -0
  21. data/vendor/bundle/ruby/3.1.0/cache/net-http-0.6.0.gem +0 -0
  22. data/vendor/bundle/ruby/3.1.0/cache/power_assert-2.0.5.gem +0 -0
  23. data/vendor/bundle/ruby/3.1.0/cache/rake-13.2.1.gem +0 -0
  24. data/vendor/bundle/ruby/3.1.0/cache/ruby-openai-7.3.1.gem +0 -0
  25. data/vendor/bundle/ruby/3.1.0/cache/test-unit-3.6.7.gem +0 -0
  26. data/vendor/bundle/ruby/3.1.0/cache/thor-1.3.2.gem +0 -0
  27. data/vendor/bundle/ruby/3.1.0/cache/uri-1.0.2.gem +0 -0
  28. data/vendor/bundle/ruby/3.1.0/extensions/arm64-darwin-23/3.1.0/json-2.9.1/gem.build_complete +0 -0
  29. data/vendor/bundle/ruby/3.1.0/extensions/arm64-darwin-23/3.1.0/json-2.9.1/gem_make.out +22 -0
  30. data/vendor/bundle/ruby/3.1.0/extensions/arm64-darwin-23/3.1.0/json-2.9.1/json/ext/generator.bundle +0 -0
  31. data/vendor/bundle/ruby/3.1.0/extensions/arm64-darwin-23/3.1.0/json-2.9.1/json/ext/parser.bundle +0 -0
  32. data/vendor/bundle/ruby/3.1.0/extensions/arm64-darwin-23/3.1.0/json-2.9.1/mkmf.log +208 -0
  33. data/vendor/bundle/ruby/3.1.0/gems/event_stream_parser-1.0.0/LICENSE.md +21 -0
  34. data/vendor/bundle/ruby/3.1.0/gems/event_stream_parser-1.0.0/README.md +99 -0
  35. data/vendor/bundle/ruby/3.1.0/gems/event_stream_parser-1.0.0/lib/event_stream_parser/version.rb +5 -0
  36. data/vendor/bundle/ruby/3.1.0/gems/event_stream_parser-1.0.0/lib/event_stream_parser.rb +222 -0
  37. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/CHANGELOG.md +574 -0
  38. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/LICENSE.md +20 -0
  39. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/README.md +67 -0
  40. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/Rakefile +12 -0
  41. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/examples/client_spec.rb +119 -0
  42. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/examples/client_test.rb +144 -0
  43. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/adapter/test.rb +311 -0
  44. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/adapter.rb +101 -0
  45. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/adapter_registry.rb +30 -0
  46. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/connection.rb +564 -0
  47. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/encoders/flat_params_encoder.rb +105 -0
  48. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/encoders/nested_params_encoder.rb +183 -0
  49. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/error.rb +165 -0
  50. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/logging/formatter.rb +118 -0
  51. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/methods.rb +6 -0
  52. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/middleware.rb +72 -0
  53. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/middleware_registry.rb +83 -0
  54. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/options/connection_options.rb +23 -0
  55. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/options/env.rb +204 -0
  56. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/options/proxy_options.rb +36 -0
  57. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/options/request_options.rb +23 -0
  58. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/options/ssl_options.rb +73 -0
  59. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/options.rb +219 -0
  60. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/parameters.rb +5 -0
  61. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/rack_builder.rb +251 -0
  62. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/request/authorization.rb +54 -0
  63. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/request/instrumentation.rb +58 -0
  64. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/request/json.rb +70 -0
  65. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/request/url_encoded.rb +60 -0
  66. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/request.rb +139 -0
  67. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/response/json.rb +74 -0
  68. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/response/logger.rb +37 -0
  69. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/response/raise_error.rb +83 -0
  70. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/response.rb +91 -0
  71. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/utils/headers.rb +150 -0
  72. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/utils/params_hash.rb +61 -0
  73. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/utils.rb +121 -0
  74. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday/version.rb +5 -0
  75. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/lib/faraday.rb +157 -0
  76. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/external_adapters/faraday_specs_setup.rb +14 -0
  77. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/adapter/test_spec.rb +442 -0
  78. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/adapter_registry_spec.rb +28 -0
  79. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/adapter_spec.rb +55 -0
  80. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/connection_spec.rb +808 -0
  81. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/error_spec.rb +93 -0
  82. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/middleware_registry_spec.rb +31 -0
  83. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/middleware_spec.rb +213 -0
  84. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/options/env_spec.rb +76 -0
  85. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/options/options_spec.rb +297 -0
  86. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/options/proxy_options_spec.rb +52 -0
  87. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/options/request_options_spec.rb +19 -0
  88. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/params_encoders/flat_spec.rb +42 -0
  89. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/params_encoders/nested_spec.rb +151 -0
  90. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/rack_builder_spec.rb +317 -0
  91. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/request/authorization_spec.rb +118 -0
  92. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/request/instrumentation_spec.rb +74 -0
  93. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/request/json_spec.rb +199 -0
  94. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/request/url_encoded_spec.rb +93 -0
  95. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/request_spec.rb +110 -0
  96. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/response/json_spec.rb +206 -0
  97. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/response/logger_spec.rb +278 -0
  98. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/response/raise_error_spec.rb +275 -0
  99. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/response_spec.rb +77 -0
  100. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/utils/headers_spec.rb +109 -0
  101. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday/utils_spec.rb +119 -0
  102. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/faraday_spec.rb +43 -0
  103. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/spec_helper.rb +133 -0
  104. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/support/disabling_stub.rb +14 -0
  105. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/support/fake_safe_buffer.rb +15 -0
  106. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/support/faraday_middleware_subclasses.rb +18 -0
  107. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/support/helper_methods.rb +96 -0
  108. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/support/shared_examples/adapter.rb +105 -0
  109. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/support/shared_examples/params_encoder.rb +18 -0
  110. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/support/shared_examples/request_method.rb +263 -0
  111. data/vendor/bundle/ruby/3.1.0/gems/faraday-2.12.2/spec/support/streaming_response_checker.rb +35 -0
  112. data/vendor/bundle/ruby/3.1.0/gems/faraday-multipart-1.1.0/CHANGELOG.md +54 -0
  113. data/vendor/bundle/ruby/3.1.0/gems/faraday-multipart-1.1.0/LICENSE.md +21 -0
  114. data/vendor/bundle/ruby/3.1.0/gems/faraday-multipart-1.1.0/README.md +170 -0
  115. data/vendor/bundle/ruby/3.1.0/gems/faraday-multipart-1.1.0/lib/faraday/multipart/file_part.rb +130 -0
  116. data/vendor/bundle/ruby/3.1.0/gems/faraday-multipart-1.1.0/lib/faraday/multipart/middleware.rb +134 -0
  117. data/vendor/bundle/ruby/3.1.0/gems/faraday-multipart-1.1.0/lib/faraday/multipart/param_part.rb +55 -0
  118. data/vendor/bundle/ruby/3.1.0/gems/faraday-multipart-1.1.0/lib/faraday/multipart/version.rb +16 -0
  119. data/vendor/bundle/ruby/3.1.0/gems/faraday-multipart-1.1.0/lib/faraday/multipart.rb +26 -0
  120. data/vendor/bundle/ruby/3.1.0/gems/faraday-net_http-3.4.0/LICENSE.md +21 -0
  121. data/vendor/bundle/ruby/3.1.0/gems/faraday-net_http-3.4.0/README.md +57 -0
  122. data/vendor/bundle/ruby/3.1.0/gems/faraday-net_http-3.4.0/lib/faraday/adapter/net_http.rb +206 -0
  123. data/vendor/bundle/ruby/3.1.0/gems/faraday-net_http-3.4.0/lib/faraday/net_http/version.rb +7 -0
  124. data/vendor/bundle/ruby/3.1.0/gems/faraday-net_http-3.4.0/lib/faraday/net_http.rb +10 -0
  125. data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/BSDL +22 -0
  126. data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/CHANGES.md +572 -0
  127. data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/COPYING +56 -0
  128. data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/LEGAL +60 -0
  129. data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/README.md +195 -0
  130. data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/ext/json/ext/fbuffer/fbuffer.h +214 -0
  131. data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/ext/json/ext/generator/.sitearchdir.-.json.-.ext.time +0 -0
  132. data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/ext/json/ext/generator/Makefile +269 -0
  133. data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/ext/json/ext/generator/extconf.rb +10 -0
  134. data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/ext/json/ext/generator/generator.bundle +0 -0
  135. data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/ext/json/ext/generator/generator.c +1691 -0
  136. data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/ext/json/ext/generator/generator.o +0 -0
  137. data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/ext/json/ext/parser/.sitearchdir.-.json.-.ext.time +0 -0
  138. data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/ext/json/ext/parser/Makefile +269 -0
  139. data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/ext/json/ext/parser/extconf.rb +12 -0
  140. data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/ext/json/ext/parser/parser.bundle +0 -0
  141. data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/ext/json/ext/parser/parser.c +3238 -0
  142. data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/ext/json/ext/parser/parser.o +0 -0
  143. data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/ext/json/ext/parser/parser.rl +1465 -0
  144. data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/json.gemspec +64 -0
  145. data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/lib/json/add/bigdecimal.rb +58 -0
  146. data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/lib/json/add/complex.rb +51 -0
  147. data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/lib/json/add/core.rb +12 -0
  148. data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/lib/json/add/date.rb +54 -0
  149. data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/lib/json/add/date_time.rb +67 -0
  150. data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/lib/json/add/exception.rb +49 -0
  151. data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/lib/json/add/ostruct.rb +54 -0
  152. data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/lib/json/add/range.rb +54 -0
  153. data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/lib/json/add/rational.rb +49 -0
  154. data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/lib/json/add/regexp.rb +48 -0
  155. data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/lib/json/add/set.rb +48 -0
  156. data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/lib/json/add/struct.rb +52 -0
  157. data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/lib/json/add/symbol.rb +47 -0
  158. data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/lib/json/add/time.rb +52 -0
  159. data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/lib/json/common.rb +896 -0
  160. data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/lib/json/ext/generator/state.rb +116 -0
  161. data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/lib/json/ext/generator.bundle +0 -0
  162. data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/lib/json/ext/parser.bundle +0 -0
  163. data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/lib/json/ext.rb +23 -0
  164. data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/lib/json/generic_object.rb +75 -0
  165. data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/lib/json/truffle_ruby/generator.rb +629 -0
  166. data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/lib/json/version.rb +5 -0
  167. data/vendor/bundle/ruby/3.1.0/gems/json-2.9.1/lib/json.rb +587 -0
  168. data/vendor/bundle/ruby/3.1.0/gems/logger-1.6.5/.github/dependabot.yml +6 -0
  169. data/vendor/bundle/ruby/3.1.0/gems/logger-1.6.5/.github/workflows/push_gem.yml +46 -0
  170. data/vendor/bundle/ruby/3.1.0/gems/logger-1.6.5/.github/workflows/test.yml +32 -0
  171. data/vendor/bundle/ruby/3.1.0/gems/logger-1.6.5/.gitignore +11 -0
  172. data/vendor/bundle/ruby/3.1.0/gems/logger-1.6.5/BSDL +22 -0
  173. data/vendor/bundle/ruby/3.1.0/gems/logger-1.6.5/COPYING +56 -0
  174. data/vendor/bundle/ruby/3.1.0/gems/logger-1.6.5/Gemfile +10 -0
  175. data/vendor/bundle/ruby/3.1.0/gems/logger-1.6.5/README.md +104 -0
  176. data/vendor/bundle/ruby/3.1.0/gems/logger-1.6.5/Rakefile +30 -0
  177. data/vendor/bundle/ruby/3.1.0/gems/logger-1.6.5/bin/console +14 -0
  178. data/vendor/bundle/ruby/3.1.0/gems/logger-1.6.5/bin/setup +8 -0
  179. data/vendor/bundle/ruby/3.1.0/gems/logger-1.6.5/lib/logger/errors.rb +9 -0
  180. data/vendor/bundle/ruby/3.1.0/gems/logger-1.6.5/lib/logger/formatter.rb +36 -0
  181. data/vendor/bundle/ruby/3.1.0/gems/logger-1.6.5/lib/logger/log_device.rb +241 -0
  182. data/vendor/bundle/ruby/3.1.0/gems/logger-1.6.5/lib/logger/period.rb +47 -0
  183. data/vendor/bundle/ruby/3.1.0/gems/logger-1.6.5/lib/logger/severity.rb +38 -0
  184. data/vendor/bundle/ruby/3.1.0/gems/logger-1.6.5/lib/logger/version.rb +5 -0
  185. data/vendor/bundle/ruby/3.1.0/gems/logger-1.6.5/lib/logger.rb +761 -0
  186. data/vendor/bundle/ruby/3.1.0/gems/logger-1.6.5/logger.gemspec +28 -0
  187. data/vendor/bundle/ruby/3.1.0/gems/multipart-post-2.4.1/changelog.md +14 -0
  188. data/vendor/bundle/ruby/3.1.0/gems/multipart-post-2.4.1/lib/composite_io.rb +17 -0
  189. data/vendor/bundle/ruby/3.1.0/gems/multipart-post-2.4.1/lib/multipart/post/composite_read_io.rb +91 -0
  190. data/vendor/bundle/ruby/3.1.0/gems/multipart-post-2.4.1/lib/multipart/post/multipartable.rb +70 -0
  191. data/vendor/bundle/ruby/3.1.0/gems/multipart-post-2.4.1/lib/multipart/post/parts.rb +148 -0
  192. data/vendor/bundle/ruby/3.1.0/gems/multipart-post-2.4.1/lib/multipart/post/upload_io.rb +64 -0
  193. data/vendor/bundle/ruby/3.1.0/gems/multipart-post-2.4.1/lib/multipart/post/version.rb +11 -0
  194. data/vendor/bundle/ruby/3.1.0/gems/multipart-post-2.4.1/lib/multipart/post.rb +8 -0
  195. data/vendor/bundle/ruby/3.1.0/gems/multipart-post-2.4.1/lib/multipart_post.rb +11 -0
  196. data/vendor/bundle/ruby/3.1.0/gems/multipart-post-2.4.1/lib/multipartable.rb +19 -0
  197. data/vendor/bundle/ruby/3.1.0/gems/multipart-post-2.4.1/lib/net/http/post/multipart.rb +28 -0
  198. data/vendor/bundle/ruby/3.1.0/gems/multipart-post-2.4.1/lib/parts.rb +25 -0
  199. data/vendor/bundle/ruby/3.1.0/gems/multipart-post-2.4.1/license.md +58 -0
  200. data/vendor/bundle/ruby/3.1.0/gems/multipart-post-2.4.1/readme.md +170 -0
  201. data/vendor/bundle/ruby/3.1.0/gems/net-http-0.6.0/BSDL +22 -0
  202. data/vendor/bundle/ruby/3.1.0/gems/net-http-0.6.0/COPYING +56 -0
  203. data/vendor/bundle/ruby/3.1.0/gems/net-http-0.6.0/Gemfile +8 -0
  204. data/vendor/bundle/ruby/3.1.0/gems/net-http-0.6.0/README.md +93 -0
  205. data/vendor/bundle/ruby/3.1.0/gems/net-http-0.6.0/Rakefile +10 -0
  206. data/vendor/bundle/ruby/3.1.0/gems/net-http-0.6.0/bin/console +14 -0
  207. data/vendor/bundle/ruby/3.1.0/gems/net-http-0.6.0/bin/setup +8 -0
  208. data/vendor/bundle/ruby/3.1.0/gems/net-http-0.6.0/doc/net-http/examples.rdoc +31 -0
  209. data/vendor/bundle/ruby/3.1.0/gems/net-http-0.6.0/doc/net-http/included_getters.rdoc +3 -0
  210. data/vendor/bundle/ruby/3.1.0/gems/net-http-0.6.0/lib/net/http/exceptions.rb +34 -0
  211. data/vendor/bundle/ruby/3.1.0/gems/net-http-0.6.0/lib/net/http/generic_request.rb +414 -0
  212. data/vendor/bundle/ruby/3.1.0/gems/net-http-0.6.0/lib/net/http/header.rb +981 -0
  213. data/vendor/bundle/ruby/3.1.0/gems/net-http-0.6.0/lib/net/http/proxy_delta.rb +17 -0
  214. data/vendor/bundle/ruby/3.1.0/gems/net-http-0.6.0/lib/net/http/request.rb +88 -0
  215. data/vendor/bundle/ruby/3.1.0/gems/net-http-0.6.0/lib/net/http/requests.rb +430 -0
  216. data/vendor/bundle/ruby/3.1.0/gems/net-http-0.6.0/lib/net/http/response.rb +738 -0
  217. data/vendor/bundle/ruby/3.1.0/gems/net-http-0.6.0/lib/net/http/responses.rb +1174 -0
  218. data/vendor/bundle/ruby/3.1.0/gems/net-http-0.6.0/lib/net/http/status.rb +84 -0
  219. data/vendor/bundle/ruby/3.1.0/gems/net-http-0.6.0/lib/net/http.rb +2580 -0
  220. data/vendor/bundle/ruby/3.1.0/gems/net-http-0.6.0/lib/net/https.rb +23 -0
  221. data/vendor/bundle/ruby/3.1.0/gems/net-http-0.6.0/net-http.gemspec +39 -0
  222. data/vendor/bundle/ruby/3.1.0/gems/power_assert-2.0.5/.github/dependabot.yml +6 -0
  223. data/vendor/bundle/ruby/3.1.0/gems/power_assert-2.0.5/.github/workflows/ci.yml +46 -0
  224. data/vendor/bundle/ruby/3.1.0/gems/power_assert-2.0.5/.gitignore +9 -0
  225. data/vendor/bundle/ruby/3.1.0/gems/power_assert-2.0.5/BSDL +22 -0
  226. data/vendor/bundle/ruby/3.1.0/gems/power_assert-2.0.5/COPYING +57 -0
  227. data/vendor/bundle/ruby/3.1.0/gems/power_assert-2.0.5/Gemfile +19 -0
  228. data/vendor/bundle/ruby/3.1.0/gems/power_assert-2.0.5/LEGAL +4 -0
  229. data/vendor/bundle/ruby/3.1.0/gems/power_assert-2.0.5/README.md +98 -0
  230. data/vendor/bundle/ruby/3.1.0/gems/power_assert-2.0.5/Rakefile +59 -0
  231. data/vendor/bundle/ruby/3.1.0/gems/power_assert-2.0.5/lib/power_assert/colorize.rb +7 -0
  232. data/vendor/bundle/ruby/3.1.0/gems/power_assert-2.0.5/lib/power_assert/configuration.rb +46 -0
  233. data/vendor/bundle/ruby/3.1.0/gems/power_assert-2.0.5/lib/power_assert/context.rb +233 -0
  234. data/vendor/bundle/ruby/3.1.0/gems/power_assert-2.0.5/lib/power_assert/enable_tracepoint_events.rb +62 -0
  235. data/vendor/bundle/ruby/3.1.0/gems/power_assert-2.0.5/lib/power_assert/inspector.rb +66 -0
  236. data/vendor/bundle/ruby/3.1.0/gems/power_assert-2.0.5/lib/power_assert/parser.rb +251 -0
  237. data/vendor/bundle/ruby/3.1.0/gems/power_assert-2.0.5/lib/power_assert/version.rb +3 -0
  238. data/vendor/bundle/ruby/3.1.0/gems/power_assert-2.0.5/lib/power_assert.rb +93 -0
  239. data/vendor/bundle/ruby/3.1.0/gems/power_assert-2.0.5/power_assert.gemspec +24 -0
  240. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/History.rdoc +2403 -0
  241. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/MIT-LICENSE +21 -0
  242. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/README.rdoc +155 -0
  243. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/doc/command_line_usage.rdoc +158 -0
  244. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/doc/example/Rakefile1 +38 -0
  245. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/doc/example/Rakefile2 +35 -0
  246. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/doc/example/a.c +6 -0
  247. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/doc/example/b.c +6 -0
  248. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/doc/example/main.c +11 -0
  249. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/doc/glossary.rdoc +42 -0
  250. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/doc/jamis.rb +592 -0
  251. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/doc/proto_rake.rdoc +127 -0
  252. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/doc/rake.1 +156 -0
  253. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/doc/rakefile.rdoc +622 -0
  254. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/doc/rational.rdoc +151 -0
  255. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/exe/rake +27 -0
  256. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/application.rb +861 -0
  257. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/backtrace.rb +25 -0
  258. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/clean.rb +78 -0
  259. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/cloneable.rb +17 -0
  260. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/cpu_counter.rb +107 -0
  261. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/default_loader.rb +15 -0
  262. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/dsl_definition.rb +196 -0
  263. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/early_time.rb +22 -0
  264. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/ext/core.rb +26 -0
  265. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/ext/string.rb +176 -0
  266. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/file_creation_task.rb +25 -0
  267. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/file_list.rb +435 -0
  268. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/file_task.rb +58 -0
  269. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/file_utils.rb +132 -0
  270. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/file_utils_ext.rb +134 -0
  271. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/invocation_chain.rb +57 -0
  272. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/invocation_exception_mixin.rb +17 -0
  273. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/late_time.rb +18 -0
  274. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/linked_list.rb +112 -0
  275. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/loaders/makefile.rb +54 -0
  276. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/multi_task.rb +14 -0
  277. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/name_space.rb +38 -0
  278. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/packagetask.rb +222 -0
  279. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/phony.rb +16 -0
  280. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/private_reader.rb +21 -0
  281. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/promise.rb +100 -0
  282. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/pseudo_status.rb +30 -0
  283. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/rake_module.rb +67 -0
  284. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/rake_test_loader.rb +27 -0
  285. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/rule_recursion_overflow_error.rb +20 -0
  286. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/scope.rb +43 -0
  287. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/task.rb +434 -0
  288. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/task_argument_error.rb +8 -0
  289. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/task_arguments.rb +109 -0
  290. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/task_manager.rb +331 -0
  291. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/tasklib.rb +12 -0
  292. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/testtask.rb +189 -0
  293. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/thread_history_display.rb +49 -0
  294. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/thread_pool.rb +163 -0
  295. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/trace_output.rb +23 -0
  296. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/version.rb +10 -0
  297. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake/win32.rb +51 -0
  298. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/lib/rake.rb +70 -0
  299. data/vendor/bundle/ruby/3.1.0/gems/rake-13.2.1/rake.gemspec +101 -0
  300. data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/.circleci/config.yml +46 -0
  301. data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/.devcontainer/Dockerfile +16 -0
  302. data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/.devcontainer/devcontainer.json +36 -0
  303. data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/.devcontainer/docker-compose.yml +19 -0
  304. data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/.github/FUNDING.yml +13 -0
  305. data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
  306. data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  307. data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/.github/dependabot.yml +15 -0
  308. data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/.gitignore +69 -0
  309. data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/.rspec +3 -0
  310. data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/.rubocop.yml +31 -0
  311. data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/CHANGELOG.md +467 -0
  312. data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/CODE_OF_CONDUCT.md +74 -0
  313. data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/CONTRIBUTING.md +3 -0
  314. data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/Gemfile +12 -0
  315. data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/Gemfile.lock +92 -0
  316. data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/LICENSE.txt +21 -0
  317. data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/README.md +1381 -0
  318. data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/Rakefile +19 -0
  319. data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/bin/console +14 -0
  320. data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/bin/setup +8 -0
  321. data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/lib/openai/assistants.rb +29 -0
  322. data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/lib/openai/audio.rb +19 -0
  323. data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/lib/openai/batches.rb +23 -0
  324. data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/lib/openai/client.rb +122 -0
  325. data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/lib/openai/compatibility.rb +10 -0
  326. data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/lib/openai/files.rb +75 -0
  327. data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/lib/openai/finetunes.rb +27 -0
  328. data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/lib/openai/http.rb +134 -0
  329. data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/lib/openai/http_headers.rb +36 -0
  330. data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/lib/openai/images.rb +27 -0
  331. data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/lib/openai/messages.rb +27 -0
  332. data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/lib/openai/models.rb +15 -0
  333. data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/lib/openai/run_steps.rb +15 -0
  334. data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/lib/openai/runs.rb +37 -0
  335. data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/lib/openai/threads.rb +23 -0
  336. data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/lib/openai/vector_store_file_batches.rb +29 -0
  337. data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/lib/openai/vector_store_files.rb +23 -0
  338. data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/lib/openai/vector_stores.rb +27 -0
  339. data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/lib/openai/version.rb +3 -0
  340. data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/lib/openai.rb +92 -0
  341. data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/lib/ruby/openai.rb +2 -0
  342. data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/pull_request_template.md +5 -0
  343. data/vendor/bundle/ruby/3.1.0/gems/ruby-openai-7.3.1/ruby-openai.gemspec +32 -0
  344. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/BSDL +24 -0
  345. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/COPYING +64 -0
  346. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/PSFL +271 -0
  347. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/README.md +108 -0
  348. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/Rakefile +74 -0
  349. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/doc/text/getting-started.md +246 -0
  350. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/doc/text/how-to.md +90 -0
  351. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/doc/text/news.md +1853 -0
  352. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/assertion-failed-error.rb +60 -0
  353. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/assertions.rb +2541 -0
  354. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/attribute-matcher.rb +26 -0
  355. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/attribute.rb +228 -0
  356. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/auto-runner-loader.rb +17 -0
  357. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/autorunner.rb +629 -0
  358. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/code-snippet-fetcher.rb +58 -0
  359. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/collector/descendant.rb +20 -0
  360. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/collector/dir.rb +110 -0
  361. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/collector/load.rb +201 -0
  362. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/collector/objectspace.rb +35 -0
  363. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/collector/xml.rb +249 -0
  364. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/collector.rb +104 -0
  365. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/color-scheme.rb +225 -0
  366. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/color.rb +134 -0
  367. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/data-sets.rb +127 -0
  368. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/data.rb +371 -0
  369. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/diff.rb +745 -0
  370. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/error.rb +158 -0
  371. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/exception-handler.rb +82 -0
  372. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/failure.rb +169 -0
  373. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/fault-location-detector.rb +104 -0
  374. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/fixture.rb +304 -0
  375. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/notification.rb +138 -0
  376. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/omission.rb +198 -0
  377. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/pending.rb +155 -0
  378. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/priority.rb +194 -0
  379. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/runner/console.rb +86 -0
  380. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/runner/emacs.rb +8 -0
  381. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/runner/xml.rb +15 -0
  382. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/sub-test-result.rb +59 -0
  383. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/test-suite-creator.rb +103 -0
  384. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/test-suite-runner.rb +128 -0
  385. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/test-suite-thread-runner.rb +69 -0
  386. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/testcase.rb +963 -0
  387. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/testresult.rb +132 -0
  388. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/testsuite.rb +108 -0
  389. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/ui/console/outputlevel.rb +15 -0
  390. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/ui/console/testrunner.rb +891 -0
  391. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/ui/emacs/testrunner.rb +49 -0
  392. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/ui/testrunner.rb +53 -0
  393. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/ui/testrunnermediator.rb +119 -0
  394. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/ui/testrunnerutilities.rb +41 -0
  395. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/ui/xml/testrunner.rb +224 -0
  396. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/util/backtracefilter.rb +59 -0
  397. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/util/memory-usage.rb +47 -0
  398. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/util/method-owner-finder.rb +28 -0
  399. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/util/observable.rb +86 -0
  400. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/util/output.rb +32 -0
  401. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/util/procwrapper.rb +48 -0
  402. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/version.rb +5 -0
  403. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit/warning.rb +3 -0
  404. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test/unit.rb +521 -0
  405. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/lib/test-unit.rb +19 -0
  406. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/sample/adder.rb +13 -0
  407. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/sample/subtracter.rb +12 -0
  408. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/sample/test_adder.rb +20 -0
  409. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/sample/test_subtracter.rb +20 -0
  410. data/vendor/bundle/ruby/3.1.0/gems/test-unit-3.6.7/sample/test_user.rb +23 -0
  411. data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/.document +5 -0
  412. data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/CONTRIBUTING.md +15 -0
  413. data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/LICENSE.md +20 -0
  414. data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/README.md +45 -0
  415. data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/bin/thor +6 -0
  416. data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/actions/create_file.rb +105 -0
  417. data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/actions/create_link.rb +61 -0
  418. data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/actions/directory.rb +108 -0
  419. data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/actions/empty_directory.rb +143 -0
  420. data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/actions/file_manipulation.rb +371 -0
  421. data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/actions/inject_into_file.rb +130 -0
  422. data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/actions.rb +340 -0
  423. data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/base.rb +825 -0
  424. data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/command.rb +151 -0
  425. data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/core_ext/hash_with_indifferent_access.rb +107 -0
  426. data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/error.rb +106 -0
  427. data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/group.rb +292 -0
  428. data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/invocation.rb +178 -0
  429. data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/line_editor/basic.rb +37 -0
  430. data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/line_editor/readline.rb +88 -0
  431. data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/line_editor.rb +17 -0
  432. data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/nested_context.rb +29 -0
  433. data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/parser/argument.rb +86 -0
  434. data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/parser/arguments.rb +195 -0
  435. data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/parser/option.rb +178 -0
  436. data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/parser/options.rb +294 -0
  437. data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/parser.rb +4 -0
  438. data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/rake_compat.rb +72 -0
  439. data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/runner.rb +335 -0
  440. data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/shell/basic.rb +388 -0
  441. data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/shell/color.rb +115 -0
  442. data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/shell/column_printer.rb +29 -0
  443. data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/shell/html.rb +84 -0
  444. data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/shell/lcs_diff.rb +49 -0
  445. data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/shell/table_printer.rb +118 -0
  446. data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/shell/terminal.rb +42 -0
  447. data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/shell/wrapped_printer.rb +38 -0
  448. data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/shell.rb +81 -0
  449. data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/util.rb +285 -0
  450. data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor/version.rb +3 -0
  451. data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/lib/thor.rb +674 -0
  452. data/vendor/bundle/ruby/3.1.0/gems/thor-1.3.2/thor.gemspec +33 -0
  453. data/vendor/bundle/ruby/3.1.0/gems/uri-1.0.2/BSDL +22 -0
  454. data/vendor/bundle/ruby/3.1.0/gems/uri-1.0.2/COPYING +56 -0
  455. data/vendor/bundle/ruby/3.1.0/gems/uri-1.0.2/README.md +55 -0
  456. data/vendor/bundle/ruby/3.1.0/gems/uri-1.0.2/lib/uri/common.rb +876 -0
  457. data/vendor/bundle/ruby/3.1.0/gems/uri-1.0.2/lib/uri/file.rb +100 -0
  458. data/vendor/bundle/ruby/3.1.0/gems/uri-1.0.2/lib/uri/ftp.rb +267 -0
  459. data/vendor/bundle/ruby/3.1.0/gems/uri-1.0.2/lib/uri/generic.rb +1578 -0
  460. data/vendor/bundle/ruby/3.1.0/gems/uri-1.0.2/lib/uri/http.rb +125 -0
  461. data/vendor/bundle/ruby/3.1.0/gems/uri-1.0.2/lib/uri/https.rb +23 -0
  462. data/vendor/bundle/ruby/3.1.0/gems/uri-1.0.2/lib/uri/ldap.rb +261 -0
  463. data/vendor/bundle/ruby/3.1.0/gems/uri-1.0.2/lib/uri/ldaps.rb +22 -0
  464. data/vendor/bundle/ruby/3.1.0/gems/uri-1.0.2/lib/uri/mailto.rb +293 -0
  465. data/vendor/bundle/ruby/3.1.0/gems/uri-1.0.2/lib/uri/rfc2396_parser.rb +546 -0
  466. data/vendor/bundle/ruby/3.1.0/gems/uri-1.0.2/lib/uri/rfc3986_parser.rb +206 -0
  467. data/vendor/bundle/ruby/3.1.0/gems/uri-1.0.2/lib/uri/version.rb +6 -0
  468. data/vendor/bundle/ruby/3.1.0/gems/uri-1.0.2/lib/uri/ws.rb +83 -0
  469. data/vendor/bundle/ruby/3.1.0/gems/uri-1.0.2/lib/uri/wss.rb +23 -0
  470. data/vendor/bundle/ruby/3.1.0/gems/uri-1.0.2/lib/uri.rb +104 -0
  471. data/vendor/bundle/ruby/3.1.0/specifications/event_stream_parser-1.0.0.gemspec +23 -0
  472. data/vendor/bundle/ruby/3.1.0/specifications/faraday-2.12.2.gemspec +0 -0
  473. data/vendor/bundle/ruby/3.1.0/specifications/faraday-multipart-1.1.0.gemspec +32 -0
  474. data/vendor/bundle/ruby/3.1.0/specifications/faraday-net_http-3.4.0.gemspec +32 -0
  475. data/vendor/bundle/ruby/3.1.0/specifications/json-2.9.1.gemspec +0 -0
  476. data/vendor/bundle/ruby/3.1.0/specifications/logger-1.6.5.gemspec +22 -0
  477. data/vendor/bundle/ruby/3.1.0/specifications/multipart-post-2.4.1.gemspec +21 -0
  478. data/vendor/bundle/ruby/3.1.0/specifications/net-http-0.6.0.gemspec +33 -0
  479. data/vendor/bundle/ruby/3.1.0/specifications/power_assert-2.0.5.gemspec +24 -0
  480. data/vendor/bundle/ruby/3.1.0/specifications/rake-13.2.1.gemspec +26 -0
  481. data/vendor/bundle/ruby/3.1.0/specifications/ruby-openai-7.3.1.gemspec +36 -0
  482. data/vendor/bundle/ruby/3.1.0/specifications/test-unit-3.6.7.gemspec +31 -0
  483. data/vendor/bundle/ruby/3.1.0/specifications/thor-1.3.2.gemspec +34 -0
  484. data/vendor/bundle/ruby/3.1.0/specifications/uri-1.0.2.gemspec +23 -0
  485. metadata +560 -0
@@ -0,0 +1,981 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # The \HTTPHeader module provides access to \HTTP headers.
4
+ #
5
+ # The module is included in:
6
+ #
7
+ # - Net::HTTPGenericRequest (and therefore Net::HTTPRequest).
8
+ # - Net::HTTPResponse.
9
+ #
10
+ # The headers are a hash-like collection of key/value pairs called _fields_.
11
+ #
12
+ # == Request and Response Fields
13
+ #
14
+ # Headers may be included in:
15
+ #
16
+ # - A Net::HTTPRequest object:
17
+ # the object's headers will be sent with the request.
18
+ # Any fields may be defined in the request;
19
+ # see {Setters}[rdoc-ref:Net::HTTPHeader@Setters].
20
+ # - A Net::HTTPResponse object:
21
+ # the objects headers are usually those returned from the host.
22
+ # Fields may be retrieved from the object;
23
+ # see {Getters}[rdoc-ref:Net::HTTPHeader@Getters]
24
+ # and {Iterators}[rdoc-ref:Net::HTTPHeader@Iterators].
25
+ #
26
+ # Exactly which fields should be sent or expected depends on the host;
27
+ # see:
28
+ #
29
+ # - {Request fields}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Request_fields].
30
+ # - {Response fields}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Response_fields].
31
+ #
32
+ # == About the Examples
33
+ #
34
+ # :include: doc/net-http/examples.rdoc
35
+ #
36
+ # == Fields
37
+ #
38
+ # A header field is a key/value pair.
39
+ #
40
+ # === Field Keys
41
+ #
42
+ # A field key may be:
43
+ #
44
+ # - A string: Key <tt>'Accept'</tt> is treated as if it were
45
+ # <tt>'Accept'.downcase</tt>; i.e., <tt>'accept'</tt>.
46
+ # - A symbol: Key <tt>:Accept</tt> is treated as if it were
47
+ # <tt>:Accept.to_s.downcase</tt>; i.e., <tt>'accept'</tt>.
48
+ #
49
+ # Examples:
50
+ #
51
+ # req = Net::HTTP::Get.new(uri)
52
+ # req[:accept] # => "*/*"
53
+ # req['Accept'] # => "*/*"
54
+ # req['ACCEPT'] # => "*/*"
55
+ #
56
+ # req['accept'] = 'text/html'
57
+ # req[:accept] = 'text/html'
58
+ # req['ACCEPT'] = 'text/html'
59
+ #
60
+ # === Field Values
61
+ #
62
+ # A field value may be returned as an array of strings or as a string:
63
+ #
64
+ # - These methods return field values as arrays:
65
+ #
66
+ # - #get_fields: Returns the array value for the given key,
67
+ # or +nil+ if it does not exist.
68
+ # - #to_hash: Returns a hash of all header fields:
69
+ # each key is a field name; its value is the array value for the field.
70
+ #
71
+ # - These methods return field values as string;
72
+ # the string value for a field is equivalent to
73
+ # <tt>self[key.downcase.to_s].join(', '))</tt>:
74
+ #
75
+ # - #[]: Returns the string value for the given key,
76
+ # or +nil+ if it does not exist.
77
+ # - #fetch: Like #[], but accepts a default value
78
+ # to be returned if the key does not exist.
79
+ #
80
+ # The field value may be set:
81
+ #
82
+ # - #[]=: Sets the value for the given key;
83
+ # the given value may be a string, a symbol, an array, or a hash.
84
+ # - #add_field: Adds a given value to a value for the given key
85
+ # (not overwriting the existing value).
86
+ # - #delete: Deletes the field for the given key.
87
+ #
88
+ # Example field values:
89
+ #
90
+ # - \String:
91
+ #
92
+ # req['Accept'] = 'text/html' # => "text/html"
93
+ # req['Accept'] # => "text/html"
94
+ # req.get_fields('Accept') # => ["text/html"]
95
+ #
96
+ # - \Symbol:
97
+ #
98
+ # req['Accept'] = :text # => :text
99
+ # req['Accept'] # => "text"
100
+ # req.get_fields('Accept') # => ["text"]
101
+ #
102
+ # - Simple array:
103
+ #
104
+ # req[:foo] = %w[bar baz bat]
105
+ # req[:foo] # => "bar, baz, bat"
106
+ # req.get_fields(:foo) # => ["bar", "baz", "bat"]
107
+ #
108
+ # - Simple hash:
109
+ #
110
+ # req[:foo] = {bar: 0, baz: 1, bat: 2}
111
+ # req[:foo] # => "bar, 0, baz, 1, bat, 2"
112
+ # req.get_fields(:foo) # => ["bar", "0", "baz", "1", "bat", "2"]
113
+ #
114
+ # - Nested:
115
+ #
116
+ # req[:foo] = [%w[bar baz], {bat: 0, bam: 1}]
117
+ # req[:foo] # => "bar, baz, bat, 0, bam, 1"
118
+ # req.get_fields(:foo) # => ["bar", "baz", "bat", "0", "bam", "1"]
119
+ #
120
+ # req[:foo] = {bar: %w[baz bat], bam: {bah: 0, bad: 1}}
121
+ # req[:foo] # => "bar, baz, bat, bam, bah, 0, bad, 1"
122
+ # req.get_fields(:foo) # => ["bar", "baz", "bat", "bam", "bah", "0", "bad", "1"]
123
+ #
124
+ # == Convenience Methods
125
+ #
126
+ # Various convenience methods retrieve values, set values, query values,
127
+ # set form values, or iterate over fields.
128
+ #
129
+ # === Setters
130
+ #
131
+ # \Method #[]= can set any field, but does little to validate the new value;
132
+ # some of the other setter methods provide some validation:
133
+ #
134
+ # - #[]=: Sets the string or array value for the given key.
135
+ # - #add_field: Creates or adds to the array value for the given key.
136
+ # - #basic_auth: Sets the string authorization header for <tt>'Authorization'</tt>.
137
+ # - #content_length=: Sets the integer length for field <tt>'Content-Length</tt>.
138
+ # - #content_type=: Sets the string value for field <tt>'Content-Type'</tt>.
139
+ # - #proxy_basic_auth: Sets the string authorization header for <tt>'Proxy-Authorization'</tt>.
140
+ # - #set_range: Sets the value for field <tt>'Range'</tt>.
141
+ #
142
+ # === Form Setters
143
+ #
144
+ # - #set_form: Sets an HTML form data set.
145
+ # - #set_form_data: Sets header fields and a body from HTML form data.
146
+ #
147
+ # === Getters
148
+ #
149
+ # \Method #[] can retrieve the value of any field that exists,
150
+ # but always as a string;
151
+ # some of the other getter methods return something different
152
+ # from the simple string value:
153
+ #
154
+ # - #[]: Returns the string field value for the given key.
155
+ # - #content_length: Returns the integer value of field <tt>'Content-Length'</tt>.
156
+ # - #content_range: Returns the Range value of field <tt>'Content-Range'</tt>.
157
+ # - #content_type: Returns the string value of field <tt>'Content-Type'</tt>.
158
+ # - #fetch: Returns the string field value for the given key.
159
+ # - #get_fields: Returns the array field value for the given +key+.
160
+ # - #main_type: Returns first part of the string value of field <tt>'Content-Type'</tt>.
161
+ # - #sub_type: Returns second part of the string value of field <tt>'Content-Type'</tt>.
162
+ # - #range: Returns an array of Range objects of field <tt>'Range'</tt>, or +nil+.
163
+ # - #range_length: Returns the integer length of the range given in field <tt>'Content-Range'</tt>.
164
+ # - #type_params: Returns the string parameters for <tt>'Content-Type'</tt>.
165
+ #
166
+ # === Queries
167
+ #
168
+ # - #chunked?: Returns whether field <tt>'Transfer-Encoding'</tt> is set to <tt>'chunked'</tt>.
169
+ # - #connection_close?: Returns whether field <tt>'Connection'</tt> is set to <tt>'close'</tt>.
170
+ # - #connection_keep_alive?: Returns whether field <tt>'Connection'</tt> is set to <tt>'keep-alive'</tt>.
171
+ # - #key?: Returns whether a given key exists.
172
+ #
173
+ # === Iterators
174
+ #
175
+ # - #each_capitalized: Passes each field capitalized-name/value pair to the block.
176
+ # - #each_capitalized_name: Passes each capitalized field name to the block.
177
+ # - #each_header: Passes each field name/value pair to the block.
178
+ # - #each_name: Passes each field name to the block.
179
+ # - #each_value: Passes each string field value to the block.
180
+ #
181
+ module Net::HTTPHeader
182
+ MAX_KEY_LENGTH = 1024
183
+ MAX_FIELD_LENGTH = 65536
184
+
185
+ def initialize_http_header(initheader) #:nodoc:
186
+ @header = {}
187
+ return unless initheader
188
+ initheader.each do |key, value|
189
+ warn "net/http: duplicated HTTP header: #{key}", uplevel: 3 if key?(key) and $VERBOSE
190
+ if value.nil?
191
+ warn "net/http: nil HTTP header: #{key}", uplevel: 3 if $VERBOSE
192
+ else
193
+ value = value.strip # raise error for invalid byte sequences
194
+ if key.to_s.bytesize > MAX_KEY_LENGTH
195
+ raise ArgumentError, "too long (#{key.bytesize} bytes) header: #{key[0, 30].inspect}..."
196
+ end
197
+ if value.to_s.bytesize > MAX_FIELD_LENGTH
198
+ raise ArgumentError, "header #{key} has too long field value: #{value.bytesize}"
199
+ end
200
+ if value.count("\r\n") > 0
201
+ raise ArgumentError, "header #{key} has field value #{value.inspect}, this cannot include CR/LF"
202
+ end
203
+ @header[key.downcase.to_s] = [value]
204
+ end
205
+ end
206
+ end
207
+
208
+ def size #:nodoc: obsolete
209
+ @header.size
210
+ end
211
+
212
+ alias length size #:nodoc: obsolete
213
+
214
+ # Returns the string field value for the case-insensitive field +key+,
215
+ # or +nil+ if there is no such key;
216
+ # see {Fields}[rdoc-ref:Net::HTTPHeader@Fields]:
217
+ #
218
+ # res = Net::HTTP.get_response(hostname, '/todos/1')
219
+ # res['Connection'] # => "keep-alive"
220
+ # res['Nosuch'] # => nil
221
+ #
222
+ # Note that some field values may be retrieved via convenience methods;
223
+ # see {Getters}[rdoc-ref:Net::HTTPHeader@Getters].
224
+ def [](key)
225
+ a = @header[key.downcase.to_s] or return nil
226
+ a.join(', ')
227
+ end
228
+
229
+ # Sets the value for the case-insensitive +key+ to +val+,
230
+ # overwriting the previous value if the field exists;
231
+ # see {Fields}[rdoc-ref:Net::HTTPHeader@Fields]:
232
+ #
233
+ # req = Net::HTTP::Get.new(uri)
234
+ # req['Accept'] # => "*/*"
235
+ # req['Accept'] = 'text/html'
236
+ # req['Accept'] # => "text/html"
237
+ #
238
+ # Note that some field values may be set via convenience methods;
239
+ # see {Setters}[rdoc-ref:Net::HTTPHeader@Setters].
240
+ def []=(key, val)
241
+ unless val
242
+ @header.delete key.downcase.to_s
243
+ return val
244
+ end
245
+ set_field(key, val)
246
+ end
247
+
248
+ # Adds value +val+ to the value array for field +key+ if the field exists;
249
+ # creates the field with the given +key+ and +val+ if it does not exist.
250
+ # see {Fields}[rdoc-ref:Net::HTTPHeader@Fields]:
251
+ #
252
+ # req = Net::HTTP::Get.new(uri)
253
+ # req.add_field('Foo', 'bar')
254
+ # req['Foo'] # => "bar"
255
+ # req.add_field('Foo', 'baz')
256
+ # req['Foo'] # => "bar, baz"
257
+ # req.add_field('Foo', %w[baz bam])
258
+ # req['Foo'] # => "bar, baz, baz, bam"
259
+ # req.get_fields('Foo') # => ["bar", "baz", "baz", "bam"]
260
+ #
261
+ def add_field(key, val)
262
+ stringified_downcased_key = key.downcase.to_s
263
+ if @header.key?(stringified_downcased_key)
264
+ append_field_value(@header[stringified_downcased_key], val)
265
+ else
266
+ set_field(key, val)
267
+ end
268
+ end
269
+
270
+ private def set_field(key, val)
271
+ case val
272
+ when Enumerable
273
+ ary = []
274
+ append_field_value(ary, val)
275
+ @header[key.downcase.to_s] = ary
276
+ else
277
+ val = val.to_s # for compatibility use to_s instead of to_str
278
+ if val.b.count("\r\n") > 0
279
+ raise ArgumentError, 'header field value cannot include CR/LF'
280
+ end
281
+ @header[key.downcase.to_s] = [val]
282
+ end
283
+ end
284
+
285
+ private def append_field_value(ary, val)
286
+ case val
287
+ when Enumerable
288
+ val.each{|x| append_field_value(ary, x)}
289
+ else
290
+ val = val.to_s
291
+ if /[\r\n]/n.match?(val.b)
292
+ raise ArgumentError, 'header field value cannot include CR/LF'
293
+ end
294
+ ary.push val
295
+ end
296
+ end
297
+
298
+ # Returns the array field value for the given +key+,
299
+ # or +nil+ if there is no such field;
300
+ # see {Fields}[rdoc-ref:Net::HTTPHeader@Fields]:
301
+ #
302
+ # res = Net::HTTP.get_response(hostname, '/todos/1')
303
+ # res.get_fields('Connection') # => ["keep-alive"]
304
+ # res.get_fields('Nosuch') # => nil
305
+ #
306
+ def get_fields(key)
307
+ stringified_downcased_key = key.downcase.to_s
308
+ return nil unless @header[stringified_downcased_key]
309
+ @header[stringified_downcased_key].dup
310
+ end
311
+
312
+ # call-seq:
313
+ # fetch(key, default_val = nil) {|key| ... } -> object
314
+ # fetch(key, default_val = nil) -> value or default_val
315
+ #
316
+ # With a block, returns the string value for +key+ if it exists;
317
+ # otherwise returns the value of the block;
318
+ # ignores the +default_val+;
319
+ # see {Fields}[rdoc-ref:Net::HTTPHeader@Fields]:
320
+ #
321
+ # res = Net::HTTP.get_response(hostname, '/todos/1')
322
+ #
323
+ # # Field exists; block not called.
324
+ # res.fetch('Connection') do |value|
325
+ # fail 'Cannot happen'
326
+ # end # => "keep-alive"
327
+ #
328
+ # # Field does not exist; block called.
329
+ # res.fetch('Nosuch') do |value|
330
+ # value.downcase
331
+ # end # => "nosuch"
332
+ #
333
+ # With no block, returns the string value for +key+ if it exists;
334
+ # otherwise, returns +default_val+ if it was given;
335
+ # otherwise raises an exception:
336
+ #
337
+ # res.fetch('Connection', 'Foo') # => "keep-alive"
338
+ # res.fetch('Nosuch', 'Foo') # => "Foo"
339
+ # res.fetch('Nosuch') # Raises KeyError.
340
+ #
341
+ def fetch(key, *args, &block) #:yield: +key+
342
+ a = @header.fetch(key.downcase.to_s, *args, &block)
343
+ a.kind_of?(Array) ? a.join(', ') : a
344
+ end
345
+
346
+ # Calls the block with each key/value pair:
347
+ #
348
+ # res = Net::HTTP.get_response(hostname, '/todos/1')
349
+ # res.each_header do |key, value|
350
+ # p [key, value] if key.start_with?('c')
351
+ # end
352
+ #
353
+ # Output:
354
+ #
355
+ # ["content-type", "application/json; charset=utf-8"]
356
+ # ["connection", "keep-alive"]
357
+ # ["cache-control", "max-age=43200"]
358
+ # ["cf-cache-status", "HIT"]
359
+ # ["cf-ray", "771d17e9bc542cf5-ORD"]
360
+ #
361
+ # Returns an enumerator if no block is given.
362
+ #
363
+ # Net::HTTPHeader#each is an alias for Net::HTTPHeader#each_header.
364
+ def each_header #:yield: +key+, +value+
365
+ block_given? or return enum_for(__method__) { @header.size }
366
+ @header.each do |k,va|
367
+ yield k, va.join(', ')
368
+ end
369
+ end
370
+
371
+ alias each each_header
372
+
373
+ # Calls the block with each field key:
374
+ #
375
+ # res = Net::HTTP.get_response(hostname, '/todos/1')
376
+ # res.each_key do |key|
377
+ # p key if key.start_with?('c')
378
+ # end
379
+ #
380
+ # Output:
381
+ #
382
+ # "content-type"
383
+ # "connection"
384
+ # "cache-control"
385
+ # "cf-cache-status"
386
+ # "cf-ray"
387
+ #
388
+ # Returns an enumerator if no block is given.
389
+ #
390
+ # Net::HTTPHeader#each_name is an alias for Net::HTTPHeader#each_key.
391
+ def each_name(&block) #:yield: +key+
392
+ block_given? or return enum_for(__method__) { @header.size }
393
+ @header.each_key(&block)
394
+ end
395
+
396
+ alias each_key each_name
397
+
398
+ # Calls the block with each capitalized field name:
399
+ #
400
+ # res = Net::HTTP.get_response(hostname, '/todos/1')
401
+ # res.each_capitalized_name do |key|
402
+ # p key if key.start_with?('C')
403
+ # end
404
+ #
405
+ # Output:
406
+ #
407
+ # "Content-Type"
408
+ # "Connection"
409
+ # "Cache-Control"
410
+ # "Cf-Cache-Status"
411
+ # "Cf-Ray"
412
+ #
413
+ # The capitalization is system-dependent;
414
+ # see {Case Mapping}[https://docs.ruby-lang.org/en/master/case_mapping_rdoc.html].
415
+ #
416
+ # Returns an enumerator if no block is given.
417
+ def each_capitalized_name #:yield: +key+
418
+ block_given? or return enum_for(__method__) { @header.size }
419
+ @header.each_key do |k|
420
+ yield capitalize(k)
421
+ end
422
+ end
423
+
424
+ # Calls the block with each string field value:
425
+ #
426
+ # res = Net::HTTP.get_response(hostname, '/todos/1')
427
+ # res.each_value do |value|
428
+ # p value if value.start_with?('c')
429
+ # end
430
+ #
431
+ # Output:
432
+ #
433
+ # "chunked"
434
+ # "cf-q-config;dur=6.0000002122251e-06"
435
+ # "cloudflare"
436
+ #
437
+ # Returns an enumerator if no block is given.
438
+ def each_value #:yield: +value+
439
+ block_given? or return enum_for(__method__) { @header.size }
440
+ @header.each_value do |va|
441
+ yield va.join(', ')
442
+ end
443
+ end
444
+
445
+ # Removes the header for the given case-insensitive +key+
446
+ # (see {Fields}[rdoc-ref:Net::HTTPHeader@Fields]);
447
+ # returns the deleted value, or +nil+ if no such field exists:
448
+ #
449
+ # req = Net::HTTP::Get.new(uri)
450
+ # req.delete('Accept') # => ["*/*"]
451
+ # req.delete('Nosuch') # => nil
452
+ #
453
+ def delete(key)
454
+ @header.delete(key.downcase.to_s)
455
+ end
456
+
457
+ # Returns +true+ if the field for the case-insensitive +key+ exists, +false+ otherwise:
458
+ #
459
+ # req = Net::HTTP::Get.new(uri)
460
+ # req.key?('Accept') # => true
461
+ # req.key?('Nosuch') # => false
462
+ #
463
+ def key?(key)
464
+ @header.key?(key.downcase.to_s)
465
+ end
466
+
467
+ # Returns a hash of the key/value pairs:
468
+ #
469
+ # req = Net::HTTP::Get.new(uri)
470
+ # req.to_hash
471
+ # # =>
472
+ # {"accept-encoding"=>["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"],
473
+ # "accept"=>["*/*"],
474
+ # "user-agent"=>["Ruby"],
475
+ # "host"=>["jsonplaceholder.typicode.com"]}
476
+ #
477
+ def to_hash
478
+ @header.dup
479
+ end
480
+
481
+ # Like #each_header, but the keys are returned in capitalized form.
482
+ #
483
+ # Net::HTTPHeader#canonical_each is an alias for Net::HTTPHeader#each_capitalized.
484
+ def each_capitalized
485
+ block_given? or return enum_for(__method__) { @header.size }
486
+ @header.each do |k,v|
487
+ yield capitalize(k), v.join(', ')
488
+ end
489
+ end
490
+
491
+ alias canonical_each each_capitalized
492
+
493
+ def capitalize(name)
494
+ name.to_s.split('-'.freeze).map {|s| s.capitalize }.join('-'.freeze)
495
+ end
496
+ private :capitalize
497
+
498
+ # Returns an array of Range objects that represent
499
+ # the value of field <tt>'Range'</tt>,
500
+ # or +nil+ if there is no such field;
501
+ # see {Range request header}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#range-request-header]:
502
+ #
503
+ # req = Net::HTTP::Get.new(uri)
504
+ # req['Range'] = 'bytes=0-99,200-299,400-499'
505
+ # req.range # => [0..99, 200..299, 400..499]
506
+ # req.delete('Range')
507
+ # req.range # # => nil
508
+ #
509
+ def range
510
+ return nil unless @header['range']
511
+
512
+ value = self['Range']
513
+ # byte-range-set = *( "," OWS ) ( byte-range-spec / suffix-byte-range-spec )
514
+ # *( OWS "," [ OWS ( byte-range-spec / suffix-byte-range-spec ) ] )
515
+ # corrected collected ABNF
516
+ # http://tools.ietf.org/html/draft-ietf-httpbis-p5-range-19#section-5.4.1
517
+ # http://tools.ietf.org/html/draft-ietf-httpbis-p5-range-19#appendix-C
518
+ # http://tools.ietf.org/html/draft-ietf-httpbis-p1-messaging-19#section-3.2.5
519
+ unless /\Abytes=((?:,[ \t]*)*(?:\d+-\d*|-\d+)(?:[ \t]*,(?:[ \t]*\d+-\d*|-\d+)?)*)\z/ =~ value
520
+ raise Net::HTTPHeaderSyntaxError, "invalid syntax for byte-ranges-specifier: '#{value}'"
521
+ end
522
+
523
+ byte_range_set = $1
524
+ result = byte_range_set.split(/,/).map {|spec|
525
+ m = /(\d+)?\s*-\s*(\d+)?/i.match(spec) or
526
+ raise Net::HTTPHeaderSyntaxError, "invalid byte-range-spec: '#{spec}'"
527
+ d1 = m[1].to_i
528
+ d2 = m[2].to_i
529
+ if m[1] and m[2]
530
+ if d1 > d2
531
+ raise Net::HTTPHeaderSyntaxError, "last-byte-pos MUST greater than or equal to first-byte-pos but '#{spec}'"
532
+ end
533
+ d1..d2
534
+ elsif m[1]
535
+ d1..-1
536
+ elsif m[2]
537
+ -d2..-1
538
+ else
539
+ raise Net::HTTPHeaderSyntaxError, 'range is not specified'
540
+ end
541
+ }
542
+ # if result.empty?
543
+ # byte-range-set must include at least one byte-range-spec or suffix-byte-range-spec
544
+ # but above regexp already denies it.
545
+ if result.size == 1 && result[0].begin == 0 && result[0].end == -1
546
+ raise Net::HTTPHeaderSyntaxError, 'only one suffix-byte-range-spec with zero suffix-length'
547
+ end
548
+ result
549
+ end
550
+
551
+ # call-seq:
552
+ # set_range(length) -> length
553
+ # set_range(offset, length) -> range
554
+ # set_range(begin..length) -> range
555
+ #
556
+ # Sets the value for field <tt>'Range'</tt>;
557
+ # see {Range request header}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#range-request-header]:
558
+ #
559
+ # With argument +length+:
560
+ #
561
+ # req = Net::HTTP::Get.new(uri)
562
+ # req.set_range(100) # => 100
563
+ # req['Range'] # => "bytes=0-99"
564
+ #
565
+ # With arguments +offset+ and +length+:
566
+ #
567
+ # req.set_range(100, 100) # => 100...200
568
+ # req['Range'] # => "bytes=100-199"
569
+ #
570
+ # With argument +range+:
571
+ #
572
+ # req.set_range(100..199) # => 100..199
573
+ # req['Range'] # => "bytes=100-199"
574
+ #
575
+ # Net::HTTPHeader#range= is an alias for Net::HTTPHeader#set_range.
576
+ def set_range(r, e = nil)
577
+ unless r
578
+ @header.delete 'range'
579
+ return r
580
+ end
581
+ r = (r...r+e) if e
582
+ case r
583
+ when Numeric
584
+ n = r.to_i
585
+ rangestr = (n > 0 ? "0-#{n-1}" : "-#{-n}")
586
+ when Range
587
+ first = r.first
588
+ last = r.end
589
+ last -= 1 if r.exclude_end?
590
+ if last == -1
591
+ rangestr = (first > 0 ? "#{first}-" : "-#{-first}")
592
+ else
593
+ raise Net::HTTPHeaderSyntaxError, 'range.first is negative' if first < 0
594
+ raise Net::HTTPHeaderSyntaxError, 'range.last is negative' if last < 0
595
+ raise Net::HTTPHeaderSyntaxError, 'must be .first < .last' if first > last
596
+ rangestr = "#{first}-#{last}"
597
+ end
598
+ else
599
+ raise TypeError, 'Range/Integer is required'
600
+ end
601
+ @header['range'] = ["bytes=#{rangestr}"]
602
+ r
603
+ end
604
+
605
+ alias range= set_range
606
+
607
+ # Returns the value of field <tt>'Content-Length'</tt> as an integer,
608
+ # or +nil+ if there is no such field;
609
+ # see {Content-Length request header}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-length-request-header]:
610
+ #
611
+ # res = Net::HTTP.get_response(hostname, '/nosuch/1')
612
+ # res.content_length # => 2
613
+ # res = Net::HTTP.get_response(hostname, '/todos/1')
614
+ # res.content_length # => nil
615
+ #
616
+ def content_length
617
+ return nil unless key?('Content-Length')
618
+ len = self['Content-Length'].slice(/\d+/) or
619
+ raise Net::HTTPHeaderSyntaxError, 'wrong Content-Length format'
620
+ len.to_i
621
+ end
622
+
623
+ # Sets the value of field <tt>'Content-Length'</tt> to the given numeric;
624
+ # see {Content-Length response header}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-length-response-header]:
625
+ #
626
+ # _uri = uri.dup
627
+ # hostname = _uri.hostname # => "jsonplaceholder.typicode.com"
628
+ # _uri.path = '/posts' # => "/posts"
629
+ # req = Net::HTTP::Post.new(_uri) # => #<Net::HTTP::Post POST>
630
+ # req.body = '{"title": "foo","body": "bar","userId": 1}'
631
+ # req.content_length = req.body.size # => 42
632
+ # req.content_type = 'application/json'
633
+ # res = Net::HTTP.start(hostname) do |http|
634
+ # http.request(req)
635
+ # end # => #<Net::HTTPCreated 201 Created readbody=true>
636
+ #
637
+ def content_length=(len)
638
+ unless len
639
+ @header.delete 'content-length'
640
+ return nil
641
+ end
642
+ @header['content-length'] = [len.to_i.to_s]
643
+ end
644
+
645
+ # Returns +true+ if field <tt>'Transfer-Encoding'</tt>
646
+ # exists and has value <tt>'chunked'</tt>,
647
+ # +false+ otherwise;
648
+ # see {Transfer-Encoding response header}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#transfer-encoding-response-header]:
649
+ #
650
+ # res = Net::HTTP.get_response(hostname, '/todos/1')
651
+ # res['Transfer-Encoding'] # => "chunked"
652
+ # res.chunked? # => true
653
+ #
654
+ def chunked?
655
+ return false unless @header['transfer-encoding']
656
+ field = self['Transfer-Encoding']
657
+ (/(?:\A|[^\-\w])chunked(?![\-\w])/i =~ field) ? true : false
658
+ end
659
+
660
+ # Returns a Range object representing the value of field
661
+ # <tt>'Content-Range'</tt>, or +nil+ if no such field exists;
662
+ # see {Content-Range response header}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-range-response-header]:
663
+ #
664
+ # res = Net::HTTP.get_response(hostname, '/todos/1')
665
+ # res['Content-Range'] # => nil
666
+ # res['Content-Range'] = 'bytes 0-499/1000'
667
+ # res['Content-Range'] # => "bytes 0-499/1000"
668
+ # res.content_range # => 0..499
669
+ #
670
+ def content_range
671
+ return nil unless @header['content-range']
672
+ m = %r<\A\s*(\w+)\s+(\d+)-(\d+)/(\d+|\*)>.match(self['Content-Range']) or
673
+ raise Net::HTTPHeaderSyntaxError, 'wrong Content-Range format'
674
+ return unless m[1] == 'bytes'
675
+ m[2].to_i .. m[3].to_i
676
+ end
677
+
678
+ # Returns the integer representing length of the value of field
679
+ # <tt>'Content-Range'</tt>, or +nil+ if no such field exists;
680
+ # see {Content-Range response header}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-range-response-header]:
681
+ #
682
+ # res = Net::HTTP.get_response(hostname, '/todos/1')
683
+ # res['Content-Range'] # => nil
684
+ # res['Content-Range'] = 'bytes 0-499/1000'
685
+ # res.range_length # => 500
686
+ #
687
+ def range_length
688
+ r = content_range() or return nil
689
+ r.end - r.begin + 1
690
+ end
691
+
692
+ # Returns the {media type}[https://en.wikipedia.org/wiki/Media_type]
693
+ # from the value of field <tt>'Content-Type'</tt>,
694
+ # or +nil+ if no such field exists;
695
+ # see {Content-Type response header}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type-response-header]:
696
+ #
697
+ # res = Net::HTTP.get_response(hostname, '/todos/1')
698
+ # res['content-type'] # => "application/json; charset=utf-8"
699
+ # res.content_type # => "application/json"
700
+ #
701
+ def content_type
702
+ main = main_type()
703
+ return nil unless main
704
+
705
+ sub = sub_type()
706
+ if sub
707
+ "#{main}/#{sub}"
708
+ else
709
+ main
710
+ end
711
+ end
712
+
713
+ # Returns the leading ('type') part of the
714
+ # {media type}[https://en.wikipedia.org/wiki/Media_type]
715
+ # from the value of field <tt>'Content-Type'</tt>,
716
+ # or +nil+ if no such field exists;
717
+ # see {Content-Type response header}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type-response-header]:
718
+ #
719
+ # res = Net::HTTP.get_response(hostname, '/todos/1')
720
+ # res['content-type'] # => "application/json; charset=utf-8"
721
+ # res.main_type # => "application"
722
+ #
723
+ def main_type
724
+ return nil unless @header['content-type']
725
+ self['Content-Type'].split(';').first.to_s.split('/')[0].to_s.strip
726
+ end
727
+
728
+ # Returns the trailing ('subtype') part of the
729
+ # {media type}[https://en.wikipedia.org/wiki/Media_type]
730
+ # from the value of field <tt>'Content-Type'</tt>,
731
+ # or +nil+ if no such field exists;
732
+ # see {Content-Type response header}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type-response-header]:
733
+ #
734
+ # res = Net::HTTP.get_response(hostname, '/todos/1')
735
+ # res['content-type'] # => "application/json; charset=utf-8"
736
+ # res.sub_type # => "json"
737
+ #
738
+ def sub_type
739
+ return nil unless @header['content-type']
740
+ _, sub = *self['Content-Type'].split(';').first.to_s.split('/')
741
+ return nil unless sub
742
+ sub.strip
743
+ end
744
+
745
+ # Returns the trailing ('parameters') part of the value of field <tt>'Content-Type'</tt>,
746
+ # or +nil+ if no such field exists;
747
+ # see {Content-Type response header}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type-response-header]:
748
+ #
749
+ # res = Net::HTTP.get_response(hostname, '/todos/1')
750
+ # res['content-type'] # => "application/json; charset=utf-8"
751
+ # res.type_params # => {"charset"=>"utf-8"}
752
+ #
753
+ def type_params
754
+ result = {}
755
+ list = self['Content-Type'].to_s.split(';')
756
+ list.shift
757
+ list.each do |param|
758
+ k, v = *param.split('=', 2)
759
+ result[k.strip] = v.strip
760
+ end
761
+ result
762
+ end
763
+
764
+ # Sets the value of field <tt>'Content-Type'</tt>;
765
+ # returns the new value;
766
+ # see {Content-Type request header}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type-request-header]:
767
+ #
768
+ # req = Net::HTTP::Get.new(uri)
769
+ # req.set_content_type('application/json') # => ["application/json"]
770
+ #
771
+ # Net::HTTPHeader#content_type= is an alias for Net::HTTPHeader#set_content_type.
772
+ def set_content_type(type, params = {})
773
+ @header['content-type'] = [type + params.map{|k,v|"; #{k}=#{v}"}.join('')]
774
+ end
775
+
776
+ alias content_type= set_content_type
777
+
778
+ # Sets the request body to a URL-encoded string derived from argument +params+,
779
+ # and sets request header field <tt>'Content-Type'</tt>
780
+ # to <tt>'application/x-www-form-urlencoded'</tt>.
781
+ #
782
+ # The resulting request is suitable for HTTP request +POST+ or +PUT+.
783
+ #
784
+ # Argument +params+ must be suitable for use as argument +enum+ to
785
+ # {URI.encode_www_form}[https://docs.ruby-lang.org/en/master/URI.html#method-c-encode_www_form].
786
+ #
787
+ # With only argument +params+ given,
788
+ # sets the body to a URL-encoded string with the default separator <tt>'&'</tt>:
789
+ #
790
+ # req = Net::HTTP::Post.new('example.com')
791
+ #
792
+ # req.set_form_data(q: 'ruby', lang: 'en')
793
+ # req.body # => "q=ruby&lang=en"
794
+ # req['Content-Type'] # => "application/x-www-form-urlencoded"
795
+ #
796
+ # req.set_form_data([['q', 'ruby'], ['lang', 'en']])
797
+ # req.body # => "q=ruby&lang=en"
798
+ #
799
+ # req.set_form_data(q: ['ruby', 'perl'], lang: 'en')
800
+ # req.body # => "q=ruby&q=perl&lang=en"
801
+ #
802
+ # req.set_form_data([['q', 'ruby'], ['q', 'perl'], ['lang', 'en']])
803
+ # req.body # => "q=ruby&q=perl&lang=en"
804
+ #
805
+ # With string argument +sep+ also given,
806
+ # uses that string as the separator:
807
+ #
808
+ # req.set_form_data({q: 'ruby', lang: 'en'}, '|')
809
+ # req.body # => "q=ruby|lang=en"
810
+ #
811
+ # Net::HTTPHeader#form_data= is an alias for Net::HTTPHeader#set_form_data.
812
+ def set_form_data(params, sep = '&')
813
+ query = URI.encode_www_form(params)
814
+ query.gsub!(/&/, sep) if sep != '&'
815
+ self.body = query
816
+ self.content_type = 'application/x-www-form-urlencoded'
817
+ end
818
+
819
+ alias form_data= set_form_data
820
+
821
+ # Stores form data to be used in a +POST+ or +PUT+ request.
822
+ #
823
+ # The form data given in +params+ consists of zero or more fields;
824
+ # each field is:
825
+ #
826
+ # - A scalar value.
827
+ # - A name/value pair.
828
+ # - An IO stream opened for reading.
829
+ #
830
+ # Argument +params+ should be an
831
+ # {Enumerable}[https://docs.ruby-lang.org/en/master/Enumerable.html#module-Enumerable-label-Enumerable+in+Ruby+Classes]
832
+ # (method <tt>params.map</tt> will be called),
833
+ # and is often an array or hash.
834
+ #
835
+ # First, we set up a request:
836
+ #
837
+ # _uri = uri.dup
838
+ # _uri.path ='/posts'
839
+ # req = Net::HTTP::Post.new(_uri)
840
+ #
841
+ # <b>Argument +params+ As an Array</b>
842
+ #
843
+ # When +params+ is an array,
844
+ # each of its elements is a subarray that defines a field;
845
+ # the subarray may contain:
846
+ #
847
+ # - One string:
848
+ #
849
+ # req.set_form([['foo'], ['bar'], ['baz']])
850
+ #
851
+ # - Two strings:
852
+ #
853
+ # req.set_form([%w[foo 0], %w[bar 1], %w[baz 2]])
854
+ #
855
+ # - When argument +enctype+ (see below) is given as
856
+ # <tt>'multipart/form-data'</tt>:
857
+ #
858
+ # - A string name and an IO stream opened for reading:
859
+ #
860
+ # require 'stringio'
861
+ # req.set_form([['file', StringIO.new('Ruby is cool.')]])
862
+ #
863
+ # - A string name, an IO stream opened for reading,
864
+ # and an options hash, which may contain these entries:
865
+ #
866
+ # - +:filename+: The name of the file to use.
867
+ # - +:content_type+: The content type of the uploaded file.
868
+ #
869
+ # Example:
870
+ #
871
+ # req.set_form([['file', file, {filename: "other-filename.foo"}]]
872
+ #
873
+ # The various forms may be mixed:
874
+ #
875
+ # req.set_form(['foo', %w[bar 1], ['file', file]])
876
+ #
877
+ # <b>Argument +params+ As a Hash</b>
878
+ #
879
+ # When +params+ is a hash,
880
+ # each of its entries is a name/value pair that defines a field:
881
+ #
882
+ # - The name is a string.
883
+ # - The value may be:
884
+ #
885
+ # - +nil+.
886
+ # - Another string.
887
+ # - An IO stream opened for reading
888
+ # (only when argument +enctype+ -- see below -- is given as
889
+ # <tt>'multipart/form-data'</tt>).
890
+ #
891
+ # Examples:
892
+ #
893
+ # # Nil-valued fields.
894
+ # req.set_form({'foo' => nil, 'bar' => nil, 'baz' => nil})
895
+ #
896
+ # # String-valued fields.
897
+ # req.set_form({'foo' => 0, 'bar' => 1, 'baz' => 2})
898
+ #
899
+ # # IO-valued field.
900
+ # require 'stringio'
901
+ # req.set_form({'file' => StringIO.new('Ruby is cool.')})
902
+ #
903
+ # # Mixture of fields.
904
+ # req.set_form({'foo' => nil, 'bar' => 1, 'file' => file})
905
+ #
906
+ # Optional argument +enctype+ specifies the value to be given
907
+ # to field <tt>'Content-Type'</tt>, and must be one of:
908
+ #
909
+ # - <tt>'application/x-www-form-urlencoded'</tt> (the default).
910
+ # - <tt>'multipart/form-data'</tt>;
911
+ # see {RFC 7578}[https://www.rfc-editor.org/rfc/rfc7578].
912
+ #
913
+ # Optional argument +formopt+ is a hash of options
914
+ # (applicable only when argument +enctype+
915
+ # is <tt>'multipart/form-data'</tt>)
916
+ # that may include the following entries:
917
+ #
918
+ # - +:boundary+: The value is the boundary string for the multipart message.
919
+ # If not given, the boundary is a random string.
920
+ # See {Boundary}[https://www.rfc-editor.org/rfc/rfc7578#section-4.1].
921
+ # - +:charset+: Value is the character set for the form submission.
922
+ # Field names and values of non-file fields should be encoded with this charset.
923
+ #
924
+ def set_form(params, enctype='application/x-www-form-urlencoded', formopt={})
925
+ @body_data = params
926
+ @body = nil
927
+ @body_stream = nil
928
+ @form_option = formopt
929
+ case enctype
930
+ when /\Aapplication\/x-www-form-urlencoded\z/i,
931
+ /\Amultipart\/form-data\z/i
932
+ self.content_type = enctype
933
+ else
934
+ raise ArgumentError, "invalid enctype: #{enctype}"
935
+ end
936
+ end
937
+
938
+ # Sets header <tt>'Authorization'</tt> using the given
939
+ # +account+ and +password+ strings:
940
+ #
941
+ # req.basic_auth('my_account', 'my_password')
942
+ # req['Authorization']
943
+ # # => "Basic bXlfYWNjb3VudDpteV9wYXNzd29yZA=="
944
+ #
945
+ def basic_auth(account, password)
946
+ @header['authorization'] = [basic_encode(account, password)]
947
+ end
948
+
949
+ # Sets header <tt>'Proxy-Authorization'</tt> using the given
950
+ # +account+ and +password+ strings:
951
+ #
952
+ # req.proxy_basic_auth('my_account', 'my_password')
953
+ # req['Proxy-Authorization']
954
+ # # => "Basic bXlfYWNjb3VudDpteV9wYXNzd29yZA=="
955
+ #
956
+ def proxy_basic_auth(account, password)
957
+ @header['proxy-authorization'] = [basic_encode(account, password)]
958
+ end
959
+
960
+ def basic_encode(account, password)
961
+ 'Basic ' + ["#{account}:#{password}"].pack('m0')
962
+ end
963
+ private :basic_encode
964
+
965
+ # Returns whether the HTTP session is to be closed.
966
+ def connection_close?
967
+ token = /(?:\A|,)\s*close\s*(?:\z|,)/i
968
+ @header['connection']&.grep(token) {return true}
969
+ @header['proxy-connection']&.grep(token) {return true}
970
+ false
971
+ end
972
+
973
+ # Returns whether the HTTP session is to be kept alive.
974
+ def connection_keep_alive?
975
+ token = /(?:\A|,)\s*keep-alive\s*(?:\z|,)/i
976
+ @header['connection']&.grep(token) {return true}
977
+ @header['proxy-connection']&.grep(token) {return true}
978
+ false
979
+ end
980
+
981
+ end