class STAC::SimpleHTTPClient

Simple HTTP Client using OpenURI.

Attributes

options[R]

Public Class Methods

new(options = { 'User-Agent' => "stac-ruby v click to toggle source
# File lib/stac/simple_http_client.rb, line 16
def initialize(options = { 'User-Agent' => "stac-ruby v#{VERSION}" })
  @options = options
end

Public Instance Methods

get(url) click to toggle source

Makes a HTTP request and returns the responded JSON as Hash.

Raises STAC::HTTPError when the response status is not 2XX.

# File lib/stac/simple_http_client.rb, line 23
def get(url)
  body = URI(url).read(options)
  JSON.parse(body)
rescue OpenURI::HTTPError => e
  raise HTTPError, e.message
end