Class: Geon::HttpLoader
- Inherits:
-
Object
- Object
- Geon::HttpLoader
- Defined in:
- lib/geon/http_loader.rb
Instance Method Summary collapse
- #get(path = '/', params = {}) ⇒ Object
-
#initialize(host, port = 80) ⇒ HttpLoader
constructor
A new instance of HttpLoader.
Constructor Details
#initialize(host, port = 80) ⇒ HttpLoader
Returns a new instance of HttpLoader.
3 4 5 6 7 8 9 10 11 |
# File 'lib/geon/http_loader.rb', line 3 def initialize(host, port = 80) @http = Net::HTTP.new(host, port) @headers = { "Accept" => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', "Accept-Charset" => "utf-8;q=0.7,*;q=0.3", "User-Agent" => "Geon #{Geon::VERSION}" } end |
Instance Method Details
#get(path = '/', params = {}) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/geon/http_loader.rb', line 13 def get(path = '/', params = {}) encode_param = URI.encode_www_form(params) path << '?' << encode_param resp, _ = @http.get(path, @headers) resp.body end |