Method: Hub::GitHubAPI::HttpMethods#create_connection

Defined in:
lib/hub/github_api.rb

#create_connection(url) ⇒ Object



189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
# File 'lib/hub/github_api.rb', line 189

def create_connection url
  use_ssl = 'https' == url.scheme

  proxy_args = []
  if proxy = config.proxy_uri(use_ssl)
    proxy_args << proxy.host << proxy.port
    if proxy.userinfo
      require 'cgi'
      # proxy user + password
      proxy_args.concat proxy.userinfo.split(':', 2).map {|a| CGI.unescape a }
    end
  end

  http = Net::HTTP.new(url.host, url.port, *proxy_args)

  if http.use_ssl = use_ssl
    # FIXME: enable SSL peer verification!
    http.verify_mode = OpenSSL::SSL::VERIFY_NONE
  end
  return http
end