Method: Hub::GitHubAPI::HttpMethods#perform_request

Defined in:
lib/hub/github_api.rb

#perform_request(url, type) ⇒ Object



153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/hub/github_api.rb', line 153

def perform_request url, type
  url = URI.parse url unless url.respond_to? :host

  require 'net/https'
  req = Net::HTTP.const_get(type).new(url.request_uri)
  # TODO: better naming?
  http = configure_connection(req, url) do |host_url|
    create_connection host_url
  end

  apply_authentication(req, url)
  yield req if block_given?
  res = http.start { http.request(req) }
  res.extend ResponseMethods
  res
rescue SocketError => err
  raise Context::FatalError, "error with #{type.to_s.upcase} #{url} (#{err.message})"
end