Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/museum/methods.rb

Instance Method Summary collapse

Instance Method Details

#fetch(headers = {}) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/museum/methods.rb', line 2

def fetch(headers = {})
  headers['User-Agent'] = 'GemVein Museum'
  require 'net/http'
  require 'net/https'

  uri = URI.parse(self)
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = (uri.scheme == "https")
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE

  request = Net::HTTP::Get.new(uri.request_uri, headers)

  response = http.request(request)
  response.body
end