Permalink
Browse files

Add support for passing in ciphers information into the ConnectionAda…

…pter, and have this work as expected with the Net:HTTP ConnectionAdapter.
  • Loading branch information...
1 parent d392c2d commit e63ee15254310a1d4c8b78953216fd90b69a2e9e @kenmazaika kenmazaika committed Nov 30, 2012
Showing with 35 additions and 1 deletion.
  1. +14 −1 lib/httparty.rb
  2. +4 −0 lib/httparty/connection_adapter.rb
  3. +9 −0 spec/httparty/connection_adapter_spec.rb
  4. +8 −0 spec/httparty_spec.rb
View
@@ -299,7 +299,7 @@ def query_string_normalizer(normalizer)
default_options[:query_string_normalizer] = normalizer
end
- # Allows setting of SSL version to use. This only works in Ruby 1.9.
+ # 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
@@ -310,6 +310,19 @@ def ssl_version(version)
default_options[:ssl_version] = version
end
+ # Allows setting of SSL ciphers to use. This only works in Ruby 1.9+.
+ # You can get a list of valid specific ciphers from OpenSSL::Cipher.ciphers.
+ # You also can specify a cipher suite here, listed here at openssl.org:
+ # http://www.openssl.org/docs/apps/ciphers.html#CIPHER_SUITE_NAMES
+ #
+ # class Foo
+ # include HTTParty
+ # ciphers "RC4-SHA"
+ # end
+ def ciphers(cipher_names)
+ default_options[:ciphers] = cipher_names
+ end
+
# Allows setting an OpenSSL certificate authority file
#
# class Foo
@@ -76,6 +76,10 @@ def connection
http.set_debug_output(options[:debug_output])
end
+ if options[:ciphers]
+ http.ciphers = options[:ciphers]
+ end
+
return http
end
@@ -78,6 +78,7 @@
it { should use_ssl }
end
+
context "when ssl version is set" do
let(:options) { {:ssl_version => :TLSv1} }
@@ -87,6 +88,14 @@
end if RUBY_VERSION > '1.9'
end
+ context "specifying ciphers" do
+ let(:options) { {:ciphers => 'RC4-SHA' } }
+
+ it "should set the ciphers on the connection" do
+ subject.ciphers.should == 'RC4-SHA'
+ end
+ end if RUBY_VERSION > '1.9'
+
context "when timeout is not set" do
it "doesn't set the timeout" do
http = mock("http", :null_object => true)
@@ -45,6 +45,14 @@
end
end
+ describe 'ciphers' do
+ it 'should set the ciphers content' do
+ @klass.default_options[:ciphers].should be_nil
+ @klass.ciphers 'RC4-SHA'
+ @klass.default_options[:ciphers].should == 'RC4-SHA'
+ end
+ end
+
describe 'http_proxy' do
it 'should set the address' do
@klass.http_proxy 'proxy.foo.com', 80

0 comments on commit e63ee15

Please sign in to comment.