Module: Torznab::Client::Http

Defined in:
lib/torznab/client/http.rb

Overview

HTTP calls handling

Constant Summary collapse

API_PATH =

API Prefix for torznab

'/api'.freeze

Class Method Summary collapse

Class Method Details

.get(url, params = nil) ⇒ String

Do a GET request

Parameters:

  • url (String)

    Resource to fetch

  • params (Hash) (defaults to: nil)

    GET Parameters in a key/value form

Returns:

  • (String)

    Contents of the provided url

Raises:

  • (SchemeError)

    If the URL don't begin with http or https

  • (HttpError)

    If the status code is not 2XX


18
19
20
21
22
23
24
# File 'lib/torznab/client/http.rb', line 18

def get(url, params = nil)
  uri = create_uri url, params
  http = create_http uri
  get_request = Net::HTTP::Get.new uri
  response = http.request get_request
  process_response response
end