vagrant-unbundled 2.2.18.0 → 2.2.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -0
- data/Gemfile.lock +6 -6
- data/contrib/zsh/generate_zsh_completion.rb +2 -2
- data/lib/vagrant/errors.rb +8 -0
- data/plugins/commands/upload/command.rb +1 -1
- data/plugins/guests/atomic/guest.rb +1 -1
- data/plugins/guests/coreos/cap/configure_networks.rb +65 -0
- data/plugins/guests/darwin/cap/mount_smb_shared_folder.rb +6 -3
- data/plugins/guests/suse/cap/halt.rb +5 -1
- data/plugins/guests/windows/cap/rsync.rb +5 -1
- data/plugins/hosts/darwin/cap/path.rb +4 -0
- data/plugins/hosts/darwin/cap/version.rb +23 -0
- data/plugins/hosts/darwin/plugin.rb +5 -0
- data/plugins/hosts/windows/cap/ssh.rb +1 -1
- data/plugins/providers/virtualbox/action/network.rb +39 -2
- data/plugins/provisioners/chef/cap/freebsd/chef_installed.rb +5 -3
- data/plugins/provisioners/chef/cap/linux/chef_installed.rb +5 -3
- data/plugins/provisioners/chef/cap/omnios/chef_installed.rb +7 -5
- data/plugins/provisioners/chef/cap/windows/chef_installed.rb +3 -2
- data/templates/locales/en.yml +25 -0
- data/vagrant.gemspec +1 -1
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/CONTRIBUTING.md +23 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/CONTRIBUTORS.md +140 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/LICENSE.md +20 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/README.md +492 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/data/cacert.pem +3232 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/excon.gemspec +45 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/connection.rb +599 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/constants.rb +172 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/error.rb +229 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/extensions/uri.rb +34 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/headers.rb +85 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/instrumentors/logging_instrumentor.rb +48 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/instrumentors/standard_instrumentor.rb +21 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/base.rb +31 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/capture_cookies.rb +32 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/decompress.rb +44 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/escape_path.rb +12 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/expects.rb +25 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/idempotent.rb +57 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/instrumentor.rb +49 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/mock.rb +61 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/redirect_follower.rb +87 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/middlewares/response_parser.rb +16 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/pretty_printer.rb +39 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/response.rb +234 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/socket.rb +297 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/ssl_socket.rb +194 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/test/plugin/server/exec.rb +26 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/test/plugin/server/puma.rb +23 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/test/plugin/server/unicorn.rb +40 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/test/plugin/server/webrick.rb +26 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/test/server.rb +106 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/unix_socket.rb +42 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/utils.rb +143 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon/version.rb +4 -0
- data/vendor/bundle/ruby/3.0.0/gems/excon-0.89.0/lib/excon.rb +255 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/MIT-LICENSE +20 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/README.md +122 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/base.rb +289 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/cache.rb +113 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/cache_file.rb +36 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/cascade.rb +56 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/chain.rb +130 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/fallbacks.rb +97 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/flatten.rb +118 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/gettext.rb +85 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/interpolation_compiler.rb +123 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/key_value.rb +206 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/memoize.rb +54 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/metadata.rb +71 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/pluralization.rb +55 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/simple.rb +108 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend/transliterator.rb +108 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/backend.rb +21 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/config.rb +165 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/core_ext/hash.rb +59 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/exceptions.rb +111 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/gettext/helpers.rb +75 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/gettext/po_parser.rb +329 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/gettext.rb +28 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/interpolate/ruby.rb +39 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/locale/fallbacks.rb +99 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/locale/tag/parents.rb +24 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/locale/tag/rfc4646.rb +74 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/locale/tag/simple.rb +39 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/locale/tag.rb +28 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/locale.rb +8 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/middleware.rb +17 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/basics.rb +60 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/defaults.rb +52 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/interpolation.rb +163 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/link.rb +66 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/localization/date.rb +117 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/localization/date_time.rb +103 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/localization/procs.rb +117 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/localization/time.rb +103 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/localization.rb +19 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/lookup.rb +81 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/pluralization.rb +35 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests/procs.rb +60 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/tests.rb +14 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n/version.rb +5 -0
- data/vendor/bundle/ruby/3.0.0/gems/i18n-1.8.11/lib/i18n.rb +415 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/Code-of-Conduct.md +73 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/Contributing.md +132 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/History.md +269 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/Licence.md +25 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/Manifest.txt +31 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/README.rdoc +194 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/Rakefile +270 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/type/columnar.rb +57 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/type.rb +634 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/_columnar.rb +137 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/cache.rb +58 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/columnar.rb +3 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/container.rb +96 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/deprecations.rb +36 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/full.rb +19 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/loader.rb +159 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/logger.rb +37 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types/registry.rb +90 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime/types.rb +233 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/lib/mime-types.rb +3 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/bad-fixtures/malformed +9 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/fixture/json.json +1 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/fixture/old-data +9 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/fixture/yaml.yaml +55 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/minitest_helper.rb +11 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/test_mime_type.rb +621 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/test_mime_types.rb +169 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/test_mime_types_cache.rb +118 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/test_mime_types_class.rb +159 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/test_mime_types_lazy.rb +49 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-3.4.1/test/test_mime_types_loader.rb +32 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/Code-of-Conduct.md +75 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/Contributing.md +241 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/History.md +494 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/Licence.md +24 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/Manifest.txt +34 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/README.md +73 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/Rakefile +155 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/content_type_mime.db +878 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/ext_mime.db +1198 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime-types.json +1 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime.content_type.column +2376 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime.docs.column +2376 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime.encoding.column +2376 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime.flags.column +2376 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime.friendly.column +2376 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime.pext.column +2376 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime.use_instead.column +2376 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/data/mime.xrefs.column +2376 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/lib/mime/types/data.rb +21 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/lib/mime-types-data.rb +3 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/application.yaml +17254 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/audio.yaml +1716 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/chemical.yaml +71 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/conference.yaml +9 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/drawing.yaml +15 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/font.yaml +65 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/image.yaml +1251 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/message.yaml +200 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/model.yaml +390 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/multipart.yaml +179 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/provisional-standard-types.yaml +129 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/text.yaml +1166 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/video.yaml +1121 -0
- data/vendor/bundle/ruby/3.0.0/gems/mime-types-data-3.2021.1115/types/world.yaml +8 -0
- data/vendor/bundle/ruby/3.0.0/specifications/excon-0.89.0.gemspec +58 -0
- data/vendor/bundle/ruby/3.0.0/specifications/i18n-1.8.11.gemspec +32 -0
- data/vendor/bundle/ruby/3.0.0/specifications/mime-types-3.4.1.gemspec +63 -0
- data/vendor/bundle/ruby/3.0.0/specifications/mime-types-data-3.2021.1115.gemspec +54 -0
- data/version.txt +1 -1
- metadata +157 -4
@@ -0,0 +1,45 @@
|
|
1
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), 'lib')
|
2
|
+
require 'excon/version'
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = 'excon'
|
6
|
+
s.version = Excon::VERSION
|
7
|
+
s.summary = "speed, persistence, http(s)"
|
8
|
+
s.description = "EXtended http(s) CONnections"
|
9
|
+
s.authors = ["dpiddy (Dan Peterson)", "geemus (Wesley Beary)", "nextmat (Matt Sanders)"]
|
10
|
+
s.email = 'geemus@gmail.com'
|
11
|
+
s.homepage = 'https://github.com/excon/excon'
|
12
|
+
s.license = 'MIT'
|
13
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
14
|
+
s.extra_rdoc_files = %w[README.md CONTRIBUTORS.md CONTRIBUTING.md]
|
15
|
+
s.files = `git ls-files -- data/* lib/*`.split("\n") + [
|
16
|
+
"CONTRIBUTING.md",
|
17
|
+
"CONTRIBUTORS.md",
|
18
|
+
"LICENSE.md",
|
19
|
+
"README.md",
|
20
|
+
"excon.gemspec"
|
21
|
+
]
|
22
|
+
|
23
|
+
s.add_development_dependency('rspec', '>= 3.5.0')
|
24
|
+
s.add_development_dependency('activesupport')
|
25
|
+
s.add_development_dependency('delorean')
|
26
|
+
s.add_development_dependency('eventmachine', '>= 1.0.4')
|
27
|
+
s.add_development_dependency('open4')
|
28
|
+
s.add_development_dependency('rake')
|
29
|
+
s.add_development_dependency('rdoc')
|
30
|
+
s.add_development_dependency('shindo')
|
31
|
+
s.add_development_dependency('sinatra')
|
32
|
+
s.add_development_dependency('sinatra-contrib')
|
33
|
+
s.add_development_dependency('json', '>= 1.8.5')
|
34
|
+
s.add_development_dependency('puma')
|
35
|
+
s.add_development_dependency('webrick')
|
36
|
+
|
37
|
+
s.metadata = {
|
38
|
+
'homepage_uri' => 'https://github.com/excon/excon',
|
39
|
+
'bug_tracker_uri' => 'https://github.com/excon/excon/issues',
|
40
|
+
'changelog_uri' => 'https://github.com/excon/excon/blob/master/changelog.txt',
|
41
|
+
'documentation_uri' => 'https://github.com/excon/excon/blob/master/README.md',
|
42
|
+
'source_code_uri' => 'https://github.com/excon/excon',
|
43
|
+
'wiki_uri' => 'https://github.com/excon/excon/wiki'
|
44
|
+
}
|
45
|
+
end
|
@@ -0,0 +1,599 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'ipaddr'
|
3
|
+
|
4
|
+
module Excon
|
5
|
+
class Connection
|
6
|
+
include Utils
|
7
|
+
|
8
|
+
attr_reader :data
|
9
|
+
|
10
|
+
def connection
|
11
|
+
Excon.display_warning('Excon::Connection#connection is deprecated use Excon::Connection#data instead.')
|
12
|
+
@data
|
13
|
+
end
|
14
|
+
def connection=(new_params)
|
15
|
+
Excon.display_warning('Excon::Connection#connection= is deprecated. Use of this method may cause unexpected results.')
|
16
|
+
@data = new_params
|
17
|
+
end
|
18
|
+
|
19
|
+
def params
|
20
|
+
Excon.display_warning('Excon::Connection#params is deprecated use Excon::Connection#data instead.')
|
21
|
+
@data
|
22
|
+
end
|
23
|
+
def params=(new_params)
|
24
|
+
Excon.display_warning('Excon::Connection#params= is deprecated. Use of this method may cause unexpected results.')
|
25
|
+
@data = new_params
|
26
|
+
end
|
27
|
+
|
28
|
+
def proxy
|
29
|
+
Excon.display_warning('Excon::Connection#proxy is deprecated use Excon::Connection#data[:proxy] instead.')
|
30
|
+
@data[:proxy]
|
31
|
+
end
|
32
|
+
def proxy=(new_proxy)
|
33
|
+
Excon.display_warning('Excon::Connection#proxy= is deprecated. Use of this method may cause unexpected results.')
|
34
|
+
@data[:proxy] = new_proxy
|
35
|
+
end
|
36
|
+
|
37
|
+
def logger
|
38
|
+
if @data[:instrumentor] && @data[:instrumentor].respond_to?(:logger)
|
39
|
+
@data[:instrumentor].logger
|
40
|
+
end
|
41
|
+
end
|
42
|
+
def logger=(logger)
|
43
|
+
@data[:instrumentor] = Excon::LoggingInstrumentor
|
44
|
+
@data[:logger] = logger
|
45
|
+
end
|
46
|
+
|
47
|
+
# Initializes a new Connection instance
|
48
|
+
# @param [Hash<Symbol, >] params One or more optional params
|
49
|
+
# @option params [String] :body Default text to be sent over a socket. Only used if :body absent in Connection#request params
|
50
|
+
# @option params [Hash<Symbol, String>] :headers The default headers to supply in a request. Only used if params[:headers] is not supplied to Connection#request
|
51
|
+
# @option params [String] :host The destination host's reachable DNS name or IP, in the form of a String. IPv6 addresses must be wrapped (e.g. [::1]). See URI#host.
|
52
|
+
# @option params [String] :hostname Same as host, but usable for socket connections. IPv6 addresses must not be wrapped (e.g. ::1). See URI#hostname.
|
53
|
+
# @option params [String] :path Default path; appears after 'scheme://host:port/'. Only used if params[:path] is not supplied to Connection#request
|
54
|
+
# @option params [Fixnum] :port The port on which to connect, to the destination host
|
55
|
+
# @option params [Hash] :query Default query; appended to the 'scheme://host:port/path/' in the form of '?key=value'. Will only be used if params[:query] is not supplied to Connection#request
|
56
|
+
# @option params [String] :scheme The protocol; 'https' causes OpenSSL to be used
|
57
|
+
# @option params [String] :socket The path to the unix socket (required for 'unix://' connections)
|
58
|
+
# @option params [String] :ciphers Only use the specified SSL/TLS cipher suites; use OpenSSL cipher spec format e.g. 'HIGH:!aNULL:!3DES' or 'AES256-SHA:DES-CBC3-SHA'
|
59
|
+
# @option params [String] :proxy Proxy server; e.g. 'http://myproxy.com:8888'
|
60
|
+
# @option params [Fixnum] :retry_limit Set how many times we'll retry a failed request. (Default 4)
|
61
|
+
# @option params [Fixnum] :retry_interval Set how long to wait between retries. (Default 0)
|
62
|
+
# @option params [Class] :instrumentor Responds to #instrument as in ActiveSupport::Notifications
|
63
|
+
# @option params [String] :instrumentor_name Name prefix for #instrument events. Defaults to 'excon'
|
64
|
+
def initialize(params = {})
|
65
|
+
@data = Excon.defaults.dup
|
66
|
+
# merge does not deep-dup, so make sure headers is not the original
|
67
|
+
@data[:headers] = @data[:headers].dup
|
68
|
+
|
69
|
+
# the same goes for :middlewares
|
70
|
+
@data[:middlewares] = @data[:middlewares].dup
|
71
|
+
|
72
|
+
@data.merge!(params)
|
73
|
+
validate_params(:connection, @data, @data[:middlewares])
|
74
|
+
|
75
|
+
if @data.key?(:host) && !@data.key?(:hostname)
|
76
|
+
Excon.display_warning('hostname is missing! For IPv6 support, provide both host and hostname: Excon::Connection#new(:host => uri.host, :hostname => uri.hostname, ...).')
|
77
|
+
@data[:hostname] = @data[:host]
|
78
|
+
end
|
79
|
+
|
80
|
+
setup_proxy
|
81
|
+
|
82
|
+
if ENV.has_key?('EXCON_STANDARD_INSTRUMENTOR')
|
83
|
+
@data[:instrumentor] = Excon::StandardInstrumentor
|
84
|
+
end
|
85
|
+
|
86
|
+
if @data[:debug] || ENV.has_key?('EXCON_DEBUG')
|
87
|
+
@data[:debug_request] = @data[:debug_response] = true
|
88
|
+
@data[:instrumentor] = Excon::StandardInstrumentor
|
89
|
+
end
|
90
|
+
|
91
|
+
if @data[:scheme] == UNIX
|
92
|
+
if @data[:host]
|
93
|
+
raise ArgumentError, "The `:host` parameter should not be set for `unix://` connections.\n" +
|
94
|
+
"When supplying a `unix://` URI, it should start with `unix:/` or `unix:///`."
|
95
|
+
elsif !@data[:socket]
|
96
|
+
raise ArgumentError, 'You must provide a `:socket` for `unix://` connections'
|
97
|
+
else
|
98
|
+
@socket_key = "#{@data[:scheme]}://#{@data[:socket]}"
|
99
|
+
end
|
100
|
+
else
|
101
|
+
@socket_key = "#{@data[:scheme]}://#{@data[:host]}#{port_string(@data)}"
|
102
|
+
end
|
103
|
+
reset
|
104
|
+
end
|
105
|
+
|
106
|
+
def error_call(datum)
|
107
|
+
if datum[:error]
|
108
|
+
raise(datum[:error])
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def request_call(datum)
|
113
|
+
begin
|
114
|
+
if datum.has_key?(:response)
|
115
|
+
# we already have data from a middleware, so bail
|
116
|
+
return datum
|
117
|
+
else
|
118
|
+
socket(datum).data = datum
|
119
|
+
# start with "METHOD /path"
|
120
|
+
request = datum[:method].to_s.upcase + ' '
|
121
|
+
if datum[:proxy] && datum[:scheme] != HTTPS
|
122
|
+
request << datum[:scheme] << '://' << datum[:host] << port_string(datum)
|
123
|
+
end
|
124
|
+
request << datum[:path]
|
125
|
+
|
126
|
+
# add query to path, if there is one
|
127
|
+
request << query_string(datum)
|
128
|
+
|
129
|
+
# finish first line with "HTTP/1.1\r\n"
|
130
|
+
request << HTTP_1_1
|
131
|
+
|
132
|
+
if datum.has_key?(:request_block)
|
133
|
+
datum[:headers]['Transfer-Encoding'] = 'chunked'
|
134
|
+
else
|
135
|
+
body = datum[:body].is_a?(String) ? StringIO.new(datum[:body]) : datum[:body]
|
136
|
+
|
137
|
+
# The HTTP spec isn't clear on it, but specifically, GET requests don't usually send bodies;
|
138
|
+
# if they don't, sending Content-Length:0 can cause issues.
|
139
|
+
unless datum[:method].to_s.casecmp('GET') == 0 && body.nil?
|
140
|
+
unless datum[:headers].has_key?('Content-Length')
|
141
|
+
datum[:headers]['Content-Length'] = detect_content_length(body)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
# add headers to request
|
147
|
+
request << Utils.headers_hash_to_s(datum[:headers])
|
148
|
+
|
149
|
+
# add additional "\r\n" to indicate end of headers
|
150
|
+
request << CR_NL
|
151
|
+
|
152
|
+
if datum.has_key?(:request_block)
|
153
|
+
socket(datum).write(request) # write out request + headers
|
154
|
+
while true # write out body with chunked encoding
|
155
|
+
chunk = datum[:request_block].call
|
156
|
+
chunk = binary_encode(chunk)
|
157
|
+
if chunk.length > 0
|
158
|
+
socket(datum).write(chunk.length.to_s(16) << CR_NL << chunk << CR_NL)
|
159
|
+
else
|
160
|
+
socket(datum).write(String.new("0#{CR_NL}#{CR_NL}"))
|
161
|
+
break
|
162
|
+
end
|
163
|
+
end
|
164
|
+
elsif body.nil?
|
165
|
+
socket(datum).write(request) # write out request + headers
|
166
|
+
else # write out body
|
167
|
+
if body.respond_to?(:binmode) && !body.is_a?(StringIO)
|
168
|
+
body.binmode
|
169
|
+
end
|
170
|
+
if body.respond_to?(:rewind)
|
171
|
+
body.rewind rescue nil
|
172
|
+
end
|
173
|
+
|
174
|
+
# if request + headers is less than chunk size, fill with body
|
175
|
+
request = binary_encode(request)
|
176
|
+
chunk = body.read([datum[:chunk_size] - request.length, 0].max)
|
177
|
+
if chunk
|
178
|
+
chunk = binary_encode(chunk)
|
179
|
+
socket(datum).write(request << chunk)
|
180
|
+
else
|
181
|
+
socket(datum).write(request) # write out request + headers
|
182
|
+
end
|
183
|
+
|
184
|
+
while (chunk = body.read(datum[:chunk_size]))
|
185
|
+
socket(datum).write(chunk)
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
rescue => error
|
190
|
+
case error
|
191
|
+
when Excon::Errors::InvalidHeaderKey, Excon::Errors::InvalidHeaderValue, Excon::Errors::StubNotFound, Excon::Errors::Timeout
|
192
|
+
raise(error)
|
193
|
+
when Errno::EPIPE
|
194
|
+
# Read whatever remains in the pipe to aid in debugging
|
195
|
+
response = socket.read
|
196
|
+
error = Excon::Error.new(response + error.message)
|
197
|
+
raise_socket_error(error)
|
198
|
+
else
|
199
|
+
raise_socket_error(error)
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
datum
|
204
|
+
end
|
205
|
+
|
206
|
+
def response_call(datum)
|
207
|
+
# ensure response_block is yielded to and body is empty from middlewares
|
208
|
+
if datum.has_key?(:response_block) && !(datum[:response][:body].nil? || datum[:response][:body].empty?)
|
209
|
+
response_body = datum[:response][:body].dup
|
210
|
+
datum[:response][:body] = ''
|
211
|
+
content_length = remaining = response_body.bytesize
|
212
|
+
while remaining > 0
|
213
|
+
datum[:response_block].call(response_body.slice!(0, [datum[:chunk_size], remaining].min), [remaining - datum[:chunk_size], 0].max, content_length)
|
214
|
+
remaining -= datum[:chunk_size]
|
215
|
+
end
|
216
|
+
end
|
217
|
+
datum
|
218
|
+
end
|
219
|
+
|
220
|
+
# Sends the supplied request to the destination host.
|
221
|
+
# @yield [chunk] @see Response#self.parse
|
222
|
+
# @param [Hash<Symbol, >] params One or more optional params, override defaults set in Connection.new
|
223
|
+
# @option params [String] :body text to be sent over a socket
|
224
|
+
# @option params [Hash<Symbol, String>] :headers The default headers to supply in a request
|
225
|
+
# @option params [String] :path appears after 'scheme://host:port/'
|
226
|
+
# @option params [Hash] :query appended to the 'scheme://host:port/path/' in the form of '?key=value'
|
227
|
+
def request(params={}, &block)
|
228
|
+
# @data has defaults, merge in new params to override
|
229
|
+
datum = @data.merge(params)
|
230
|
+
datum[:headers] = @data[:headers].merge(datum[:headers] || {})
|
231
|
+
|
232
|
+
validate_params(:request, params, datum[:middlewares])
|
233
|
+
# If the user passed in new middleware, we want to validate that the original connection parameters
|
234
|
+
# are still valid with the provided middleware.
|
235
|
+
if params[:middlewares]
|
236
|
+
validate_params(:connection, @data, datum[:middlewares])
|
237
|
+
end
|
238
|
+
|
239
|
+
if datum[:user] || datum[:password]
|
240
|
+
user, pass = Utils.unescape_uri(datum[:user].to_s), Utils.unescape_uri(datum[:password].to_s)
|
241
|
+
datum[:headers]['Authorization'] ||= 'Basic ' + ["#{user}:#{pass}"].pack('m').delete(Excon::CR_NL)
|
242
|
+
end
|
243
|
+
|
244
|
+
if datum[:scheme] == UNIX
|
245
|
+
datum[:headers]['Host'] ||= ''
|
246
|
+
else
|
247
|
+
datum[:headers]['Host'] ||= datum[:host] + port_string(datum)
|
248
|
+
end
|
249
|
+
|
250
|
+
# RFC 7230, section 5.4, states that the Host header SHOULD be the first one # to be present.
|
251
|
+
# Some web servers will reject the request if it comes too late, so let's hoist it to the top.
|
252
|
+
if (host = datum[:headers].delete('Host'))
|
253
|
+
datum[:headers] = { 'Host' => host }.merge(datum[:headers])
|
254
|
+
end
|
255
|
+
|
256
|
+
# if path is empty or doesn't start with '/', insert one
|
257
|
+
unless datum[:path][0, 1] == '/'
|
258
|
+
datum[:path] = datum[:path].dup.insert(0, '/')
|
259
|
+
end
|
260
|
+
|
261
|
+
if block_given?
|
262
|
+
Excon.display_warning('Excon requests with a block are deprecated, pass :response_block instead.')
|
263
|
+
datum[:response_block] = block
|
264
|
+
end
|
265
|
+
|
266
|
+
datum[:connection] = self
|
267
|
+
|
268
|
+
# cleanup data left behind on persistent connection after interrupt
|
269
|
+
if datum[:persistent] && !@persistent_socket_reusable
|
270
|
+
reset
|
271
|
+
end
|
272
|
+
|
273
|
+
datum[:stack] = datum[:middlewares].map do |middleware|
|
274
|
+
lambda {|stack| middleware.new(stack)}
|
275
|
+
end.reverse.inject(self) do |middlewares, middleware|
|
276
|
+
middleware.call(middlewares)
|
277
|
+
end
|
278
|
+
datum = datum[:stack].request_call(datum)
|
279
|
+
|
280
|
+
unless datum[:pipeline]
|
281
|
+
@persistent_socket_reusable = false
|
282
|
+
datum = response(datum)
|
283
|
+
@persistent_socket_reusable = true
|
284
|
+
|
285
|
+
if datum[:persistent]
|
286
|
+
if (key = datum[:response][:headers].keys.detect {|k| k.casecmp('Connection') == 0 })
|
287
|
+
if datum[:response][:headers][key].casecmp('close') == 0
|
288
|
+
reset
|
289
|
+
end
|
290
|
+
end
|
291
|
+
else
|
292
|
+
reset
|
293
|
+
end
|
294
|
+
|
295
|
+
Excon::Response.new(datum[:response])
|
296
|
+
else
|
297
|
+
datum
|
298
|
+
end
|
299
|
+
rescue => error
|
300
|
+
reset
|
301
|
+
|
302
|
+
# If we didn't get far enough to initialize datum and the middleware stack, just raise
|
303
|
+
raise error if !datum
|
304
|
+
|
305
|
+
datum[:error] = error
|
306
|
+
if datum[:stack]
|
307
|
+
datum[:stack].error_call(datum)
|
308
|
+
else
|
309
|
+
raise error
|
310
|
+
end
|
311
|
+
end
|
312
|
+
|
313
|
+
# Sends the supplied requests to the destination host using pipelining.
|
314
|
+
# @param pipeline_params [Array<Hash>] An array of one or more optional params, override defaults set in Connection.new, see #request for details
|
315
|
+
def requests(pipeline_params)
|
316
|
+
pipeline_params.each {|params| params.merge!(:pipeline => true, :persistent => true) }
|
317
|
+
pipeline_params.last.merge!(:persistent => @data[:persistent])
|
318
|
+
|
319
|
+
responses = pipeline_params.map do |params|
|
320
|
+
request(params)
|
321
|
+
end.map do |datum|
|
322
|
+
Excon::Response.new(response(datum)[:response])
|
323
|
+
end
|
324
|
+
|
325
|
+
if @data[:persistent]
|
326
|
+
if (key = responses.last[:headers].keys.detect {|k| k.casecmp('Connection') == 0 })
|
327
|
+
if responses.last[:headers][key].casecmp('close') == 0
|
328
|
+
reset
|
329
|
+
end
|
330
|
+
end
|
331
|
+
else
|
332
|
+
reset
|
333
|
+
end
|
334
|
+
|
335
|
+
responses
|
336
|
+
end
|
337
|
+
|
338
|
+
# Sends the supplied requests to the destination host using pipelining in
|
339
|
+
# batches of @limit [Numeric] requests. This is your soft file descriptor
|
340
|
+
# limit by default, typically 256.
|
341
|
+
# @param pipeline_params [Array<Hash>] An array of one or more optional params, override defaults set in Connection.new, see #request for details
|
342
|
+
def batch_requests(pipeline_params, limit = nil)
|
343
|
+
limit ||= Process.respond_to?(:getrlimit) ? Process.getrlimit(:NOFILE).first : 256
|
344
|
+
responses = []
|
345
|
+
|
346
|
+
pipeline_params.each_slice(limit) do |params|
|
347
|
+
responses.concat(requests(params))
|
348
|
+
end
|
349
|
+
|
350
|
+
responses
|
351
|
+
end
|
352
|
+
|
353
|
+
def reset
|
354
|
+
if (old_socket = sockets.delete(@socket_key))
|
355
|
+
old_socket.close rescue nil
|
356
|
+
end
|
357
|
+
@persistent_socket_reusable = true
|
358
|
+
end
|
359
|
+
|
360
|
+
# Generate HTTP request verb methods
|
361
|
+
Excon::HTTP_VERBS.each do |method|
|
362
|
+
class_eval <<-DEF, __FILE__, __LINE__ + 1
|
363
|
+
def #{method}(params={}, &block)
|
364
|
+
request(params.merge!(:method => :#{method}), &block)
|
365
|
+
end
|
366
|
+
DEF
|
367
|
+
end
|
368
|
+
|
369
|
+
def retry_limit=(new_retry_limit)
|
370
|
+
Excon.display_warning('Excon::Connection#retry_limit= is deprecated, pass :retry_limit to the initializer.')
|
371
|
+
@data[:retry_limit] = new_retry_limit
|
372
|
+
end
|
373
|
+
|
374
|
+
def retry_limit
|
375
|
+
Excon.display_warning('Excon::Connection#retry_limit is deprecated, use Excon::Connection#data[:retry_limit].')
|
376
|
+
@data[:retry_limit] ||= DEFAULT_RETRY_LIMIT
|
377
|
+
end
|
378
|
+
|
379
|
+
def inspect
|
380
|
+
vars = instance_variables.inject({}) do |accum, var|
|
381
|
+
accum.merge!(var.to_sym => instance_variable_get(var))
|
382
|
+
end
|
383
|
+
vars[:'@data'] = Utils.redact(vars[:'@data'])
|
384
|
+
inspection = '#<Excon::Connection:'
|
385
|
+
inspection += (object_id << 1).to_s(16)
|
386
|
+
vars.each do |key, value|
|
387
|
+
inspection += " #{key}=#{value.inspect}"
|
388
|
+
end
|
389
|
+
inspection += '>'
|
390
|
+
inspection
|
391
|
+
end
|
392
|
+
|
393
|
+
def valid_request_keys(middlewares)
|
394
|
+
valid_middleware_keys(middlewares) + Excon::VALID_REQUEST_KEYS
|
395
|
+
end
|
396
|
+
|
397
|
+
private
|
398
|
+
|
399
|
+
def detect_content_length(body)
|
400
|
+
if body.respond_to?(:size)
|
401
|
+
# IO object: File, Tempfile, StringIO, etc.
|
402
|
+
body.size
|
403
|
+
elsif body.respond_to?(:stat)
|
404
|
+
# for 1.8.7 where file does not have size
|
405
|
+
body.stat.size
|
406
|
+
else
|
407
|
+
0
|
408
|
+
end
|
409
|
+
end
|
410
|
+
|
411
|
+
def valid_middleware_keys(middlewares)
|
412
|
+
middlewares.flat_map do |middleware|
|
413
|
+
if middleware.respond_to?(:valid_parameter_keys)
|
414
|
+
middleware.valid_parameter_keys
|
415
|
+
else
|
416
|
+
Excon.display_warning(
|
417
|
+
"Excon middleware #{middleware} does not define #valid_parameter_keys"
|
418
|
+
)
|
419
|
+
[]
|
420
|
+
end
|
421
|
+
end
|
422
|
+
end
|
423
|
+
|
424
|
+
def validate_params(validation, params, middlewares)
|
425
|
+
valid_keys = case validation
|
426
|
+
when :connection
|
427
|
+
valid_middleware_keys(middlewares) + Excon::VALID_CONNECTION_KEYS
|
428
|
+
when :request
|
429
|
+
valid_request_keys(middlewares)
|
430
|
+
else
|
431
|
+
raise ArgumentError.new("Invalid validation type '#{validation}'")
|
432
|
+
end
|
433
|
+
|
434
|
+
invalid_keys = params.keys - valid_keys
|
435
|
+
unless invalid_keys.empty?
|
436
|
+
Excon.display_warning("Invalid Excon #{validation} keys: #{invalid_keys.map(&:inspect).join(', ')}")
|
437
|
+
|
438
|
+
if validation == :request
|
439
|
+
deprecated_keys = invalid_keys & Excon::DEPRECATED_VALID_REQUEST_KEYS.keys
|
440
|
+
mw_msg = deprecated_keys.map do |k|
|
441
|
+
"#{k}: #{Excon::DEPRECATED_VALID_REQUEST_KEYS[k]}"
|
442
|
+
end.join(', ')
|
443
|
+
Excon.display_warning(
|
444
|
+
"The following request keys are only valid with the associated middleware: #{mw_msg}"
|
445
|
+
)
|
446
|
+
end
|
447
|
+
end
|
448
|
+
end
|
449
|
+
|
450
|
+
def response(datum={})
|
451
|
+
datum[:stack].response_call(datum)
|
452
|
+
rescue => error
|
453
|
+
case error
|
454
|
+
when Excon::Errors::HTTPStatusError, Excon::Errors::Timeout, Excon::Errors::TooManyRedirects
|
455
|
+
raise(error)
|
456
|
+
else
|
457
|
+
raise_socket_error(error)
|
458
|
+
end
|
459
|
+
end
|
460
|
+
|
461
|
+
def socket(datum = @data)
|
462
|
+
unix_proxy = datum[:proxy] ? datum[:proxy][:scheme] == UNIX : false
|
463
|
+
sockets[@socket_key] ||= if datum[:scheme] == UNIX || unix_proxy
|
464
|
+
Excon::UnixSocket.new(datum)
|
465
|
+
elsif datum[:ssl_uri_schemes].include?(datum[:scheme])
|
466
|
+
Excon::SSLSocket.new(datum)
|
467
|
+
else
|
468
|
+
Excon::Socket.new(datum)
|
469
|
+
end
|
470
|
+
end
|
471
|
+
|
472
|
+
def sockets
|
473
|
+
@_excon_sockets ||= {}
|
474
|
+
@_excon_sockets.compare_by_identity
|
475
|
+
|
476
|
+
if @data[:thread_safe_sockets]
|
477
|
+
# In a multi-threaded world, if the same connection is used by multiple
|
478
|
+
# threads at the same time to connect to the same destination, they may
|
479
|
+
# stomp on each other's sockets. This ensures every thread gets their
|
480
|
+
# own socket cache, within the context of a single connection.
|
481
|
+
@_excon_sockets[Thread.current] ||= {}
|
482
|
+
else
|
483
|
+
@_excon_sockets
|
484
|
+
end
|
485
|
+
end
|
486
|
+
|
487
|
+
def raise_socket_error(error)
|
488
|
+
if error.message =~ /certificate verify failed/
|
489
|
+
raise(Excon::Errors::CertificateError.new(error))
|
490
|
+
else
|
491
|
+
raise(Excon::Errors::SocketError.new(error))
|
492
|
+
end
|
493
|
+
end
|
494
|
+
|
495
|
+
def proxy_match_host_port(host, port)
|
496
|
+
host_match = if host.is_a? IPAddr
|
497
|
+
begin
|
498
|
+
host.include? @data[:host]
|
499
|
+
rescue IPAddr::Error
|
500
|
+
false
|
501
|
+
end
|
502
|
+
else
|
503
|
+
/(^|\.)#{host}$/.match(@data[:host])
|
504
|
+
end
|
505
|
+
host_match && (port.nil? || port.to_i == @data[:port])
|
506
|
+
end
|
507
|
+
|
508
|
+
def proxy_from_env
|
509
|
+
if (no_proxy_env = ENV['no_proxy'] || ENV['NO_PROXY'])
|
510
|
+
no_proxy_list = no_proxy_env.scan(/\s*(?:\[([\dA-Fa-f:\/]+)\]|\*?\.?([^\s,:]+))(?::(\d+))?\s*/i).map { |e|
|
511
|
+
if e[0]
|
512
|
+
begin
|
513
|
+
[IPAddr.new(e[0]), e[2]]
|
514
|
+
rescue IPAddr::Error
|
515
|
+
nil
|
516
|
+
end
|
517
|
+
else
|
518
|
+
begin
|
519
|
+
[IPAddr.new(e[1]), e[2]]
|
520
|
+
rescue IPAddr::Error
|
521
|
+
[e[1], e[2]]
|
522
|
+
end
|
523
|
+
end
|
524
|
+
}.reject { |e| e.nil? || e[0].nil? }
|
525
|
+
end
|
526
|
+
|
527
|
+
unless no_proxy_env && no_proxy_list.index { |h| proxy_match_host_port(h[0], h[1]) }
|
528
|
+
if @data[:scheme] == HTTPS && (ENV.has_key?('https_proxy') || ENV.has_key?('HTTPS_PROXY'))
|
529
|
+
@data[:proxy] = ENV['https_proxy'] || ENV['HTTPS_PROXY']
|
530
|
+
elsif (ENV.has_key?('http_proxy') || ENV.has_key?('HTTP_PROXY'))
|
531
|
+
@data[:proxy] = ENV['http_proxy'] || ENV['HTTP_PROXY']
|
532
|
+
end
|
533
|
+
end
|
534
|
+
end
|
535
|
+
|
536
|
+
def setup_proxy
|
537
|
+
if @data[:disable_proxy]
|
538
|
+
if @data[:proxy]
|
539
|
+
raise ArgumentError, "`:disable_proxy` parameter and `:proxy` parameter cannot both be set at the same time."
|
540
|
+
end
|
541
|
+
return
|
542
|
+
end
|
543
|
+
|
544
|
+
return if @data[:scheme] == UNIX
|
545
|
+
|
546
|
+
proxy_from_env
|
547
|
+
|
548
|
+
case @data[:proxy]
|
549
|
+
when nil
|
550
|
+
@data.delete(:proxy)
|
551
|
+
when ''
|
552
|
+
@data.delete(:proxy)
|
553
|
+
when Hash
|
554
|
+
# no processing needed
|
555
|
+
when String, URI
|
556
|
+
uri = @data[:proxy].is_a?(String) ? URI.parse(@data[:proxy]) : @data[:proxy]
|
557
|
+
@data[:proxy] = {
|
558
|
+
:host => uri.host,
|
559
|
+
:hostname => uri.hostname,
|
560
|
+
# path is only sensible for a Unix socket proxy
|
561
|
+
:path => uri.scheme == UNIX ? uri.path : nil,
|
562
|
+
:port => uri.port,
|
563
|
+
:scheme => uri.scheme,
|
564
|
+
}
|
565
|
+
if uri.password
|
566
|
+
@data[:proxy][:password] = uri.password
|
567
|
+
end
|
568
|
+
if uri.user
|
569
|
+
@data[:proxy][:user] = uri.user
|
570
|
+
end
|
571
|
+
if @data[:ssl_proxy_headers] && !@data[:ssl_uri_schemes].include?(@data[:scheme])
|
572
|
+
raise ArgumentError, "The `:ssl_proxy_headers` parameter should only be used with HTTPS requests."
|
573
|
+
end
|
574
|
+
if @data[:proxy][:scheme] == UNIX
|
575
|
+
if @data[:proxy][:host]
|
576
|
+
raise ArgumentError, "The `:host` parameter should not be set for `unix://` proxies.\n" +
|
577
|
+
"When supplying a `unix://` URI, it should start with `unix:/` or `unix:///`."
|
578
|
+
end
|
579
|
+
else
|
580
|
+
unless uri.host && uri.port && uri.scheme
|
581
|
+
raise Excon::Errors::ProxyParse, "Proxy is invalid"
|
582
|
+
end
|
583
|
+
end
|
584
|
+
else
|
585
|
+
raise Excon::Errors::ProxyParse, "Proxy is invalid"
|
586
|
+
end
|
587
|
+
|
588
|
+
if @data.has_key?(:proxy) && @data[:scheme] == 'http'
|
589
|
+
@data[:headers]['Proxy-Connection'] ||= 'Keep-Alive'
|
590
|
+
# https credentials happen in handshake
|
591
|
+
if @data[:proxy].has_key?(:user) || @data[:proxy].has_key?(:password)
|
592
|
+
user, pass = Utils.unescape_form(@data[:proxy][:user].to_s), Utils.unescape_form(@data[:proxy][:password].to_s)
|
593
|
+
auth = ["#{user}:#{pass}"].pack('m').delete(Excon::CR_NL)
|
594
|
+
@data[:headers]['Proxy-Authorization'] = 'Basic ' + auth
|
595
|
+
end
|
596
|
+
end
|
597
|
+
end
|
598
|
+
end
|
599
|
+
end
|