pingram 1.0.40 → 1.0.41
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +5 -5
- data/lib/pingram/api/account_api.rb +191 -4
- data/lib/pingram/api/webhooks_api.rb +6 -6
- data/lib/pingram/api_client.rb +1 -1
- data/lib/pingram/models/account_get_response_billing_alerts.rb +1 -1
- data/lib/pingram/models/account_payment_methods.rb +214 -0
- data/lib/pingram/models/account_payment_methods_payment_methods_inner.rb +270 -0
- data/lib/pingram/models/assign_payment_method_request.rb +216 -0
- data/lib/pingram/models/billing_post_response_body.rb +1 -1
- data/lib/pingram/models/confirm_change_email_request.rb +14 -4
- data/lib/pingram/models/confirm_change_email_response.rb +192 -0
- data/lib/pingram/models/confirm_password_change_request.rb +191 -0
- data/lib/pingram/models/create_payment_method_setup_request.rb +191 -0
- data/lib/pingram/models/list_invoices_response_invoices_inner.rb +1 -1
- data/lib/pingram/models/logs_get_response_logs_inner.rb +10 -1
- data/lib/pingram/models/password_status_response.rb +195 -0
- data/lib/pingram/models/payment_method_setup.rb +191 -0
- data/lib/pingram/models/sign_in_username_request.rb +164 -0
- data/lib/pingram/models/sign_in_username_response.rb +165 -0
- data/lib/pingram/models/start_change_email_request.rb +13 -20
- data/lib/pingram/models/start_password_change_request.rb +185 -0
- data/lib/pingram/models/webhook_endpoint.rb +14 -5
- data/lib/pingram/models/webhook_endpoint_basic_auth.rb +193 -0
- data/lib/pingram/models/webhook_endpoint_upsert_request.rb +15 -5
- data/lib/pingram/models/webhook_endpoint_upsert_request_basic_auth.rb +176 -0
- data/lib/pingram/models/webhook_endpoints_response_endpoints_inner.rb +14 -5
- data/lib/pingram/version.rb +1 -1
- data/lib/pingram.rb +13 -0
- data/vendor/bundle/ruby/3.2.0/cache/ethon-0.19.1.gem +0 -0
- data/vendor/bundle/ruby/3.2.0/cache/io-console-0.9.5.gem +0 -0
- data/vendor/bundle/ruby/3.2.0/cache/typhoeus-1.7.1.gem +0 -0
- data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/byebug-13.0.0/gem_make.out +5 -5
- data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/date-3.6.0/gem_make.out +5 -5
- data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/{io-console-0.9.4 → io-console-0.9.5}/gem_make.out +10 -10
- data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/io-console-0.9.5/io/console.so +0 -0
- data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/{io-console-0.9.4 → io-console-0.9.5}/mkmf.log +6 -6
- data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/jaro_winkler-1.5.6/gem_make.out +5 -5
- data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/psych-5.5.0/gem_make.out +5 -5
- data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/racc-1.8.1/gem_make.out +5 -5
- data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/stringio-3.2.0/gem_make.out +5 -5
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.19.1/CHANGELOG.md +1120 -0
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.19.1/README.md +261 -0
- data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.18.0 → ethon-0.19.1}/lib/ethon/curl.rb +22 -0
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.19.1/lib/ethon/curls/classes.rb +337 -0
- data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.18.0 → ethon-0.19.1}/lib/ethon/curls/codes.rb +28 -9
- data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.18.0 → ethon-0.19.1}/lib/ethon/curls/constants.rb +61 -4
- data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.18.0 → ethon-0.19.1}/lib/ethon/curls/form_options.rb +2 -1
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.19.1/lib/ethon/curls/functions.rb +107 -0
- data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.18.0 → ethon-0.19.1}/lib/ethon/curls/infos.rb +104 -5
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.19.1/lib/ethon/curls/introspection.rb +139 -0
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.19.1/lib/ethon/curls/introspection_constants.rb +42 -0
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.19.1/lib/ethon/curls/mime.rb +187 -0
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.19.1/lib/ethon/curls/optional.rb +14 -0
- data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.18.0 → ethon-0.19.1}/lib/ethon/curls/options.rb +298 -71
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.19.1/lib/ethon/curls/settings.rb +21 -0
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.19.1/lib/ethon/curls/share.rb +165 -0
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.19.1/lib/ethon/curls/share_constants.rb +47 -0
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.19.1/lib/ethon/curls/url.rb +171 -0
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.19.1/lib/ethon/curls/url_constants.rb +78 -0
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.19.1/lib/ethon/easy/callbacks.rb +281 -0
- data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.18.0 → ethon-0.19.1}/lib/ethon/easy/features.rb +4 -1
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.19.1/lib/ethon/easy/files.rb +113 -0
- data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.18.0 → ethon-0.19.1}/lib/ethon/easy/form.rb +65 -6
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.19.1/lib/ethon/easy/header.rb +103 -0
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.19.1/lib/ethon/easy/headers_api.rb +79 -0
- data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.18.0 → ethon-0.19.1}/lib/ethon/easy/http/actionable.rb +25 -3
- data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.18.0 → ethon-0.19.1}/lib/ethon/easy/http/get.rb +5 -1
- data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.18.0 → ethon-0.19.1}/lib/ethon/easy/http/post.rb +1 -0
- data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.18.0 → ethon-0.19.1}/lib/ethon/easy/http/postable.rb +9 -2
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.19.1/lib/ethon/easy/http/putable.rb +40 -0
- data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.18.0 → ethon-0.19.1}/lib/ethon/easy/http.rb +16 -4
- data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.18.0 → ethon-0.19.1}/lib/ethon/easy/informations.rb +51 -2
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.19.1/lib/ethon/easy/mime.rb +29 -0
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.19.1/lib/ethon/easy/mirror.rb +49 -0
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.19.1/lib/ethon/easy/operations.rb +317 -0
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.19.1/lib/ethon/easy/options.rb +369 -0
- data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.18.0 → ethon-0.19.1}/lib/ethon/easy/queryable.rb +59 -14
- data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.18.0 → ethon-0.19.1}/lib/ethon/easy/response_callbacks.rb +33 -12
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.19.1/lib/ethon/easy/share.rb +28 -0
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.19.1/lib/ethon/easy/url.rb +32 -0
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.19.1/lib/ethon/easy/util.rb +47 -0
- data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.18.0 → ethon-0.19.1}/lib/ethon/easy.rb +185 -10
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.19.1/lib/ethon/errors/fork_safety.rb +10 -0
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.19.1/lib/ethon/errors/form_add.rb +12 -0
- data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.18.0 → ethon-0.19.1}/lib/ethon/errors/global_init.rb +1 -1
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.19.1/lib/ethon/errors/header.rb +12 -0
- data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.18.0 → ethon-0.19.1}/lib/ethon/errors/invalid_option.rb +3 -1
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.19.1/lib/ethon/errors/invalid_value.rb +15 -0
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.19.1/lib/ethon/errors/mime.rb +17 -0
- data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.18.0 → ethon-0.19.1}/lib/ethon/errors/multi_add.rb +1 -1
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.19.1/lib/ethon/errors/multi_assign.rb +12 -0
- data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.18.0 → ethon-0.19.1}/lib/ethon/errors/multi_fdset.rb +1 -1
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.19.1/lib/ethon/errors/multi_perform.rb +12 -0
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.19.1/lib/ethon/errors/multi_poll.rb +12 -0
- data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.18.0 → ethon-0.19.1}/lib/ethon/errors/multi_remove.rb +1 -1
- data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.18.0 → ethon-0.19.1}/lib/ethon/errors/multi_timeout.rb +2 -2
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.19.1/lib/ethon/errors/multi_wait.rb +12 -0
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.19.1/lib/ethon/errors/multi_wakeup.rb +12 -0
- data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.18.0 → ethon-0.19.1}/lib/ethon/errors/select.rb +1 -1
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.19.1/lib/ethon/errors/set_option.rb +27 -0
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.19.1/lib/ethon/errors/share.rb +17 -0
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.19.1/lib/ethon/errors/unsupported_option.rb +23 -0
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.19.1/lib/ethon/errors/url.rb +17 -0
- data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.18.0 → ethon-0.19.1}/lib/ethon/errors.rb +13 -0
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.19.1/lib/ethon/libc.rb +50 -0
- data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.18.0 → ethon-0.19.1}/lib/ethon/loggable.rb +1 -1
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.19.1/lib/ethon/multi/operations.rb +472 -0
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.19.1/lib/ethon/multi/options.rb +219 -0
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.19.1/lib/ethon/multi/stack.rb +220 -0
- data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.18.0 → ethon-0.19.1}/lib/ethon/multi.rb +51 -15
- data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.18.0 → ethon-0.19.1}/lib/ethon/version.rb +1 -1
- data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.18.0 → ethon-0.19.1}/lib/ethon.rb +8 -9
- data/vendor/bundle/ruby/3.2.0/gems/{io-console-0.9.4 → io-console-0.9.5}/ext/io/console/console.c +8 -3
- data/vendor/bundle/ruby/3.2.0/gems/{io-console-0.9.4 → io-console-0.9.5}/ext/io/console/extconf.rb +7 -3
- data/vendor/bundle/ruby/3.2.0/gems/io-console-0.9.5/lib/io/console.so +0 -0
- data/vendor/bundle/ruby/3.2.0/gems/{typhoeus-1.6.0 → typhoeus-1.7.1}/CHANGELOG.md +228 -1
- data/vendor/bundle/ruby/3.2.0/gems/typhoeus-1.7.1/README.md +766 -0
- data/vendor/bundle/ruby/3.2.0/gems/{typhoeus-1.6.0 → typhoeus-1.7.1}/UPGRADE.md +29 -0
- data/vendor/bundle/ruby/3.2.0/gems/typhoeus-1.7.1/lib/rack/typhoeus/middleware/params_decoder/helper.rb +129 -0
- data/vendor/bundle/ruby/3.2.0/gems/{typhoeus-1.6.0 → typhoeus-1.7.1}/lib/rack/typhoeus/middleware/params_decoder.rb +8 -19
- data/vendor/bundle/ruby/3.2.0/gems/{typhoeus-1.6.0 → typhoeus-1.7.1}/lib/rack/typhoeus.rb +2 -0
- data/vendor/bundle/ruby/3.2.0/gems/{typhoeus-1.6.0 → typhoeus-1.7.1}/lib/typhoeus/adapters/faraday.rb +89 -28
- data/vendor/bundle/ruby/3.2.0/gems/{typhoeus-1.6.0 → typhoeus-1.7.1}/lib/typhoeus/cache/dalli.rb +2 -0
- data/vendor/bundle/ruby/3.2.0/gems/{typhoeus-1.6.0 → typhoeus-1.7.1}/lib/typhoeus/cache/rails.rb +3 -1
- data/vendor/bundle/ruby/3.2.0/gems/{typhoeus-1.6.0 → typhoeus-1.7.1}/lib/typhoeus/cache/redis.rb +2 -0
- data/vendor/bundle/ruby/3.2.0/gems/{typhoeus-1.6.0 → typhoeus-1.7.1}/lib/typhoeus/config.rb +51 -7
- data/vendor/bundle/ruby/3.2.0/gems/{typhoeus-1.6.0 → typhoeus-1.7.1}/lib/typhoeus/easy_factory.rb +129 -23
- data/vendor/bundle/ruby/3.2.0/gems/typhoeus-1.7.1/lib/typhoeus/errors/invalid_option.rb +23 -0
- data/vendor/bundle/ruby/3.2.0/gems/typhoeus-1.7.1/lib/typhoeus/errors/no_response.rb +18 -0
- data/vendor/bundle/ruby/3.2.0/gems/{typhoeus-1.6.0 → typhoeus-1.7.1}/lib/typhoeus/errors/no_stub.rb +8 -1
- data/vendor/bundle/ruby/3.2.0/gems/{typhoeus-1.6.0 → typhoeus-1.7.1}/lib/typhoeus/errors/typhoeus_error.rb +2 -0
- data/vendor/bundle/ruby/3.2.0/gems/{typhoeus-1.6.0 → typhoeus-1.7.1}/lib/typhoeus/errors.rb +4 -0
- data/vendor/bundle/ruby/3.2.0/gems/{typhoeus-1.6.0 → typhoeus-1.7.1}/lib/typhoeus/expectation.rb +33 -1
- data/vendor/bundle/ruby/3.2.0/gems/{typhoeus-1.6.0 → typhoeus-1.7.1}/lib/typhoeus/hydra/queueable.rb +29 -4
- data/vendor/bundle/ruby/3.2.0/gems/typhoeus-1.7.1/lib/typhoeus/hydra.rb +423 -0
- data/vendor/bundle/ruby/3.2.0/gems/typhoeus-1.7.1/lib/typhoeus/pool.rb +133 -0
- data/vendor/bundle/ruby/3.2.0/gems/{typhoeus-1.6.0 → typhoeus-1.7.1}/lib/typhoeus/railtie.rb +4 -2
- data/vendor/bundle/ruby/3.2.0/gems/{typhoeus-1.6.0 → typhoeus-1.7.1}/lib/typhoeus/request/actions.rb +2 -0
- data/vendor/bundle/ruby/3.2.0/gems/{typhoeus-1.6.0 → typhoeus-1.7.1}/lib/typhoeus/request/callbacks.rb +11 -4
- data/vendor/bundle/ruby/3.2.0/gems/{typhoeus-1.6.0 → typhoeus-1.7.1}/lib/typhoeus/request/marshal.rb +5 -2
- data/vendor/bundle/ruby/3.2.0/gems/{typhoeus-1.6.0 → typhoeus-1.7.1}/lib/typhoeus/request/streamable.rb +2 -0
- data/vendor/bundle/ruby/3.2.0/gems/typhoeus-1.7.1/lib/typhoeus/request.rb +510 -0
- data/vendor/bundle/ruby/3.2.0/gems/{typhoeus-1.6.0 → typhoeus-1.7.1}/lib/typhoeus/response/cacheable.rb +2 -0
- data/vendor/bundle/ruby/3.2.0/gems/typhoeus-1.7.1/lib/typhoeus/response/header.rb +325 -0
- data/vendor/bundle/ruby/3.2.0/gems/{typhoeus-1.6.0 → typhoeus-1.7.1}/lib/typhoeus/response/informations.rb +75 -12
- data/vendor/bundle/ruby/3.2.0/gems/{typhoeus-1.6.0 → typhoeus-1.7.1}/lib/typhoeus/response/status.rb +4 -13
- data/vendor/bundle/ruby/3.2.0/gems/{typhoeus-1.6.0 → typhoeus-1.7.1}/lib/typhoeus/response.rb +35 -0
- data/vendor/bundle/ruby/3.2.0/gems/{typhoeus-1.6.0 → typhoeus-1.7.1}/lib/typhoeus/version.rb +3 -1
- data/vendor/bundle/ruby/3.2.0/gems/typhoeus-1.7.1/lib/typhoeus.rb +206 -0
- data/vendor/bundle/ruby/3.2.0/gems/{typhoeus-1.6.0 → typhoeus-1.7.1}/typhoeus.gemspec +15 -3
- data/vendor/bundle/ruby/3.2.0/specifications/{ethon-0.18.0.gemspec → ethon-0.19.1.gemspec} +4 -4
- data/vendor/bundle/ruby/3.2.0/specifications/{io-console-0.9.4.gemspec → io-console-0.9.5.gemspec} +3 -3
- data/vendor/bundle/ruby/3.2.0/specifications/{typhoeus-1.6.0.gemspec → typhoeus-1.7.1.gemspec} +5 -5
- metadata +156 -129
- data/vendor/bundle/ruby/3.2.0/cache/ethon-0.18.0.gem +0 -0
- data/vendor/bundle/ruby/3.2.0/cache/io-console-0.9.4.gem +0 -0
- data/vendor/bundle/ruby/3.2.0/cache/typhoeus-1.6.0.gem +0 -0
- data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/io-console-0.9.4/io/console.so +0 -0
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.18.0/CHANGELOG.md +0 -417
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.18.0/README.md +0 -118
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.18.0/lib/ethon/curls/classes.rb +0 -65
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.18.0/lib/ethon/curls/functions.rb +0 -58
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.18.0/lib/ethon/curls/settings.rb +0 -12
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.18.0/lib/ethon/easy/callbacks.rb +0 -155
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.18.0/lib/ethon/easy/header.rb +0 -61
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.18.0/lib/ethon/easy/http/putable.rb +0 -25
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.18.0/lib/ethon/easy/mirror.rb +0 -36
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.18.0/lib/ethon/easy/operations.rb +0 -64
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.18.0/lib/ethon/easy/options.rb +0 -50
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.18.0/lib/ethon/easy/util.rb +0 -28
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.18.0/lib/ethon/errors/invalid_value.rb +0 -13
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.18.0/lib/ethon/libc.rb +0 -21
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.18.0/lib/ethon/multi/operations.rb +0 -228
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.18.0/lib/ethon/multi/options.rb +0 -117
- data/vendor/bundle/ruby/3.2.0/gems/ethon-0.18.0/lib/ethon/multi/stack.rb +0 -49
- data/vendor/bundle/ruby/3.2.0/gems/io-console-0.9.4/lib/io/console.so +0 -0
- data/vendor/bundle/ruby/3.2.0/gems/typhoeus-1.6.0/README.md +0 -588
- data/vendor/bundle/ruby/3.2.0/gems/typhoeus-1.6.0/lib/rack/typhoeus/middleware/params_decoder/helper.rb +0 -76
- data/vendor/bundle/ruby/3.2.0/gems/typhoeus-1.6.0/lib/typhoeus/hydra/addable.rb +0 -23
- data/vendor/bundle/ruby/3.2.0/gems/typhoeus-1.6.0/lib/typhoeus/hydra/before.rb +0 -31
- data/vendor/bundle/ruby/3.2.0/gems/typhoeus-1.6.0/lib/typhoeus/hydra/block_connection.rb +0 -35
- data/vendor/bundle/ruby/3.2.0/gems/typhoeus-1.6.0/lib/typhoeus/hydra/cacheable.rb +0 -15
- data/vendor/bundle/ruby/3.2.0/gems/typhoeus-1.6.0/lib/typhoeus/hydra/memoizable.rb +0 -56
- data/vendor/bundle/ruby/3.2.0/gems/typhoeus-1.6.0/lib/typhoeus/hydra/runnable.rb +0 -19
- data/vendor/bundle/ruby/3.2.0/gems/typhoeus-1.6.0/lib/typhoeus/hydra/stubbable.rb +0 -28
- data/vendor/bundle/ruby/3.2.0/gems/typhoeus-1.6.0/lib/typhoeus/hydra.rb +0 -95
- data/vendor/bundle/ruby/3.2.0/gems/typhoeus-1.6.0/lib/typhoeus/pool.rb +0 -70
- data/vendor/bundle/ruby/3.2.0/gems/typhoeus-1.6.0/lib/typhoeus/request/before.rb +0 -30
- data/vendor/bundle/ruby/3.2.0/gems/typhoeus-1.6.0/lib/typhoeus/request/block_connection.rb +0 -52
- data/vendor/bundle/ruby/3.2.0/gems/typhoeus-1.6.0/lib/typhoeus/request/cacheable.rb +0 -38
- data/vendor/bundle/ruby/3.2.0/gems/typhoeus-1.6.0/lib/typhoeus/request/memoizable.rb +0 -38
- data/vendor/bundle/ruby/3.2.0/gems/typhoeus-1.6.0/lib/typhoeus/request/operations.rb +0 -40
- data/vendor/bundle/ruby/3.2.0/gems/typhoeus-1.6.0/lib/typhoeus/request/responseable.rb +0 -29
- data/vendor/bundle/ruby/3.2.0/gems/typhoeus-1.6.0/lib/typhoeus/request/stubbable.rb +0 -30
- data/vendor/bundle/ruby/3.2.0/gems/typhoeus-1.6.0/lib/typhoeus/request.rb +0 -223
- data/vendor/bundle/ruby/3.2.0/gems/typhoeus-1.6.0/lib/typhoeus/response/header.rb +0 -105
- data/vendor/bundle/ruby/3.2.0/gems/typhoeus-1.6.0/lib/typhoeus.rb +0 -143
- /data/vendor/bundle/ruby/3.2.0/extensions/x86_64-linux/3.2.0/{io-console-0.9.4 → io-console-0.9.5}/gem.build_complete +0 -0
- /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.18.0 → ethon-0.19.1}/LICENSE +0 -0
- /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.18.0 → ethon-0.19.1}/ethon.gemspec +0 -0
- /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.18.0 → ethon-0.19.1}/lib/ethon/curls/messages.rb +0 -0
- /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.18.0 → ethon-0.19.1}/lib/ethon/easy/debug_info.rb +0 -0
- /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.18.0 → ethon-0.19.1}/lib/ethon/easy/http/custom.rb +0 -0
- /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.18.0 → ethon-0.19.1}/lib/ethon/easy/http/delete.rb +0 -0
- /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.18.0 → ethon-0.19.1}/lib/ethon/easy/http/head.rb +0 -0
- /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.18.0 → ethon-0.19.1}/lib/ethon/easy/http/options.rb +0 -0
- /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.18.0 → ethon-0.19.1}/lib/ethon/easy/http/patch.rb +0 -0
- /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.18.0 → ethon-0.19.1}/lib/ethon/easy/http/put.rb +0 -0
- /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.18.0 → ethon-0.19.1}/lib/ethon/easy/params.rb +0 -0
- /data/vendor/bundle/ruby/3.2.0/gems/{ethon-0.18.0 → ethon-0.19.1}/lib/ethon/errors/ethon_error.rb +0 -0
- /data/vendor/bundle/ruby/3.2.0/gems/{io-console-0.9.4 → io-console-0.9.5}/.document +0 -0
- /data/vendor/bundle/ruby/3.2.0/gems/{io-console-0.9.4 → io-console-0.9.5}/BSDL +0 -0
- /data/vendor/bundle/ruby/3.2.0/gems/{io-console-0.9.4 → io-console-0.9.5}/COPYING +0 -0
- /data/vendor/bundle/ruby/3.2.0/gems/{io-console-0.9.4 → io-console-0.9.5}/README.md +0 -0
- /data/vendor/bundle/ruby/3.2.0/gems/{io-console-0.9.4 → io-console-0.9.5}/ext/io/console/Makefile +0 -0
- /data/vendor/bundle/ruby/3.2.0/gems/{io-console-0.9.4 → io-console-0.9.5}/ext/io/console/win32_vk.inc +0 -0
- /data/vendor/bundle/ruby/3.2.0/gems/{io-console-0.9.4 → io-console-0.9.5}/lib/io/console/size.rb +0 -0
- /data/vendor/bundle/ruby/3.2.0/gems/{typhoeus-1.6.0 → typhoeus-1.7.1}/CONTRIBUTING.md +0 -0
- /data/vendor/bundle/ruby/3.2.0/gems/{typhoeus-1.6.0 → typhoeus-1.7.1}/LICENSE +0 -0
|
@@ -0,0 +1,510 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'zlib'
|
|
4
|
+
require 'digest/sha1'
|
|
5
|
+
require 'typhoeus/request/actions'
|
|
6
|
+
require 'typhoeus/request/callbacks'
|
|
7
|
+
require 'typhoeus/request/marshal'
|
|
8
|
+
require 'typhoeus/request/streamable'
|
|
9
|
+
|
|
10
|
+
module Typhoeus
|
|
11
|
+
|
|
12
|
+
# This class represents a request.
|
|
13
|
+
#
|
|
14
|
+
# @example (see #initialize)
|
|
15
|
+
#
|
|
16
|
+
# @example Make a request with the shortcut.
|
|
17
|
+
# response = Typhoeus.get("www.example.com")
|
|
18
|
+
#
|
|
19
|
+
# @see (see #initialize)
|
|
20
|
+
class Request
|
|
21
|
+
extend Request::Actions
|
|
22
|
+
include Request::Callbacks::Types
|
|
23
|
+
include Request::Callbacks
|
|
24
|
+
include Request::Streamable
|
|
25
|
+
include Request::Marshal
|
|
26
|
+
|
|
27
|
+
# Returns the provided base url.
|
|
28
|
+
#
|
|
29
|
+
# @return [ String ]
|
|
30
|
+
attr_accessor :base_url
|
|
31
|
+
|
|
32
|
+
# Returns options, which includes default parameters.
|
|
33
|
+
#
|
|
34
|
+
# @return [ Hash ]
|
|
35
|
+
attr_accessor :options
|
|
36
|
+
|
|
37
|
+
# Returns the hydra in which the request ran, if any.
|
|
38
|
+
#
|
|
39
|
+
# @return [ Typhoeus::Hydra ]
|
|
40
|
+
#
|
|
41
|
+
# @api private
|
|
42
|
+
attr_accessor :hydra
|
|
43
|
+
|
|
44
|
+
# Returns the original options provided.
|
|
45
|
+
#
|
|
46
|
+
# @return [ Hash ]
|
|
47
|
+
#
|
|
48
|
+
# @api private
|
|
49
|
+
attr_accessor :original_options
|
|
50
|
+
|
|
51
|
+
# @return [ Boolean ]
|
|
52
|
+
#
|
|
53
|
+
# @api private
|
|
54
|
+
attr_accessor :block_connection
|
|
55
|
+
|
|
56
|
+
# Creates a new request.
|
|
57
|
+
#
|
|
58
|
+
# @example Simplest request.
|
|
59
|
+
# response = Typhoeus::Request.new("www.example.com").run
|
|
60
|
+
#
|
|
61
|
+
# @example Request with url parameters.
|
|
62
|
+
# response = Typhoeus::Request.new(
|
|
63
|
+
# "www.example.com",
|
|
64
|
+
# params: {a: 1}
|
|
65
|
+
# ).run
|
|
66
|
+
#
|
|
67
|
+
# @example Request with a body.
|
|
68
|
+
# response = Typhoeus::Request.new(
|
|
69
|
+
# "www.example.com",
|
|
70
|
+
# body: {b: 2}
|
|
71
|
+
# ).run
|
|
72
|
+
#
|
|
73
|
+
# @example Request with parameters and body.
|
|
74
|
+
# response = Typhoeus::Request.new(
|
|
75
|
+
# "www.example.com",
|
|
76
|
+
# params: {a: 1},
|
|
77
|
+
# body: {b: 2}
|
|
78
|
+
# ).run
|
|
79
|
+
#
|
|
80
|
+
# @example Create a request and allow follow redirections.
|
|
81
|
+
# response = Typhoeus::Request.new(
|
|
82
|
+
# "www.example.com",
|
|
83
|
+
# followlocation: true
|
|
84
|
+
# ).run
|
|
85
|
+
#
|
|
86
|
+
# @param [ String ] base_url The url to request.
|
|
87
|
+
# @param [ options ] options The options.
|
|
88
|
+
#
|
|
89
|
+
# @option options [ Hash ] :params Translated
|
|
90
|
+
# into url parameters.
|
|
91
|
+
# @option options [ Hash ] :body Translated
|
|
92
|
+
# into HTTP POST request body.
|
|
93
|
+
#
|
|
94
|
+
# @return [ Typhoeus::Request ] The request.
|
|
95
|
+
#
|
|
96
|
+
# @note See {http://rubydoc.info/github/typhoeus/ethon/Ethon/Easy/Options Ethon::Easy::Options} for more options.
|
|
97
|
+
#
|
|
98
|
+
# @see Typhoeus::Hydra
|
|
99
|
+
# @see Typhoeus::Response
|
|
100
|
+
# @see Typhoeus::Request::Actions
|
|
101
|
+
def initialize(base_url, options = {})
|
|
102
|
+
@base_url = base_url
|
|
103
|
+
@original_options = options
|
|
104
|
+
@options = options.dup
|
|
105
|
+
|
|
106
|
+
set_defaults
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# Run the request.
|
|
110
|
+
#
|
|
111
|
+
# The before, stub, block connection, and cache checks run here explicitly
|
|
112
|
+
# instead of relying on the order of included modules.
|
|
113
|
+
#
|
|
114
|
+
# @example Make a request.
|
|
115
|
+
# Typhoeus::Request.new("www.example.com").run
|
|
116
|
+
#
|
|
117
|
+
# @return [ Response ] The response.
|
|
118
|
+
def run
|
|
119
|
+
callbacks = Typhoeus.before_callbacks_for(self)
|
|
120
|
+
if callbacks
|
|
121
|
+
callbacks.each do |callback|
|
|
122
|
+
value = callback.call(self)
|
|
123
|
+
if value.is_a?(Response)
|
|
124
|
+
unless response
|
|
125
|
+
# A synthetic response is a short circuit like a stub. Mark it
|
|
126
|
+
# so success? works and it is not written to the cache.
|
|
127
|
+
value.mock = true
|
|
128
|
+
execute_headers_callbacks(value)
|
|
129
|
+
on_body.each { |body_callback| body_callback.call(value.body, value) }
|
|
130
|
+
finish(value)
|
|
131
|
+
end
|
|
132
|
+
return value
|
|
133
|
+
end
|
|
134
|
+
return response if value.nil? || value == false
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
unless Typhoeus.stubs_disabled?
|
|
139
|
+
if stub_response = Expectation.response_for(self)
|
|
140
|
+
# The stub block already ran this request for real.
|
|
141
|
+
return stub_response if stub_response.request.equal?(self)
|
|
142
|
+
|
|
143
|
+
execute_headers_callbacks(stub_response)
|
|
144
|
+
on_body.each { |callback| callback.call(stub_response.body, stub_response) }
|
|
145
|
+
return finish(stub_response)
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
raise Typhoeus::Errors::NoStub.new(self) if blocked?
|
|
150
|
+
|
|
151
|
+
if cached = cached_response
|
|
152
|
+
return finish_cached_response(cached)
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
perform
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
# Add a callback that runs before the request.
|
|
159
|
+
#
|
|
160
|
+
# @example Add a callback.
|
|
161
|
+
# request.before { |request| request.options[:timeout] = 5 }
|
|
162
|
+
#
|
|
163
|
+
# @param [ Proc ] block The callback to run.
|
|
164
|
+
#
|
|
165
|
+
# @yield [ Typhoeus::Request ]
|
|
166
|
+
#
|
|
167
|
+
# @return [ Array<Proc> ] The callbacks.
|
|
168
|
+
def before(&block)
|
|
169
|
+
@before ||= []
|
|
170
|
+
@before << block if block_given?
|
|
171
|
+
@before
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
# Returns whether a request is blocked. Takes request.block_connection and
|
|
175
|
+
# the connection state of the current thread into consideration.
|
|
176
|
+
#
|
|
177
|
+
# @example Blocked?
|
|
178
|
+
# request.blocked?
|
|
179
|
+
#
|
|
180
|
+
# @return [ Boolean ] True if blocked, false else.
|
|
181
|
+
def blocked?
|
|
182
|
+
if block_connection.nil?
|
|
183
|
+
Typhoeus.connection_blocked?
|
|
184
|
+
else
|
|
185
|
+
block_connection
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
# Return whether a request is memoizable.
|
|
190
|
+
#
|
|
191
|
+
# Streaming requests are not memoized because their body is not retained
|
|
192
|
+
# and every caller has to receive its own chunks.
|
|
193
|
+
#
|
|
194
|
+
# @example Is request memoizable?
|
|
195
|
+
# request.memoizable?
|
|
196
|
+
#
|
|
197
|
+
# @return [ Boolean ] Return true if memoizable, false else.
|
|
198
|
+
def memoizable?
|
|
199
|
+
Typhoeus::Config.memoize &&
|
|
200
|
+
!streaming? &&
|
|
201
|
+
request_method == :get
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
# Return whether a request is cacheable.
|
|
205
|
+
#
|
|
206
|
+
# @return [ Boolean ]
|
|
207
|
+
def cacheable?
|
|
208
|
+
cache
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
# Return the cached response for the request, if there is one.
|
|
212
|
+
#
|
|
213
|
+
# @return [ Typhoeus::Response, nil ]
|
|
214
|
+
#
|
|
215
|
+
# @api private
|
|
216
|
+
def cached_response
|
|
217
|
+
cacheable? && cache.get(self)
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
# Finish a response that came from the cache and deliver it through the
|
|
221
|
+
# same callbacks a stubbed response uses.
|
|
222
|
+
#
|
|
223
|
+
# @param [ Typhoeus::Response ] response The cached response.
|
|
224
|
+
#
|
|
225
|
+
# @return [ Typhoeus::Response ] The response.
|
|
226
|
+
#
|
|
227
|
+
# @api private
|
|
228
|
+
def finish_cached_response(response)
|
|
229
|
+
copy = response.dup
|
|
230
|
+
copy.cached = true
|
|
231
|
+
copy.request = self
|
|
232
|
+
execute_headers_callbacks(copy)
|
|
233
|
+
on_body.each { |callback| callback.call(copy.body, copy) }
|
|
234
|
+
finish(copy)
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
# Return the cache TTL for the request.
|
|
238
|
+
#
|
|
239
|
+
# @return [ Integer, nil ]
|
|
240
|
+
def cache_ttl
|
|
241
|
+
options[:cache_ttl]
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
# Set the response and execute the callbacks.
|
|
245
|
+
#
|
|
246
|
+
# @param [ Typhoeus::Response ] response The response.
|
|
247
|
+
# @param [ Boolean ] bypass_memoization Whether to bypass memoization.
|
|
248
|
+
#
|
|
249
|
+
# @return [ Typhoeus::Response ] The response.
|
|
250
|
+
def finish(response, bypass_memoization = nil)
|
|
251
|
+
if bypass_memoization
|
|
252
|
+
@response = response
|
|
253
|
+
else
|
|
254
|
+
self.response = response
|
|
255
|
+
end
|
|
256
|
+
self.response.request = self
|
|
257
|
+
execute_callbacks
|
|
258
|
+
response
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
# Return the response.
|
|
262
|
+
#
|
|
263
|
+
# @return [ Typhoeus::Response, nil ]
|
|
264
|
+
def response
|
|
265
|
+
@response ||= nil
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
# Set the response. Cache and memoization hooks run explicitly before the
|
|
269
|
+
# response is assigned, instead of relying on the order modules were
|
|
270
|
+
# included in.
|
|
271
|
+
#
|
|
272
|
+
# @param [ Typhoeus::Response ] value The response to set.
|
|
273
|
+
def response=(value)
|
|
274
|
+
if cacheable? && cacheable_response?(value)
|
|
275
|
+
# The request exposes this response to its callbacks and the caller.
|
|
276
|
+
# Store a snapshot so later mutation cannot change what a cache hit
|
|
277
|
+
# returns.
|
|
278
|
+
cache.set(self, value.dup)
|
|
279
|
+
end
|
|
280
|
+
# Followers receive a copy of the stored response, and the leader's
|
|
281
|
+
# callbacks must not change what they see. Store a snapshot instead of
|
|
282
|
+
# the response the leader exposes to its own callbacks.
|
|
283
|
+
hydra.memory[self] = value.dup if memoizable? && hydra
|
|
284
|
+
@response = value
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
# Return the url.
|
|
288
|
+
# In contrast to base_url which returns the value you specified, url returns
|
|
289
|
+
# the full url including the parameters.
|
|
290
|
+
#
|
|
291
|
+
# @example Get the url.
|
|
292
|
+
# request.url
|
|
293
|
+
#
|
|
294
|
+
# @since 0.5.5
|
|
295
|
+
def url
|
|
296
|
+
EasyFactory.new(self).url
|
|
297
|
+
end
|
|
298
|
+
|
|
299
|
+
# Returns whether other is equal to self.
|
|
300
|
+
#
|
|
301
|
+
# @example Are request equal?
|
|
302
|
+
# request.eql?(other_request)
|
|
303
|
+
#
|
|
304
|
+
# @param [ Object ] other The object to check.
|
|
305
|
+
#
|
|
306
|
+
# @return [ Boolean ] Returns true if equal, else false.
|
|
307
|
+
#
|
|
308
|
+
# @api private
|
|
309
|
+
def eql?(other)
|
|
310
|
+
self.class == other.class &&
|
|
311
|
+
base_url.to_s == other.base_url.to_s &&
|
|
312
|
+
fuzzy_hash_eql?(normalized_options, other.normalized_options)
|
|
313
|
+
end
|
|
314
|
+
|
|
315
|
+
# Overrides Object#hash.
|
|
316
|
+
#
|
|
317
|
+
# @return [ Integer ] The integer representing the request.
|
|
318
|
+
#
|
|
319
|
+
# @api private
|
|
320
|
+
def hash
|
|
321
|
+
Zlib.crc32 cache_key
|
|
322
|
+
end
|
|
323
|
+
|
|
324
|
+
# Returns a cache key for use with caching methods that required a string
|
|
325
|
+
# for a key. Will get used by ActiveSupport::Cache stores automatically.
|
|
326
|
+
#
|
|
327
|
+
# @return [ String ] The cache key.
|
|
328
|
+
def cache_key
|
|
329
|
+
# The cache store and the TTL only affect where and how long a response
|
|
330
|
+
# is stored, not what the response is. Leaving them in the key would
|
|
331
|
+
# silently miss the cache whenever the TTL changes.
|
|
332
|
+
hashable_options = normalized_options.tap do |dup_opts|
|
|
333
|
+
dup_opts.delete(:cache)
|
|
334
|
+
dup_opts.delete(:cache_ttl)
|
|
335
|
+
end
|
|
336
|
+
|
|
337
|
+
cache_key_components = [
|
|
338
|
+
self.class.name,
|
|
339
|
+
base_url,
|
|
340
|
+
hashable_string_for(hashable_options)
|
|
341
|
+
]
|
|
342
|
+
|
|
343
|
+
Digest::SHA1.hexdigest(cache_key_components.join)
|
|
344
|
+
end
|
|
345
|
+
|
|
346
|
+
# Mimics libcurl's POST body generation. This is not accurate, but good
|
|
347
|
+
# enough for VCR.
|
|
348
|
+
#
|
|
349
|
+
# @return [ String ] The encoded body.
|
|
350
|
+
#
|
|
351
|
+
# @api private
|
|
352
|
+
def encoded_body
|
|
353
|
+
easy = Typhoeus::Pool.get
|
|
354
|
+
begin
|
|
355
|
+
body_options = { :body => options[:body] }
|
|
356
|
+
[:params_encoding, :escape].each do |option|
|
|
357
|
+
body_options[option] = options[option] if options.key?(option)
|
|
358
|
+
end
|
|
359
|
+
|
|
360
|
+
# Let Ethon apply its escape rule for this method. The form must stay
|
|
361
|
+
# non-multipart because encoded_body returns a single string.
|
|
362
|
+
form = Ethon::Easy::Form.new(easy, options[:body])
|
|
363
|
+
form.define_singleton_method(:multipart?) { false }
|
|
364
|
+
|
|
365
|
+
action = if options.fetch(:method, :get).to_s.downcase == "put"
|
|
366
|
+
Ethon::Easy::Http::Put.new("http://localhost/", body_options)
|
|
367
|
+
else
|
|
368
|
+
Ethon::Easy::Http::Post.new("http://localhost/", body_options)
|
|
369
|
+
end
|
|
370
|
+
action.instance_variable_set(:@form, form)
|
|
371
|
+
action.setup(easy)
|
|
372
|
+
form.to_s
|
|
373
|
+
ensure
|
|
374
|
+
Typhoeus::Pool.release(easy) if easy
|
|
375
|
+
end
|
|
376
|
+
end
|
|
377
|
+
|
|
378
|
+
# Return the request method with the same defaults and spelling Ethon
|
|
379
|
+
# uses. Cache keys, memoization, and equality must not depend on whether
|
|
380
|
+
# the caller wrote :get, "GET", or omitted the default method.
|
|
381
|
+
#
|
|
382
|
+
# @return [ Symbol ] The normalized method.
|
|
383
|
+
#
|
|
384
|
+
# @api private
|
|
385
|
+
def request_method
|
|
386
|
+
(options[:method] || :get).to_s.downcase.to_sym
|
|
387
|
+
end
|
|
388
|
+
|
|
389
|
+
# Return the options with their implicit defaults filled in for comparison.
|
|
390
|
+
#
|
|
391
|
+
# @return [ Hash ] The normalized options.
|
|
392
|
+
#
|
|
393
|
+
# @api private
|
|
394
|
+
def normalized_options
|
|
395
|
+
normalized = options.merge(:method => request_method)
|
|
396
|
+
normalized.delete("method")
|
|
397
|
+
# GET is the default. Leaving it out keeps the cache key of an implicit
|
|
398
|
+
# GET stable across the normalization change.
|
|
399
|
+
normalized.delete(:method) if normalized[:method] == :get
|
|
400
|
+
normalized
|
|
401
|
+
end
|
|
402
|
+
|
|
403
|
+
private
|
|
404
|
+
|
|
405
|
+
# Perform the actual request.
|
|
406
|
+
#
|
|
407
|
+
# @return [ Typhoeus::Response ] The response.
|
|
408
|
+
def perform
|
|
409
|
+
easy_factory = EasyFactory.new(self)
|
|
410
|
+
easy = easy_factory.get
|
|
411
|
+
begin
|
|
412
|
+
easy.perform
|
|
413
|
+
rescue Exception
|
|
414
|
+
easy_factory.release_easy(easy) unless easy_factory.released?
|
|
415
|
+
raise
|
|
416
|
+
end
|
|
417
|
+
response
|
|
418
|
+
end
|
|
419
|
+
|
|
420
|
+
# Return the cache for the request, falling back to the global cache.
|
|
421
|
+
#
|
|
422
|
+
# @return [ Object, nil ]
|
|
423
|
+
def cache
|
|
424
|
+
return nil if options[:cache] === false
|
|
425
|
+
options[:cache] || Typhoeus::Config.cache
|
|
426
|
+
end
|
|
427
|
+
|
|
428
|
+
# A streaming response has no buffered body, and a transport failure or a
|
|
429
|
+
# stub is not a representation of the resource.
|
|
430
|
+
#
|
|
431
|
+
# @param [ Typhoeus::Response ] response The response to cache.
|
|
432
|
+
#
|
|
433
|
+
# @return [ Boolean ] Whether the response should be cached.
|
|
434
|
+
def cacheable_response?(response)
|
|
435
|
+
!response.cached? &&
|
|
436
|
+
!streaming? &&
|
|
437
|
+
!response.mock? &&
|
|
438
|
+
(response.return_code.nil? || response.return_code == :ok)
|
|
439
|
+
end
|
|
440
|
+
|
|
441
|
+
# Checks if two hashes are equal or not, discarding
|
|
442
|
+
# first-level hash order.
|
|
443
|
+
#
|
|
444
|
+
# @param [ Hash ] left
|
|
445
|
+
# @param [ Hash ] right hash to check for equality
|
|
446
|
+
#
|
|
447
|
+
# @return [ Boolean ] Returns true if hashes have
|
|
448
|
+
# same values for same keys and same length,
|
|
449
|
+
# even if the keys are given in a different order.
|
|
450
|
+
def fuzzy_hash_eql?(left, right)
|
|
451
|
+
return true if (left == right)
|
|
452
|
+
|
|
453
|
+
(left.count == right.count) && left.inject(true) do |res, kvp|
|
|
454
|
+
res && (kvp[1] == right[kvp[0]])
|
|
455
|
+
end
|
|
456
|
+
end
|
|
457
|
+
|
|
458
|
+
def hashable_string_for(obj)
|
|
459
|
+
case obj
|
|
460
|
+
when Hash
|
|
461
|
+
pairs = obj.map do |key, value|
|
|
462
|
+
"#{hashable_string_for(key)}#{hashable_string_for(value)}"
|
|
463
|
+
end
|
|
464
|
+
"hash:#{obj.size}:#{pairs.sort.join}"
|
|
465
|
+
when Array
|
|
466
|
+
values = obj.map { |value| hashable_string_for(value) }
|
|
467
|
+
"array:#{obj.size}:#{values.join}"
|
|
468
|
+
else
|
|
469
|
+
value = obj.to_s
|
|
470
|
+
"#{obj.class}:#{value.bytesize}:#{value}"
|
|
471
|
+
end
|
|
472
|
+
end
|
|
473
|
+
|
|
474
|
+
# Sets default header and verbose when turned on.
|
|
475
|
+
def set_defaults
|
|
476
|
+
default_user_agent = Config.user_agent || Typhoeus::USER_AGENT
|
|
477
|
+
|
|
478
|
+
headers = (options[:headers] || {}).dup
|
|
479
|
+
unless header_key?(headers, "User-Agent")
|
|
480
|
+
headers = {"User-Agent" => default_user_agent}.merge(headers)
|
|
481
|
+
end
|
|
482
|
+
# An empty value suppresses libcurl's 100-continue. A nil value opts out
|
|
483
|
+
# of the header entirely, which lets libcurl add it when it sees fit.
|
|
484
|
+
unless header_key?(headers, "Expect")
|
|
485
|
+
headers["Expect"] = ""
|
|
486
|
+
end
|
|
487
|
+
headers.reject! { |key, value| key.to_s.casecmp?("Expect") && value.nil? }
|
|
488
|
+
options[:headers] = headers
|
|
489
|
+
options[:verbose] = Typhoeus::Config.verbose if options[:verbose].nil? && !Typhoeus::Config.verbose.nil?
|
|
490
|
+
options[:timeout] = Typhoeus::Config.timeout if options[:timeout].nil? && !Typhoeus::Config.timeout.nil?
|
|
491
|
+
options[:connecttimeout] = Typhoeus::Config.connecttimeout if options[:connecttimeout].nil? && !Typhoeus::Config.connecttimeout.nil?
|
|
492
|
+
options[:maxredirs] ||= 50
|
|
493
|
+
options[:proxy] = Typhoeus::Config.proxy unless options.has_key?(:proxy) || Typhoeus::Config.proxy.nil?
|
|
494
|
+
options[:cainfo] = ENV["SSL_CERT_FILE"] if options[:cainfo].nil? && ENV["SSL_CERT_FILE"]
|
|
495
|
+
options[:capath] = ENV["SSL_CERT_DIR"] if options[:capath].nil? && ENV["SSL_CERT_DIR"]
|
|
496
|
+
end
|
|
497
|
+
|
|
498
|
+
# Check the headers for a name without relying on its casing. Header names
|
|
499
|
+
# are case-insensitive and libcurl sends every spelling it is given, so a
|
|
500
|
+
# second default header would be added to the caller's value.
|
|
501
|
+
#
|
|
502
|
+
# @param [ Hash ] headers The request headers.
|
|
503
|
+
# @param [ String ] name The header name to look for.
|
|
504
|
+
#
|
|
505
|
+
# @return [ Boolean ] Whether the header is already present.
|
|
506
|
+
def header_key?(headers, name)
|
|
507
|
+
headers.keys.any? { |key| key.to_s.casecmp?(name) }
|
|
508
|
+
end
|
|
509
|
+
end
|
|
510
|
+
end
|