Skip to content

Commit

Permalink
Updated the SSL-variant of the Client to match the changes to the hea…
Browse files Browse the repository at this point in the history
…ders.
  • Loading branch information
mtodd committed May 16, 2008
1 parent 1890eb9 commit aa8e9b8
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions lib/halcyon/client/ssl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,20 @@ def request(req, headers={})
req["User-Agent"] = USER_AGENT

# apply provided headers
headers.each do |(header, value)|
self.headers.merge(headers).each do |(header, value)|
req[header] = value
end

# provide hook for modifying the headers
req = headers(req) if respond_to? :headers

# prepare and send HTTPS request
serv = Net::HTTP.new(@uri.host, @uri.port)
serv.use_ssl = true if @uri.scheme == 'https'
serv = Net::HTTP.new(self.uri.host, self.uri.port)
serv.use_ssl = true if self.uri.scheme == 'https'
res = serv.start {|http|http.request(req)}

# parse response
body = JSON.parse(res.body).to_mash

# handle non-successes
if @options[:raise_exceptions] && !res.kind_of?(Net::HTTPSuccess)
if self.options[:raise_exceptions] && !res.kind_of?(Net::HTTPSuccess)
raise self.class.const_get(Exceptions::HTTP_STATUS_CODES[body[:status]].tr(' ', '_').camel_case.gsub(/( |\-)/,'')).new
end

Expand Down

0 comments on commit aa8e9b8

Please sign in to comment.