Skip to content

Commit

Permalink
ssl_version option is only available in Ruby 1.9.
Browse files Browse the repository at this point in the history
  • Loading branch information
htanata committed Aug 20, 2012
1 parent c2cf65f commit 6b88a95
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/httparty.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/httparty/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion spec/httparty/request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6b88a95

Please sign in to comment.