Skip to content
This repository was archived by the owner on Sep 17, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
PATH
remote: .
specs:
zephyr (1.2.2)
zephyr (1.2.3)
typhoeus (~> 0.4.2)
yajl-ruby

GEM
remote: http://rubygems.org/
specs:
ffi (1.7.0)
ffi (1.9.0)
git (1.2.5)
jeweler (1.6.4)
bundler (~> 1.0)
git (>= 1.2.5)
rake
metaclass (0.0.1)
mime-types (1.22)
mime-types (1.23)
mocha (0.12.0)
metaclass (~> 0.0.1)
rake (0.9.2.2)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ unfortunate choice of naming our library Http and suddenly fighting with http_pa
* Ryan Kennedy
* Vidit Drolia
* Vivek Aggarwal
* Sean Wolfe

### References

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2.2
1.2.3
17 changes: 17 additions & 0 deletions lib/zephyr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,20 @@ def uri(given_parts = [])
end
end

# Configure SSL parameters that will be passed on to Typhoeus.
#
# Example:
# http = Zephyr.new 'http://host/'
# http.ssl(:ssl_cacert => "ca_file.cer",
# :ssl_cert => "acert.crt",
# :ssl_key => "akey.key")
#
def ssl(ssl_params)
raise ArgumentError, "ssl_params must be a hash" unless ssl_params.is_a? Hash
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why so defensive?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not? It allows anyone looking at the source to know that the argument should be a Hash. If you think it's useless, then I can cut it. Maybe I've been hanging out with too many static language users.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have the method nicely documented above. Not only does it mention it's a Hash, but it mentions the accepted keys.

@ssl_params = ssl_params
end


# Comes handy in IRB
#
def inspect
Expand Down Expand Up @@ -309,6 +323,9 @@ def perform(method, path_components, headers, expect, timeout, data=nil)
params[:body] = data if data != ''
end

# add the ssl_params if there are any.
params.merge!(@ssl_params) unless @ssl_params.nil? || @ssl_params.empty?

http_start = Time.now.to_f
response = Typhoeus::Request.run(uri(path_components).to_s, params)
http_end = Time.now.to_f
Expand Down
15 changes: 15 additions & 0 deletions test/test_zephyr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,19 @@ class TestZephyr < Test::Unit::TestCase
end.returns(TYPHOEUS_RESPONSE)
z.custom(:purge, 200, 1, ["images", "4271e4c1594adc92651cf431029429d8"])
end

should 'support ssl certificates' do
z = Zephyr.new('http://www.example.com')
z.ssl(:ssl_cacert => 'ca_file.cer', :ssl_cert => 'acert.crt', :ssl_key => 'akey.key')

Typhoeus::Request.expects(:run).with do |uri, params|
params[:ssl_cacert] == 'ca_file.cer' &&
params[:ssl_cert] == 'acert.crt' &&
params[:ssl_key] == 'akey.key' &&
params[:method] == :get &&
uri == 'http://www.example.com/users/1'
end.returns(TYPHOEUS_RESPONSE)

z.get(200, 1, ['users', '1'])
end
end
2 changes: 1 addition & 1 deletion zephyr.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Gem::Specification.new do |s|
s.name = "zephyr"
s.version = "1.2.2"
s.version = "1.2.3"

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Matt Knopp"]
Expand Down