Skip to content

Commit

Permalink
Merge pull request #85 from maestrodev/ssl-ruby-1.8
Browse files Browse the repository at this point in the history
Support SSL on Ruby 1.8.7 / JRuby 1.6
  • Loading branch information
arangamani committed Jun 25, 2013
2 parents 11ca37b + 4eada86 commit 9814db1
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions lib/jenkins_api_client/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
require 'rubygems'
require 'json'
require 'net/http'
require 'net/https'
require 'nokogiri'
require 'base64'
require 'mixlib/shellout'
Expand Down Expand Up @@ -229,18 +230,26 @@ def inspect
def make_http_request(request, follow_redirect = @follow_redirects)
request.basic_auth @username, @password if @username

if @server_url
http = Net::HTTP.new(@server_uri.host, @server_uri.port)
http.use_ssl = true if @ssl
http.verify_mode = OpenSSL::SSL::VERIFY_NONE if @ssl
response = http.request(request)
if @server_uri
host = @server_uri.host
port = @server_uri.port
else
Net::HTTP.start(
@server_ip, @server_port, @proxy_ip, @proxy_port, :use_ssl => @ssl
) do |http|
response = http.request(request)
end
host = @server_ip
port = @server_port
end

if @proxy_ip
http = Net::HTTP::Proxy(@proxy_ip, @proxy_port).new(host, port)
else
http = Net::HTTP.new(host, port)
end

if @ssl
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
end

response = http.request(request)
case response
when Net::HTTPRedirection then
# If we got a redirect request, follow it (if flag set), but don't
Expand Down

0 comments on commit 9814db1

Please sign in to comment.