From 6b88a95a4054b6116f2376130a58c96d6710ae5b Mon Sep 17 00:00:00 2001 From: Hendy Tanata Date: Mon, 20 Aug 2012 22:06:15 +0800 Subject: [PATCH] ssl_version option is only available in Ruby 1.9. --- lib/httparty.rb | 2 +- lib/httparty/request.rb | 2 +- spec/httparty/request_spec.rb | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/httparty.rb b/lib/httparty.rb index 1476f313..3d0b466e 100644 --- a/lib/httparty.rb +++ b/lib/httparty.rb @@ -296,7 +296,7 @@ def query_string_normalizer(normalizer) default_options[:query_string_normalizer] = normalizer end - # Allows setting of SSL version to use. + # Allows setting of SSL version to use. This only works in Ruby 1.9. # You can get a list of valid versions from OpenSSL::SSL::SSLContext::METHODS. # # class Foo diff --git a/lib/httparty/request.rb b/lib/httparty/request.rb index 6ec2080b..47008f96 100644 --- a/lib/httparty/request.rb +++ b/lib/httparty/request.rb @@ -114,7 +114,7 @@ def attach_ssl_certificates(http) http.verify_mode = OpenSSL::SSL::VERIFY_PEER end - if options[:ssl_version] + if options[:ssl_version] && http.respond_to?(:ssl_version=) http.ssl_version = options[:ssl_version] end end diff --git a/spec/httparty/request_spec.rb b/spec/httparty/request_spec.rb index 04201ebb..c3b8f289 100644 --- a/spec/httparty/request_spec.rb +++ b/spec/httparty/request_spec.rb @@ -167,7 +167,10 @@ it 'uses specified ssl_version' do request = HTTParty::Request.new(Net::HTTP::Get, 'https://foobar.com', :ssl_version => :TLSv1) - request.send(:http).ssl_version.should == :TLSv1 + http = request.send(:http) + if http.respond_to?(:ssl_version) + http.ssl_version.should == :TLSv1 + end end context "PEM certificates" do