vagrant-unbundled 1.8.4.2 → 1.8.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/CHANGELOG.md +52 -0
- data/Gemfile.lock +9 -7
- data/RELEASE.md +37 -14
- data/lib/vagrant/action/builtin/box_add.rb +3 -1
- data/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb +5 -0
- data/lib/vagrant/box_collection.rb +2 -1
- data/lib/vagrant/bundler.rb +36 -1
- data/lib/vagrant/errors.rb +16 -8
- data/lib/vagrant/plugin/state_file.rb +8 -1
- data/lib/vagrant/util/platform.rb +1 -1
- data/plugins/guests/arch/cap/change_host_name.rb +13 -10
- data/plugins/guests/arch/cap/configure_networks.rb +11 -8
- data/plugins/guests/arch/cap/nfs.rb +35 -0
- data/plugins/guests/arch/cap/rsync.rb +16 -0
- data/plugins/guests/arch/cap/smb.rb +17 -0
- data/plugins/guests/arch/plugin.rb +28 -3
- data/plugins/guests/atomic/cap/change_host_name.rb +13 -10
- data/plugins/guests/atomic/plugin.rb +3 -3
- data/plugins/guests/{netbsd → bsd}/cap/halt.rb +2 -2
- data/plugins/guests/bsd/cap/nfs.rb +49 -0
- data/plugins/guests/bsd/cap/public_key.rb +65 -0
- data/plugins/guests/bsd/cap/virtualbox.rb +16 -0
- data/plugins/guests/bsd/guest.rb +9 -0
- data/plugins/guests/bsd/plugin.rb +40 -0
- data/plugins/guests/coreos/cap/change_host_name.rb +1 -1
- data/plugins/guests/coreos/plugin.rb +4 -4
- data/plugins/guests/darwin/cap/change_host_name.rb +4 -1
- data/plugins/guests/darwin/cap/configure_networks.rb +12 -5
- data/plugins/guests/darwin/cap/halt.rb +3 -1
- data/plugins/guests/darwin/cap/rsync.rb +7 -4
- data/plugins/guests/darwin/plugin.rb +13 -28
- data/plugins/guests/debian/cap/change_host_name.rb +14 -15
- data/plugins/guests/debian/cap/configure_networks.rb +2 -6
- data/plugins/guests/debian/cap/{nfs_client.rb → nfs.rb} +2 -1
- data/plugins/guests/debian/cap/rsync.rb +5 -6
- data/plugins/guests/debian/plugin.rb +8 -8
- data/plugins/guests/esxi/cap/mount_nfs_folder.rb +2 -2
- data/plugins/guests/esxi/plugin.rb +6 -6
- data/plugins/guests/fedora/cap/flavor.rb +1 -1
- data/plugins/guests/fedora/plugin.rb +2 -17
- data/plugins/guests/freebsd/cap/change_host_name.rb +2 -3
- data/plugins/guests/freebsd/cap/rsync.rb +7 -4
- data/plugins/guests/freebsd/plugin.rb +9 -29
- data/plugins/guests/funtoo/plugin.rb +3 -8
- data/plugins/guests/gentoo/cap/change_host_name.rb +21 -6
- data/plugins/guests/gentoo/cap/configure_networks.rb +35 -26
- data/plugins/guests/gentoo/plugin.rb +4 -4
- data/plugins/guests/linux/cap/choose_addressable_ip_addr.rb +2 -3
- data/plugins/guests/linux/cap/mount_virtualbox_shared_folder.rb +31 -45
- data/plugins/guests/linux/cap/network_interfaces.rb +20 -0
- data/plugins/guests/linux/cap/nfs.rb +57 -0
- data/plugins/guests/linux/cap/public_key.rb +65 -0
- data/plugins/guests/linux/cap/rsync.rb +7 -4
- data/plugins/guests/linux/plugin.rb +30 -25
- data/plugins/guests/mint/plugin.rb +1 -1
- data/plugins/guests/netbsd/plugin.rb +10 -30
- data/plugins/guests/nixos/plugin.rb +5 -5
- data/plugins/guests/omnios/cap/change_host_name.rb +1 -1
- data/plugins/guests/omnios/plugin.rb +4 -4
- data/plugins/guests/openbsd/cap/change_host_name.rb +21 -3
- data/plugins/guests/openbsd/plugin.rb +10 -30
- data/plugins/guests/photon/cap/change_host_name.rb +1 -1
- data/plugins/guests/photon/plugin.rb +4 -4
- data/plugins/guests/pld/cap/change_host_name.rb +1 -1
- data/plugins/guests/pld/plugin.rb +4 -4
- data/plugins/guests/redhat/cap/change_host_name.rb +4 -3
- data/plugins/guests/redhat/cap/configure_networks.rb +1 -24
- data/plugins/guests/redhat/plugin.rb +7 -7
- data/plugins/guests/slackware/cap/change_host_name.rb +1 -1
- data/plugins/guests/slackware/cap/configure_networks.rb +1 -5
- data/plugins/guests/slackware/plugin.rb +3 -3
- data/plugins/guests/smartos/plugin.rb +12 -12
- data/plugins/guests/solaris/plugin.rb +14 -14
- data/plugins/guests/solaris11/plugin.rb +12 -12
- data/plugins/guests/suse/cap/change_host_name.rb +1 -1
- data/plugins/guests/suse/cap/configure_networks.rb +1 -5
- data/plugins/guests/suse/plugin.rb +8 -8
- data/plugins/guests/tinycore/cap/mount_nfs.rb +2 -2
- data/plugins/guests/tinycore/plugin.rb +7 -7
- data/plugins/guests/trisquel/plugin.rb +1 -1
- data/plugins/guests/ubuntu/guest.rb +1 -1
- data/plugins/guests/ubuntu/plugin.rb +1 -6
- data/plugins/guests/windows/plugin.rb +2 -2
- data/plugins/kernel_v2/config/vm.rb +8 -1
- data/plugins/providers/hyperv/scripts/get_vm_status.ps1 +25 -5
- data/plugins/providers/virtualbox/driver/meta.rb +1 -0
- data/plugins/providers/virtualbox/driver/version_5_1.rb +734 -0
- data/plugins/providers/virtualbox/plugin.rb +1 -0
- data/plugins/synced_folders/nfs/synced_folder.rb +10 -2
- data/plugins/synced_folders/rsync/helper.rb +11 -4
- data/scripts/{bintray_upload.sh → sign.sh} +0 -0
- data/templates/guests/arch/network_static.erb +3 -3
- data/templates/guests/arch/network_static6.erb +8 -0
- data/templates/guests/freebsd/network_static6.erb +6 -0
- data/templates/guests/funtoo/network_static6.erb +9 -0
- data/templates/guests/gentoo/network_dhcp.erb +1 -1
- data/templates/guests/gentoo/network_static.erb +4 -4
- data/templates/guests/gentoo/network_static6.erb +7 -0
- data/templates/guests/redhat/network_dhcp.erb +1 -1
- data/templates/guests/redhat/network_static.erb +4 -1
- data/templates/guests/{fedora → redhat}/network_static6.erb +5 -2
- data/templates/locales/en.yml +40 -6
- data/test/unit/plugins/guests/arch/cap/change_host_name_test.rb +6 -6
- data/test/unit/plugins/guests/arch/cap/configure_networks_test.rb +20 -15
- data/test/unit/plugins/guests/arch/cap/rsync_test.rb +30 -0
- data/test/unit/plugins/guests/arch/cap/smb_test.rb +38 -0
- data/test/unit/plugins/guests/atomic/cap/change_host_name_test.rb +9 -8
- data/test/unit/plugins/guests/{freebsd → bsd}/cap/halt_test.rb +11 -10
- data/test/unit/plugins/guests/{freebsd → bsd}/cap/insert_public_key_test.rb +7 -6
- data/test/unit/plugins/guests/bsd/cap/nfs_test.rb +68 -0
- data/test/unit/plugins/guests/coreos/cap/change_host_name_test.rb +5 -5
- data/test/unit/plugins/guests/darwin/cap/change_host_name_test.rb +5 -5
- data/test/unit/plugins/guests/darwin/cap/halt_test.rb +36 -0
- data/test/unit/plugins/guests/debian/cap/change_host_name_test.rb +3 -5
- data/test/unit/plugins/guests/debian/cap/configure_networks_test.rb +13 -9
- data/test/unit/plugins/guests/debian/cap/rsync_test.rb +3 -11
- data/test/unit/plugins/guests/freebsd/cap/change_host_name_test.rb +2 -2
- data/test/unit/plugins/guests/linux/cap/mount_nfs_test.rb +16 -3
- data/test/unit/plugins/guests/omnios/cap/change_host_name_test.rb +2 -2
- data/test/unit/plugins/guests/photon/cap/change_host_name_test.rb +2 -2
- data/test/unit/plugins/guests/pld/cap/change_host_name_test.rb +2 -2
- data/test/unit/plugins/guests/redhat/cap/change_host_name_test.rb +4 -3
- data/test/unit/plugins/guests/redhat/cap/configure_networks_test.rb +17 -33
- data/test/unit/plugins/guests/slackware/cap/change_host_name_test.rb +2 -2
- data/test/unit/plugins/guests/slackware/cap/configure_networks_test.rb +8 -4
- data/test/unit/plugins/guests/suse/cap/change_host_name_test.rb +2 -2
- data/test/unit/plugins/guests/suse/cap/configure_networks_test.rb +13 -16
- data/test/unit/plugins/kernel_v2/config/vm_test.rb +10 -2
- data/test/unit/templates/guests/arch/network_static_test.rb +4 -2
- data/test/unit/templates/guests/gentoo/network_dhcp_test.rb +2 -2
- data/test/unit/templates/guests/gentoo/network_static_test.rb +10 -10
- data/test/unit/templates/guests/redhat/network_dhcp_test.rb +2 -2
- data/test/unit/templates/guests/redhat/network_static_test.rb +9 -9
- data/vagrant.gemspec +3 -3
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/CHANGELOG.md +1 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/CONTRIBUTING.md +38 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/LICENSE.txt +22 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/README.md +297 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/bin/listen +12 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/adapter/base.rb +141 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/adapter/bsd.rb +106 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/adapter/config.rb +26 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/adapter/darwin.rb +92 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/adapter/linux.rb +106 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/adapter/polling.rb +37 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/adapter/windows.rb +98 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/adapter.rb +45 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/backend.rb +38 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/change.rb +76 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/cli.rb +65 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/directory.rb +87 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/event/config.rb +55 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/event/loop.rb +117 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/event/processor.rb +122 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/event/queue.rb +55 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/file.rb +80 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/fsm.rb +132 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/internals/thread_pool.rb +29 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/listener/config.rb +41 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/listener.rb +133 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/logger.rb +32 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/options.rb +23 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/queue_optimizer.rb +132 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/record/entry.rb +64 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/record/symlink_detector.rb +39 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/record.rb +118 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/silencer/controller.rb +48 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/silencer.rb +97 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/version.rb +3 -0
- data/vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen.rb +57 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/.gitignore +8 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/.rspec +2 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/.rubocop-disables.yml +384 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/.rubocop.yml +3 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/.travis.yml +43 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/AUTHORS +98 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/Gemfile +11 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/LICENSE +21 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/README.md +667 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/Rakefile +132 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/bin/restclient +92 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/history.md +310 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/lib/rest-client.rb +2 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/lib/rest_client.rb +2 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/lib/restclient/abstract_response.rb +226 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/lib/restclient/exceptions.rb +244 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/lib/restclient/params_array.rb +72 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/lib/restclient/payload.rb +209 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/lib/restclient/platform.rb +49 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/lib/restclient/raw_response.rb +38 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/lib/restclient/request.rb +904 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/lib/restclient/resource.rb +168 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/lib/restclient/response.rb +80 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/lib/restclient/utils.rb +235 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/lib/restclient/version.rb +8 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/lib/restclient/windows/root_certs.rb +105 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/lib/restclient/windows.rb +8 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/lib/restclient.rb +184 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/rest-client.gemspec +31 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/rest-client.windows.gemspec +19 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/helpers.rb +22 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/integration/_lib.rb +1 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/integration/capath_digicert/244b5494.0 +19 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/integration/capath_digicert/81b9768f.0 +19 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/integration/capath_digicert/README +8 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/integration/capath_digicert/digicert.crt +19 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/integration/capath_verisign/415660c1.0 +14 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/integration/capath_verisign/7651b327.0 +14 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/integration/capath_verisign/README +8 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/integration/capath_verisign/verisign.crt +14 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/integration/certs/digicert.crt +19 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/integration/certs/verisign.crt +14 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/integration/httpbin_spec.rb +86 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/integration/integration_spec.rb +125 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/integration/request_spec.rb +127 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/spec_helper.rb +29 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/unit/_lib.rb +1 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/unit/abstract_response_spec.rb +145 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/unit/exceptions_spec.rb +108 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/unit/master_shake.jpg +0 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/unit/params_array_spec.rb +36 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/unit/payload_spec.rb +263 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/unit/raw_response_spec.rb +18 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/unit/request2_spec.rb +54 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/unit/request_spec.rb +1265 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/unit/resource_spec.rb +130 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/unit/response_spec.rb +241 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/unit/restclient_spec.rb +79 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/unit/utils_spec.rb +147 -0
- data/vendor/bundle/ruby/2.3.0/gems/rest-client-2.0.0/spec/unit/windows/root_certs_spec.rb +22 -0
- data/vendor/bundle/ruby/2.3.0/gems/ruby_dep-1.4.0/.gitignore +10 -0
- data/vendor/bundle/ruby/2.3.0/gems/ruby_dep-1.4.0/.rspec +3 -0
- data/vendor/bundle/ruby/2.3.0/gems/ruby_dep-1.4.0/.rubocop.yml +3 -0
- data/vendor/bundle/ruby/2.3.0/gems/ruby_dep-1.4.0/.travis.yml +11 -0
- data/vendor/bundle/ruby/2.3.0/gems/ruby_dep-1.4.0/LICENSE.txt +21 -0
- data/vendor/bundle/ruby/2.3.0/gems/ruby_dep-1.4.0/README.md +151 -0
- data/vendor/bundle/ruby/2.3.0/gems/ruby_dep-1.4.0/lib/ruby_dep/logger.rb +16 -0
- data/vendor/bundle/ruby/2.3.0/gems/ruby_dep-1.4.0/lib/ruby_dep/quiet.rb +3 -0
- data/vendor/bundle/ruby/2.3.0/gems/ruby_dep-1.4.0/lib/ruby_dep/ruby_version.rb +58 -0
- data/vendor/bundle/ruby/2.3.0/gems/ruby_dep-1.4.0/lib/ruby_dep/travis/ruby_version.rb +59 -0
- data/vendor/bundle/ruby/2.3.0/gems/ruby_dep-1.4.0/lib/ruby_dep/travis.rb +58 -0
- data/vendor/bundle/ruby/2.3.0/gems/ruby_dep-1.4.0/lib/ruby_dep/version.rb +3 -0
- data/vendor/bundle/ruby/2.3.0/gems/ruby_dep-1.4.0/lib/ruby_dep/warning.rb +97 -0
- data/vendor/bundle/ruby/2.3.0/gems/ruby_dep-1.4.0/lib/ruby_dep.rb +2 -0
- data/vendor/bundle/ruby/2.3.0/specifications/listen-3.1.5.gemspec +44 -0
- data/vendor/bundle/ruby/2.3.0/specifications/rest-client-2.0.0.gemspec +60 -0
- data/vendor/bundle/ruby/2.3.0/specifications/ruby_dep-1.4.0.gemspec +34 -0
- data/version.txt +1 -1
- metadata +147 -44
- data/plugins/guests/darwin/cap/insert_public_key.rb +0 -33
- data/plugins/guests/darwin/cap/mount_nfs_folder.rb +0 -37
- data/plugins/guests/darwin/cap/remove_public_key.rb +0 -21
- data/plugins/guests/fedora/cap/change_host_name.rb +0 -29
- data/plugins/guests/fedora/cap/configure_networks.rb +0 -135
- data/plugins/guests/fedora/cap/network_scripts_dir.rb +0 -15
- data/plugins/guests/freebsd/cap/halt.rb +0 -16
- data/plugins/guests/freebsd/cap/insert_public_key.rb +0 -34
- data/plugins/guests/freebsd/cap/mount_nfs_folder.rb +0 -24
- data/plugins/guests/freebsd/cap/remove_public_key.rb +0 -21
- data/plugins/guests/funtoo/cap/change_host_name.rb +0 -17
- data/plugins/guests/linux/cap/insert_public_key.rb +0 -31
- data/plugins/guests/linux/cap/mount_nfs.rb +0 -50
- data/plugins/guests/linux/cap/nfs_client.rb +0 -11
- data/plugins/guests/linux/cap/remove_public_key.rb +0 -24
- data/plugins/guests/netbsd/cap/insert_public_key.rb +0 -21
- data/plugins/guests/netbsd/cap/mount_nfs_folder.rb +0 -17
- data/plugins/guests/netbsd/cap/remove_public_key.rb +0 -21
- data/plugins/guests/openbsd/cap/halt.rb +0 -16
- data/plugins/guests/openbsd/cap/insert_public_key.rb +0 -21
- data/plugins/guests/openbsd/cap/mount_nfs_folder.rb +0 -14
- data/plugins/guests/openbsd/cap/remove_public_key.rb +0 -21
- data/plugins/guests/ubuntu/cap/change_host_name.rb +0 -52
- data/templates/guests/fedora/network_dhcp.erb +0 -6
- data/templates/guests/fedora/network_static.erb +0 -16
- data/test/unit/plugins/guests/freebsd/cap/mount_nfs_folder_test.rb +0 -53
- data/test/unit/plugins/guests/ubuntu/cap/change_host_name_test.rb +0 -42
- data/test/unit/templates/guests/fedora/network_dhcp_test.rb +0 -21
- data/test/unit/templates/guests/fedora/network_static6_test.rb +0 -25
- data/test/unit/templates/guests/fedora/network_static_test.rb +0 -71
@@ -0,0 +1,43 @@
|
|
1
|
+
# Available ruby versions: http://rubies.travis-ci.org/
|
2
|
+
|
3
|
+
language: ruby
|
4
|
+
os:
|
5
|
+
- linux
|
6
|
+
- osx
|
7
|
+
rvm:
|
8
|
+
- "2.0.0"
|
9
|
+
- "2.1" # latest 2.1.x
|
10
|
+
- "2.2" # latest 2.2.x
|
11
|
+
- "2.3.1" # TODO: switch to "2.3" once travis fixes it
|
12
|
+
- "ruby-head"
|
13
|
+
- "jruby-9.0.5.0"
|
14
|
+
- "jruby-head"
|
15
|
+
script:
|
16
|
+
bundle exec rake test
|
17
|
+
branches:
|
18
|
+
except:
|
19
|
+
- "readme-edits"
|
20
|
+
|
21
|
+
# Travis OS X support is pretty janky. These are some hacks to include tests
|
22
|
+
# only on versions that actually work.
|
23
|
+
# (last tested: 2016-04)
|
24
|
+
matrix:
|
25
|
+
exclude:
|
26
|
+
- os: osx
|
27
|
+
rvm: '2.2'
|
28
|
+
- os: osx
|
29
|
+
rvm: '2.3.1' # No 2.3.x at all
|
30
|
+
include:
|
31
|
+
- os: osx
|
32
|
+
rvm: '2.2.2' # Travis OS X doesn't have 2.2 aliases
|
33
|
+
allow_failures:
|
34
|
+
- rvm: 'ruby-head'
|
35
|
+
- os: osx
|
36
|
+
rvm: 'jruby-9.0.5.0'
|
37
|
+
- os: osx
|
38
|
+
rvm: 'jruby-head'
|
39
|
+
- os: linux
|
40
|
+
rvm: 'jruby-head'
|
41
|
+
fast_finish: true
|
42
|
+
|
43
|
+
sudo: false
|
@@ -0,0 +1,98 @@
|
|
1
|
+
The Ruby REST Client would not be what it is today without the help of
|
2
|
+
the following kind souls:
|
3
|
+
|
4
|
+
Adam Jacob
|
5
|
+
Adam Wiggins
|
6
|
+
Adrian Rangel
|
7
|
+
Alex Tomlins
|
8
|
+
Aman Gupta
|
9
|
+
Andy Brody
|
10
|
+
Blake Mizerany
|
11
|
+
Brad Ediger
|
12
|
+
Braintree
|
13
|
+
Brian Donovan
|
14
|
+
Caleb Land
|
15
|
+
Chris Dinn
|
16
|
+
Chris Frohoff
|
17
|
+
Chris Green
|
18
|
+
Coda Hale
|
19
|
+
Crawford
|
20
|
+
Cyril Rohr
|
21
|
+
Dan Mayer
|
22
|
+
Dario Hamidi
|
23
|
+
Darren Coxall
|
24
|
+
David Backeus
|
25
|
+
David Perkowski
|
26
|
+
Dmitri Dolguikh
|
27
|
+
Dusty Doris
|
28
|
+
Dylan Egan
|
29
|
+
El Draper
|
30
|
+
Evan Broder
|
31
|
+
Evan Smith
|
32
|
+
François Beausoleil
|
33
|
+
Gabriele Cirulli
|
34
|
+
Garry Shutler
|
35
|
+
Giovanni Cappellotto
|
36
|
+
Greg Borenstein
|
37
|
+
Harm Aarts
|
38
|
+
Hiro Asari
|
39
|
+
Hugh McGowan
|
40
|
+
Ian Warshak
|
41
|
+
Ivan Makfinsky
|
42
|
+
JH. Chabran
|
43
|
+
James Edward Gray II
|
44
|
+
Jari Bakken
|
45
|
+
Jeff Remer
|
46
|
+
Jeffrey Hardy
|
47
|
+
Jeremy Kemper
|
48
|
+
Joe Rafaniello
|
49
|
+
John Barnette
|
50
|
+
Jon Rowe
|
51
|
+
Jordi Massaguer Pla
|
52
|
+
Joshua J. Campoverde
|
53
|
+
Juan Alvarez
|
54
|
+
Julien Kirch
|
55
|
+
Jun Aruga
|
56
|
+
Justin Coyne
|
57
|
+
Justin Lambert
|
58
|
+
Keith Rarick
|
59
|
+
Kenichi Kamiya
|
60
|
+
Kevin Read
|
61
|
+
Kosuke Asami
|
62
|
+
Kyle VanderBeek
|
63
|
+
Lars Gierth
|
64
|
+
Lawrence Leonard Gilbert
|
65
|
+
Lee Jarvis
|
66
|
+
Lennon Day-Reynolds
|
67
|
+
Lin Jen-Shin
|
68
|
+
Marc-André Cournoyer
|
69
|
+
Marius Butuc
|
70
|
+
Matthew Manning
|
71
|
+
Michael Klett
|
72
|
+
Michael Rykov
|
73
|
+
Michael Westbom
|
74
|
+
Mike Fletcher
|
75
|
+
Nelson Elhage
|
76
|
+
Nicholas Wieland
|
77
|
+
Nick Hammond
|
78
|
+
Nick Plante
|
79
|
+
Niko Dittmann
|
80
|
+
Oscar Del Ben
|
81
|
+
Pablo Astigarraga
|
82
|
+
Paul Dlug
|
83
|
+
Pedro Belo
|
84
|
+
Pedro Chambino
|
85
|
+
Philip Corliss
|
86
|
+
Pierre-Louis Gottfrois
|
87
|
+
Rafael Ssouza
|
88
|
+
Rick Olson
|
89
|
+
Robert Eanes
|
90
|
+
Rodrigo Panachi
|
91
|
+
Samuel Cochran
|
92
|
+
Syl Turner
|
93
|
+
T. Watanabe
|
94
|
+
Tekin
|
95
|
+
W. Andrew Loe III
|
96
|
+
Waynn Lue
|
97
|
+
Xavier Shay
|
98
|
+
tpresa
|
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2008-2014 Rest Client Authors
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
@@ -0,0 +1,667 @@
|
|
1
|
+
# REST Client -- simple DSL for accessing HTTP and REST resources
|
2
|
+
|
3
|
+
[![Gem Downloads](https://img.shields.io/gem/dt/rails.svg)](https://rubygems.org/gems/rest-client)
|
4
|
+
[![Build Status](https://travis-ci.org/rest-client/rest-client.svg?branch=master)](https://travis-ci.org/rest-client/rest-client)
|
5
|
+
[![Code Climate](https://codeclimate.com/github/rest-client/rest-client.svg)](https://codeclimate.com/github/rest-client/rest-client)
|
6
|
+
[![Inline docs](http://inch-ci.org/github/rest-client/rest-client.svg?branch=master)](http://www.rubydoc.info/github/rest-client/rest-client/master)
|
7
|
+
|
8
|
+
A simple HTTP and REST client for Ruby, inspired by the Sinatra's microframework style
|
9
|
+
of specifying actions: get, put, post, delete.
|
10
|
+
|
11
|
+
* Main page: https://github.com/rest-client/rest-client
|
12
|
+
* Mailing list: https://groups.io/g/rest-client
|
13
|
+
|
14
|
+
### New mailing list
|
15
|
+
|
16
|
+
We have a new email list for announcements, hosted by Groups.io.
|
17
|
+
|
18
|
+
* Subscribe on the web: https://groups.io/g/rest-client
|
19
|
+
|
20
|
+
* Subscribe by sending an email: mailto:rest-client+subscribe@groups.io
|
21
|
+
|
22
|
+
* Open discussion subgroup: https://groups.io/g/rest-client+discuss
|
23
|
+
|
24
|
+
The old Librelist mailing list is *defunct*, as Librelist appears to be broken
|
25
|
+
and not accepting new mail. The old archives are still up, but have been
|
26
|
+
imported into the new list archives as well.
|
27
|
+
http://librelist.com/browser/rest.client
|
28
|
+
|
29
|
+
## Requirements
|
30
|
+
|
31
|
+
MRI Ruby 2.0 and newer are supported. Alternative interpreters compatible with
|
32
|
+
2.0+ should work as well.
|
33
|
+
|
34
|
+
Earlier Ruby versions such as 1.8.7, 1.9.2, and 1.9.3 are no longer supported. These
|
35
|
+
versions no longer have any official support, and do not receive security
|
36
|
+
updates.
|
37
|
+
|
38
|
+
The rest-client gem depends on these other gems for usage at runtime:
|
39
|
+
|
40
|
+
* [mime-types](http://rubygems.org/gems/mime-types)
|
41
|
+
* [netrc](http://rubygems.org/gems/netrc)
|
42
|
+
* [http-cookie](https://rubygems.org/gems/http-cookie)
|
43
|
+
|
44
|
+
There are also several development dependencies. It's recommended to use
|
45
|
+
[bundler](http://bundler.io/) to manage these dependencies for hacking on
|
46
|
+
rest-client.
|
47
|
+
|
48
|
+
### Upgrading to rest-client 2.0 from 1.x
|
49
|
+
|
50
|
+
Users are encouraged to upgrade to rest-client 2.0, which cleans up a number of
|
51
|
+
API warts and wrinkles, making rest-client generally more useful. Usage is
|
52
|
+
largely compatible, so many applications will be able to upgrade with no
|
53
|
+
changes.
|
54
|
+
|
55
|
+
Overview of significant changes:
|
56
|
+
|
57
|
+
* requires Ruby >= 2.0
|
58
|
+
* `RestClient::Response` objects are a subclass of `String` rather than a
|
59
|
+
Frankenstein monster. And `#body` or `#to_s` return a true `String` object.
|
60
|
+
* cleanup of exception classes, including new `RestClient::Exceptions::Timeout`
|
61
|
+
* improvements to handling of redirects: responses and history are properly
|
62
|
+
exposed
|
63
|
+
* major changes to cookie support: cookie jars are used for browser-like
|
64
|
+
behavior throughout
|
65
|
+
* encoding: Content-Type charset response headers are used to automatically set
|
66
|
+
the encoding of the response string
|
67
|
+
* HTTP params: handling of GET/POST params is more consistent and sophisticated
|
68
|
+
for deeply nested hash objects, and `ParamsArray` can be used to pass ordered
|
69
|
+
params
|
70
|
+
* improved proxy support with per-request proxy configuration, plus the ability
|
71
|
+
to disable proxies set by environment variables
|
72
|
+
* default request headers: rest-client sets `Accept: */*` and
|
73
|
+
`User-Agent: rest-client/...`
|
74
|
+
|
75
|
+
See [history.md](./history.md) for a more complete description of changes.
|
76
|
+
|
77
|
+
## Usage: Raw URL
|
78
|
+
```ruby
|
79
|
+
require 'rest-client'
|
80
|
+
|
81
|
+
RestClient.get 'http://example.com/resource'
|
82
|
+
|
83
|
+
RestClient.get 'http://example.com/resource', {:params => {:id => 50, 'foo' => 'bar'}}
|
84
|
+
|
85
|
+
RestClient.get 'https://user:password@example.com/private/resource', {:accept => :json}
|
86
|
+
|
87
|
+
RestClient.post 'http://example.com/resource', :param1 => 'one', :nested => { :param2 => 'two' }
|
88
|
+
|
89
|
+
RestClient.post "http://example.com/resource", { 'x' => 1 }.to_json, :content_type => :json, :accept => :json
|
90
|
+
|
91
|
+
RestClient.delete 'http://example.com/resource'
|
92
|
+
|
93
|
+
response = RestClient.get 'http://example.com/resource'
|
94
|
+
response.code
|
95
|
+
➔ 200
|
96
|
+
response.cookies
|
97
|
+
➔ {"Foo"=>"BAR", "QUUX"=>"QUUUUX"}
|
98
|
+
response.headers
|
99
|
+
➔ {:content_type=>"text/html; charset=utf-8", :cache_control=>"private" ...
|
100
|
+
response.to_str
|
101
|
+
➔ \n<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\"\n \"http://www.w3.org/TR/html4/strict.dtd\">\n\n<html ....
|
102
|
+
|
103
|
+
RestClient.post( url,
|
104
|
+
{
|
105
|
+
:transfer => {
|
106
|
+
:path => '/foo/bar',
|
107
|
+
:owner => 'that_guy',
|
108
|
+
:group => 'those_guys'
|
109
|
+
},
|
110
|
+
:upload => {
|
111
|
+
:file => File.new(path, 'rb')
|
112
|
+
}
|
113
|
+
})
|
114
|
+
```
|
115
|
+
## Passing advanced options
|
116
|
+
|
117
|
+
The top level helper methods like RestClient.get accept a headers hash as
|
118
|
+
their last argument and don't allow passing more complex options. But these
|
119
|
+
helpers are just thin wrappers around `RestClient::Request.execute`.
|
120
|
+
|
121
|
+
```ruby
|
122
|
+
RestClient::Request.execute(method: :get, url: 'http://example.com/resource',
|
123
|
+
timeout: 10)
|
124
|
+
|
125
|
+
RestClient::Request.execute(method: :get, url: 'http://example.com/resource',
|
126
|
+
ssl_ca_file: 'myca.pem',
|
127
|
+
ssl_ciphers: 'AESGCM:!aNULL')
|
128
|
+
```
|
129
|
+
You can also use this to pass a payload for HTTP verbs like DELETE, where the
|
130
|
+
`RestClient.delete` helper doesn't accept a payload.
|
131
|
+
|
132
|
+
```ruby
|
133
|
+
RestClient::Request.execute(method: :delete, url: 'http://example.com/resource',
|
134
|
+
payload: 'foo', headers: {myheader: 'bar'})
|
135
|
+
```
|
136
|
+
|
137
|
+
Due to unfortunate choices in the original API, the params used to populate the
|
138
|
+
query string are actually taken out of the headers hash. So if you want to pass
|
139
|
+
both the params hash and more complex options, use the special key
|
140
|
+
`:params` in the headers hash. This design may change in a future major
|
141
|
+
release.
|
142
|
+
|
143
|
+
```ruby
|
144
|
+
RestClient::Request.execute(method: :get, url: 'http://example.com/resource',
|
145
|
+
timeout: 10, headers: {params: {foo: 'bar'}})
|
146
|
+
|
147
|
+
➔ GET http://example.com/resource?foo=bar
|
148
|
+
```
|
149
|
+
|
150
|
+
## Multipart
|
151
|
+
|
152
|
+
Yeah, that's right! This does multipart sends for you!
|
153
|
+
|
154
|
+
```ruby
|
155
|
+
RestClient.post '/data', :myfile => File.new("/path/to/image.jpg", 'rb')
|
156
|
+
```
|
157
|
+
|
158
|
+
This does two things for you:
|
159
|
+
|
160
|
+
- Auto-detects that you have a File value sends it as multipart
|
161
|
+
- Auto-detects the mime of the file and sets it in the HEAD of the payload for each entry
|
162
|
+
|
163
|
+
If you are sending params that do not contain a File object but the payload needs to be multipart then:
|
164
|
+
|
165
|
+
```ruby
|
166
|
+
RestClient.post '/data', {:foo => 'bar', :multipart => true}
|
167
|
+
```
|
168
|
+
|
169
|
+
## Usage: ActiveResource-Style
|
170
|
+
|
171
|
+
```ruby
|
172
|
+
resource = RestClient::Resource.new 'http://example.com/resource'
|
173
|
+
resource.get
|
174
|
+
|
175
|
+
private_resource = RestClient::Resource.new 'https://example.com/private/resource', 'user', 'pass'
|
176
|
+
private_resource.put File.read('pic.jpg'), :content_type => 'image/jpg'
|
177
|
+
```
|
178
|
+
|
179
|
+
See RestClient::Resource module docs for details.
|
180
|
+
|
181
|
+
## Usage: Resource Nesting
|
182
|
+
|
183
|
+
```ruby
|
184
|
+
site = RestClient::Resource.new('http://example.com')
|
185
|
+
site['posts/1/comments'].post 'Good article.', :content_type => 'text/plain'
|
186
|
+
```
|
187
|
+
See `RestClient::Resource` docs for details.
|
188
|
+
|
189
|
+
## Exceptions (see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html)
|
190
|
+
|
191
|
+
- for result codes between `200` and `207`, a `RestClient::Response` will be returned
|
192
|
+
- for result codes `301`, `302` or `307`, the redirection will be followed if the request is a `GET` or a `HEAD`
|
193
|
+
- for result code `303`, the redirection will be followed and the request transformed into a `GET`
|
194
|
+
- for other cases, a `RestClient::Exception` holding the Response will be raised; a specific exception class will be thrown for known error codes
|
195
|
+
- call `.response` on the exception to get the server's response
|
196
|
+
|
197
|
+
```ruby
|
198
|
+
RestClient.get 'http://example.com/resource'
|
199
|
+
➔ RestClient::ResourceNotFound: RestClient::ResourceNotFound
|
200
|
+
|
201
|
+
begin
|
202
|
+
RestClient.get 'http://example.com/resource'
|
203
|
+
rescue => e
|
204
|
+
e.response
|
205
|
+
end
|
206
|
+
➔ 404 Resource Not Found | text/html 282 bytes
|
207
|
+
```
|
208
|
+
|
209
|
+
### Redirection
|
210
|
+
|
211
|
+
By default, rest-client will follow HTTP 30x redirection requests.
|
212
|
+
|
213
|
+
__New in 2.0:__ `RestClient::Response` exposes a `#history` method that returns
|
214
|
+
a list of each response received in a redirection chain.
|
215
|
+
|
216
|
+
```ruby
|
217
|
+
>> r = RestClient.get('http://httpbin.org/redirect/2')
|
218
|
+
=> <RestClient::Response 200 "{\n \"args\":...">
|
219
|
+
|
220
|
+
# see each response in the redirect chain
|
221
|
+
>> r.history
|
222
|
+
=> [<RestClient::Response 302 "<!DOCTYPE H...">, <RestClient::Response 302 "">]
|
223
|
+
|
224
|
+
# see each requested URL
|
225
|
+
>> r.request.url
|
226
|
+
=> "http://httpbin.org/get"
|
227
|
+
>> r.history.map {|x| x.request.url}
|
228
|
+
=> ["http://httpbin.org/redirect/2", "http://httpbin.org/relative-redirect/1"]
|
229
|
+
```
|
230
|
+
|
231
|
+
#### Manually following redirection
|
232
|
+
|
233
|
+
To disable automatic redirection, set `:max_redirects => 0`.
|
234
|
+
|
235
|
+
__New in 2.0:__ Prior versions of rest-client would raise
|
236
|
+
`RestClient::MaxRedirectsReached`, with no easy way to access the server's
|
237
|
+
response. In 2.0, rest-client raises the normal
|
238
|
+
`RestClient::ExceptionWithResponse` as it would with any other non-HTTP-20x
|
239
|
+
response.
|
240
|
+
|
241
|
+
```ruby
|
242
|
+
>> RestClient::Request.execute(method: :get, url: 'http://httpbin.org/redirect/1')
|
243
|
+
=> RestClient::Response 200 "{\n "args":..."
|
244
|
+
|
245
|
+
>> RestClient::Request.execute(method: :get, url: 'http://httpbin.org/redirect/1', max_redirects: 0)
|
246
|
+
RestClient::Found: 302 Found
|
247
|
+
```
|
248
|
+
|
249
|
+
To manually follow redirection, you can call `Response#follow_redirection`. Or
|
250
|
+
you could of course inspect the result and choose custom behavior.
|
251
|
+
|
252
|
+
```ruby
|
253
|
+
>> RestClient::Request.execute(method: :get, url: 'http://httpbin.org/redirect/1', max_redirects: 0)
|
254
|
+
RestClient::Found: 302 Found
|
255
|
+
>> begin
|
256
|
+
RestClient::Request.execute(method: :get, url: 'http://httpbin.org/redirect/1', max_redirects: 0)
|
257
|
+
rescue RestClient::ExceptionWithResponse => err
|
258
|
+
end
|
259
|
+
>> err
|
260
|
+
=> #<RestClient::Found: 302 Found>
|
261
|
+
>> err.response
|
262
|
+
=> RestClient::Response 302 "<!DOCTYPE H..."
|
263
|
+
>> err.response.headers[:location]
|
264
|
+
=> "/get"
|
265
|
+
>> err.response.follow_redirection
|
266
|
+
=> RestClient::Response 200 "{\n "args":..."
|
267
|
+
```
|
268
|
+
|
269
|
+
## Result handling
|
270
|
+
|
271
|
+
The result of a `RestClient::Request` is a `RestClient::Response` object.
|
272
|
+
|
273
|
+
__New in 2.0:__ `RestClient::Response` objects are now a subclass of `String`.
|
274
|
+
Previously, they were a real String object with response functionality mixed
|
275
|
+
in, which was very confusing to work with.
|
276
|
+
|
277
|
+
Response objects have several useful methods. (See the class rdoc for more details.)
|
278
|
+
|
279
|
+
- `Response#code`: The HTTP response code
|
280
|
+
- `Response#body`: The response body as a string. (AKA .to_s)
|
281
|
+
- `Response#headers`: A hash of HTTP response headers
|
282
|
+
- `Response#raw_headers`: A hash of HTTP response headers as unprocessed arrays
|
283
|
+
- `Response#cookies`: A hash of HTTP cookies set by the server
|
284
|
+
- `Response#cookie_jar`: <em>New in 1.8</em> An HTTP::CookieJar of cookies
|
285
|
+
- `Response#request`: The RestClient::Request object used to make the request
|
286
|
+
- `Response#history`: <em>New in 2.0</em> If redirection was followed, a list of prior Response objects
|
287
|
+
|
288
|
+
```ruby
|
289
|
+
RestClient.get('http://example.com')
|
290
|
+
➔ <RestClient::Response 200 "<!doctype h...">
|
291
|
+
|
292
|
+
begin
|
293
|
+
RestClient.get('http://example.com/notfound')
|
294
|
+
rescue RestClient::ExceptionWithResponse => err
|
295
|
+
err.response
|
296
|
+
end
|
297
|
+
➔ <RestClient::Response 404 "<!doctype h...">
|
298
|
+
```
|
299
|
+
|
300
|
+
### Response callbacks
|
301
|
+
|
302
|
+
A block can be passed to the RestClient method. This block will then be called with the Response.
|
303
|
+
Response.return! can be called to invoke the default response's behavior.
|
304
|
+
|
305
|
+
```ruby
|
306
|
+
# Don't raise exceptions but return the response
|
307
|
+
RestClient.get('http://example.com/resource'){|response, request, result| response }
|
308
|
+
➔ 404 Resource Not Found | text/html 282 bytes
|
309
|
+
|
310
|
+
# Manage a specific error code
|
311
|
+
RestClient.get('http://my-rest-service.com/resource'){ |response, request, result, &block|
|
312
|
+
case response.code
|
313
|
+
when 200
|
314
|
+
p "It worked !"
|
315
|
+
response
|
316
|
+
when 423
|
317
|
+
raise SomeCustomExceptionIfYouWant
|
318
|
+
else
|
319
|
+
response.return!(request, result, &block)
|
320
|
+
end
|
321
|
+
}
|
322
|
+
|
323
|
+
# Follow redirections for all request types and not only for get and head
|
324
|
+
# RFC : "If the 301, 302 or 307 status code is received in response to a request other than GET or HEAD,
|
325
|
+
# the user agent MUST NOT automatically redirect the request unless it can be confirmed by the user,
|
326
|
+
# since this might change the conditions under which the request was issued."
|
327
|
+
RestClient.get('http://my-rest-service.com/resource'){ |response, request, result, &block|
|
328
|
+
if [301, 302, 307].include? response.code
|
329
|
+
response.follow_redirection(request, result, &block)
|
330
|
+
else
|
331
|
+
response.return!(request, result, &block)
|
332
|
+
end
|
333
|
+
}
|
334
|
+
```
|
335
|
+
## Non-normalized URIs
|
336
|
+
|
337
|
+
If you need to normalize URIs, e.g. to work with International Resource Identifiers (IRIs),
|
338
|
+
use the addressable gem (http://addressable.rubyforge.org/api/) in your code:
|
339
|
+
|
340
|
+
```ruby
|
341
|
+
require 'addressable/uri'
|
342
|
+
RestClient.get(Addressable::URI.parse("http://www.詹姆斯.com/").normalize.to_str)
|
343
|
+
```
|
344
|
+
|
345
|
+
## Lower-level access
|
346
|
+
|
347
|
+
For cases not covered by the general API, you can use the `RestClient::Request` class, which provides a lower-level API.
|
348
|
+
|
349
|
+
You can:
|
350
|
+
|
351
|
+
- specify ssl parameters
|
352
|
+
- override cookies
|
353
|
+
- manually handle the response (e.g. to operate on it as a stream rather than reading it all into memory)
|
354
|
+
|
355
|
+
See `RestClient::Request`'s documentation for more information.
|
356
|
+
|
357
|
+
## Shell
|
358
|
+
|
359
|
+
The restclient shell command gives an IRB session with RestClient already loaded:
|
360
|
+
|
361
|
+
```ruby
|
362
|
+
$ restclient
|
363
|
+
>> RestClient.get 'http://example.com'
|
364
|
+
```
|
365
|
+
|
366
|
+
Specify a URL argument for get/post/put/delete on that resource:
|
367
|
+
|
368
|
+
```ruby
|
369
|
+
$ restclient http://example.com
|
370
|
+
>> put '/resource', 'data'
|
371
|
+
```
|
372
|
+
|
373
|
+
Add a user and password for authenticated resources:
|
374
|
+
|
375
|
+
```ruby
|
376
|
+
$ restclient https://example.com user pass
|
377
|
+
>> delete '/private/resource'
|
378
|
+
```
|
379
|
+
|
380
|
+
Create ~/.restclient for named sessions:
|
381
|
+
|
382
|
+
```ruby
|
383
|
+
sinatra:
|
384
|
+
url: http://localhost:4567
|
385
|
+
rack:
|
386
|
+
url: http://localhost:9292
|
387
|
+
private_site:
|
388
|
+
url: http://example.com
|
389
|
+
username: user
|
390
|
+
password: pass
|
391
|
+
```
|
392
|
+
|
393
|
+
Then invoke:
|
394
|
+
|
395
|
+
```ruby
|
396
|
+
$ restclient private_site
|
397
|
+
```
|
398
|
+
|
399
|
+
Use as a one-off, curl-style:
|
400
|
+
|
401
|
+
```ruby
|
402
|
+
$ restclient get http://example.com/resource > output_body
|
403
|
+
|
404
|
+
$ restclient put http://example.com/resource < input_body
|
405
|
+
```
|
406
|
+
|
407
|
+
## Logging
|
408
|
+
|
409
|
+
To enable logging you can:
|
410
|
+
|
411
|
+
- set RestClient.log with a Ruby Logger, or
|
412
|
+
- set an environment variable to avoid modifying the code (in this case you can use a file name, "stdout" or "stderr"):
|
413
|
+
|
414
|
+
```ruby
|
415
|
+
$ RESTCLIENT_LOG=stdout path/to/my/program
|
416
|
+
```
|
417
|
+
Either produces logs like this:
|
418
|
+
|
419
|
+
```ruby
|
420
|
+
RestClient.get "http://some/resource"
|
421
|
+
# => 200 OK | text/html 250 bytes
|
422
|
+
RestClient.put "http://some/resource", "payload"
|
423
|
+
# => 401 Unauthorized | application/xml 340 bytes
|
424
|
+
```
|
425
|
+
|
426
|
+
Note that these logs are valid Ruby, so you can paste them into the `restclient`
|
427
|
+
shell or a script to replay your sequence of rest calls.
|
428
|
+
|
429
|
+
## Proxy
|
430
|
+
|
431
|
+
All calls to RestClient, including Resources, will use the proxy specified by
|
432
|
+
`RestClient.proxy`:
|
433
|
+
|
434
|
+
```ruby
|
435
|
+
RestClient.proxy = "http://proxy.example.com/"
|
436
|
+
RestClient.get "http://some/resource"
|
437
|
+
# => response from some/resource as proxied through proxy.example.com
|
438
|
+
```
|
439
|
+
|
440
|
+
Often the proxy URL is set in an environment variable, so you can do this to
|
441
|
+
use whatever proxy the system is configured to use:
|
442
|
+
|
443
|
+
```ruby
|
444
|
+
RestClient.proxy = ENV['http_proxy']
|
445
|
+
```
|
446
|
+
|
447
|
+
__New in 2.0:__ Specify a per-request proxy by passing the :proxy option to
|
448
|
+
RestClient::Request. This will override any proxies set by environment variable
|
449
|
+
or by the global `RestClient.proxy` value.
|
450
|
+
|
451
|
+
```ruby
|
452
|
+
RestClient::Request.execute(method: :get, url: 'http://example.com',
|
453
|
+
proxy: 'http://proxy.example.com')
|
454
|
+
# => single request proxied through the proxy
|
455
|
+
```
|
456
|
+
|
457
|
+
This can be used to disable the use of a proxy for a particular request.
|
458
|
+
|
459
|
+
```ruby
|
460
|
+
RestClient.proxy = "http://proxy.example.com/"
|
461
|
+
RestClient::Request.execute(method: :get, url: 'http://example.com', proxy: nil)
|
462
|
+
# => single request sent without a proxy
|
463
|
+
```
|
464
|
+
|
465
|
+
## Query parameters
|
466
|
+
|
467
|
+
Rest-client can render a hash as HTTP query parameters for GET/HEAD/DELETE
|
468
|
+
requests or as HTTP post data in `x-www-form-urlencoded` format for POST
|
469
|
+
requests.
|
470
|
+
|
471
|
+
__New in 2.0:__ Even though there is no standard specifying how this should
|
472
|
+
work, rest-client follows a similar convention to the one used by Rack / Rails
|
473
|
+
servers for handling arrays, nested hashes, and null values.
|
474
|
+
|
475
|
+
The implementation in
|
476
|
+
[./lib/rest-client/utils.rb](RestClient::Utils.encode_query_string)
|
477
|
+
closely follows
|
478
|
+
[Rack::Utils.build_nested_query](http://www.rubydoc.info/gems/rack/Rack/Utils#build_nested_query-class_method),
|
479
|
+
but treats empty arrays and hashes as `nil`. (Rack drops them entirely, which
|
480
|
+
is confusing behavior.)
|
481
|
+
|
482
|
+
If you don't like this behavior and want more control, just serialize params
|
483
|
+
yourself (e.g. with `URI.encode_www_form`) and add the query string to the URL
|
484
|
+
directly for GET parameters or pass the payload as a string for POST requests.
|
485
|
+
|
486
|
+
Basic GET params:
|
487
|
+
```ruby
|
488
|
+
RestClient.get('https://httpbin.org/get', params: {foo: 'bar', baz: 'qux'})
|
489
|
+
# GET "https://httpbin.org/get?foo=bar&baz=qux"
|
490
|
+
```
|
491
|
+
|
492
|
+
Basic `x-www-form-urlencoded` POST params:
|
493
|
+
```ruby
|
494
|
+
>> r = RestClient.post('https://httpbin.org/post', {foo: 'bar', baz: 'qux'})
|
495
|
+
# POST "https://httpbin.org/post", data: "foo=bar&baz=qux"
|
496
|
+
=> <RestClient::Response 200 "{\n \"args\":...">
|
497
|
+
>> JSON.parse(r.body)
|
498
|
+
=> {"args"=>{},
|
499
|
+
"data"=>"",
|
500
|
+
"files"=>{},
|
501
|
+
"form"=>{"baz"=>"qux", "foo"=>"bar"},
|
502
|
+
"headers"=>
|
503
|
+
{"Accept"=>"*/*",
|
504
|
+
"Accept-Encoding"=>"gzip, deflate",
|
505
|
+
"Content-Length"=>"15",
|
506
|
+
"Content-Type"=>"application/x-www-form-urlencoded",
|
507
|
+
"Host"=>"httpbin.org"},
|
508
|
+
"json"=>nil,
|
509
|
+
"url"=>"https://httpbin.org/post"}
|
510
|
+
```
|
511
|
+
|
512
|
+
Advanced GET params (arrays):
|
513
|
+
```ruby
|
514
|
+
>> r = RestClient.get('https://http-params.herokuapp.com/get', params: {foo: [1,2,3]})
|
515
|
+
# GET "https://http-params.herokuapp.com/get?foo[]=1&foo[]=2&foo[]=3"
|
516
|
+
=> <RestClient::Response 200 "Method: GET...">
|
517
|
+
>> puts r.body
|
518
|
+
query_string: "foo[]=1&foo[]=2&foo[]=3"
|
519
|
+
decoded: "foo[]=1&foo[]=2&foo[]=3"
|
520
|
+
|
521
|
+
GET:
|
522
|
+
{"foo"=>["1", "2", "3"]}
|
523
|
+
```
|
524
|
+
|
525
|
+
Advanced GET params (nested hashes):
|
526
|
+
```ruby
|
527
|
+
>> r = RestClient.get('https://http-params.herokuapp.com/get', params: {outer: {foo: 123, bar: 456}})
|
528
|
+
# GET "https://http-params.herokuapp.com/get?outer[foo]=123&outer[bar]=456"
|
529
|
+
=> <RestClient::Response 200 "Method: GET...">
|
530
|
+
>> puts r.body
|
531
|
+
...
|
532
|
+
query_string: "outer[foo]=123&outer[bar]=456"
|
533
|
+
decoded: "outer[foo]=123&outer[bar]=456"
|
534
|
+
|
535
|
+
GET:
|
536
|
+
{"outer"=>{"foo"=>"123", "bar"=>"456"}}
|
537
|
+
```
|
538
|
+
|
539
|
+
__New in 2.0:__ The new `RestClient::ParamsArray` class allows callers to
|
540
|
+
provide ordering even to structured parameters. This is useful for unusual
|
541
|
+
cases where the server treats the order of parameters as significant or you
|
542
|
+
want to pass a particular key multiple times.
|
543
|
+
|
544
|
+
Multiple fields with the same name using ParamsArray:
|
545
|
+
```ruby
|
546
|
+
>> RestClient.get('https://httpbin.org/get', params:
|
547
|
+
RestClient::ParamsArray.new([[:foo, 1], [:foo, 2]]))
|
548
|
+
# GET "https://httpbin.org/get?foo=1&foo=2"
|
549
|
+
```
|
550
|
+
|
551
|
+
Nested ParamsArray:
|
552
|
+
```ruby
|
553
|
+
>> RestClient.get('https://httpbin.org/get', params:
|
554
|
+
{foo: RestClient::ParamsArray.new([[:a, 1], [:a, 2]])})
|
555
|
+
# GET "https://httpbin.org/get?foo[a]=1&foo[a]=2"
|
556
|
+
```
|
557
|
+
|
558
|
+
## Headers
|
559
|
+
|
560
|
+
Request headers can be set by passing a ruby hash containing keys and values
|
561
|
+
representing header names and values:
|
562
|
+
|
563
|
+
```ruby
|
564
|
+
# GET request with modified headers
|
565
|
+
RestClient.get 'http://example.com/resource', {:Authorization => 'Bearer cT0febFoD5lxAlNAXHo6g'}
|
566
|
+
|
567
|
+
# POST request with modified headers
|
568
|
+
RestClient.post 'http://example.com/resource', {:foo => 'bar', :baz => 'qux'}, {:Authorization => 'Bearer cT0febFoD5lxAlNAXHo6g'}
|
569
|
+
|
570
|
+
# DELETE request with modified headers
|
571
|
+
RestClient.delete 'http://example.com/resource', {:Authorization => 'Bearer cT0febFoD5lxAlNAXHo6g'}
|
572
|
+
```
|
573
|
+
|
574
|
+
## Cookies
|
575
|
+
|
576
|
+
Request and Response objects know about HTTP cookies, and will automatically
|
577
|
+
extract and set headers for them as needed:
|
578
|
+
|
579
|
+
```ruby
|
580
|
+
response = RestClient.get 'http://example.com/action_which_sets_session_id'
|
581
|
+
response.cookies
|
582
|
+
# => {"_applicatioN_session_id" => "1234"}
|
583
|
+
|
584
|
+
response2 = RestClient.post(
|
585
|
+
'http://localhost:3000/',
|
586
|
+
{:param1 => "foo"},
|
587
|
+
{:cookies => {:session_id => "1234"}}
|
588
|
+
)
|
589
|
+
# ...response body
|
590
|
+
```
|
591
|
+
### Full cookie jar support (new in 1.8)
|
592
|
+
|
593
|
+
The original cookie implementation was very naive and ignored most of the
|
594
|
+
cookie RFC standards.
|
595
|
+
__New in 1.8__: An HTTP::CookieJar of cookies
|
596
|
+
|
597
|
+
Response objects now carry a cookie_jar method that exposes an HTTP::CookieJar
|
598
|
+
of cookies, which supports full standards compliant behavior.
|
599
|
+
|
600
|
+
## SSL/TLS support
|
601
|
+
|
602
|
+
Various options are supported for configuring rest-client's TLS settings. By
|
603
|
+
default, rest-client will verify certificates using the system's CA store on
|
604
|
+
all platforms. (This is intended to be similar to how browsers behave.) You can
|
605
|
+
specify an :ssl_ca_file, :ssl_ca_path, or :ssl_cert_store to customize the
|
606
|
+
certificate authorities accepted.
|
607
|
+
|
608
|
+
### SSL Client Certificates
|
609
|
+
|
610
|
+
```ruby
|
611
|
+
RestClient::Resource.new(
|
612
|
+
'https://example.com',
|
613
|
+
:ssl_client_cert => OpenSSL::X509::Certificate.new(File.read("cert.pem")),
|
614
|
+
:ssl_client_key => OpenSSL::PKey::RSA.new(File.read("key.pem"), "passphrase, if any"),
|
615
|
+
:ssl_ca_file => "ca_certificate.pem",
|
616
|
+
:verify_ssl => OpenSSL::SSL::VERIFY_PEER
|
617
|
+
).get
|
618
|
+
```
|
619
|
+
Self-signed certificates can be generated with the openssl command-line tool.
|
620
|
+
|
621
|
+
## Hook
|
622
|
+
|
623
|
+
RestClient.add_before_execution_proc add a Proc to be called before each execution.
|
624
|
+
It's handy if you need direct access to the HTTP request.
|
625
|
+
|
626
|
+
Example:
|
627
|
+
|
628
|
+
```ruby
|
629
|
+
# Add oauth support using the oauth gem
|
630
|
+
require 'oauth'
|
631
|
+
access_token = ...
|
632
|
+
|
633
|
+
RestClient.add_before_execution_proc do |req, params|
|
634
|
+
access_token.sign! req
|
635
|
+
end
|
636
|
+
|
637
|
+
RestClient.get 'http://example.com'
|
638
|
+
```
|
639
|
+
|
640
|
+
## More
|
641
|
+
|
642
|
+
Need caching, more advanced logging or any ability provided by Rack middleware?
|
643
|
+
|
644
|
+
Have a look at rest-client-components: http://github.com/crohr/rest-client-components
|
645
|
+
|
646
|
+
## Credits
|
647
|
+
|
648
|
+
|||
|
649
|
+
|---------------------|---------------------------------------------------------|
|
650
|
+
| REST Client Team | Andy Brody |
|
651
|
+
| Creator | Adam Wiggins |
|
652
|
+
| Maintainers Emeriti | Lawrence Leonard Gilbert, Matthew Manning, Julien Kirch |
|
653
|
+
| Major contributions | Blake Mizerany, Julien Kirch |
|
654
|
+
|
655
|
+
A great many generous folks have contributed features and patches.
|
656
|
+
See AUTHORS for the full list.
|
657
|
+
|
658
|
+
## Legal
|
659
|
+
|
660
|
+
Released under the MIT License: http://www.opensource.org/licenses/mit-license.php
|
661
|
+
|
662
|
+
"Master Shake" photo (http://www.flickr.com/photos/solgrundy/924205581/) by
|
663
|
+
"SolGrundy"; used under terms of the Creative Commons Attribution-ShareAlike 2.0
|
664
|
+
Generic license (http://creativecommons.org/licenses/by-sa/2.0/)
|
665
|
+
|
666
|
+
Code for reading Windows root certificate store derived from work by Puppet;
|
667
|
+
used under terms of the Apache License, Version 2.0.
|