Module: HackEx::Network

Included in:
Request
Defined in:
lib/libGoo/hackex/net/std.rb,
lib/libGoo/hackex/net/typhoeus.rb

Instance Method Summary collapse

Instance Method Details

#Do(http, request) ⇒ Object



34
35
36
37
38
39
40
41
42
43
# File 'lib/libGoo/hackex/net/std.rb', line 34

def Do http, request
  response = http.request request
  if response.is_a? Net::HTTPOK
    json = JSON.parse(response.body)
    raise HackExError, "Not success: #{json}" unless json['success']
    json
  else
    raise HackExError, "Not OK: #{response.inspect}, #{response.body}"
  end
end

#NetworkDo(&proc) ⇒ Object



45
46
47
48
49
50
51
# File 'lib/libGoo/hackex/net/std.rb', line 45

def NetworkDo &proc
  uri_base = URI(HackEx::Request::URI_BASE)

  Net::HTTP.start(uri_base.host, uri_base.port, :use_ssl => true, :verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http|
    proc.call(http)
  end
end