Class: Oembed::Http
- Inherits:
-
Object
- Object
- Oembed::Http
- Defined in:
- lib/oembed/http.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
Instance Attribute Details
Instance Method Details
#get(path, options = {}) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/oembed/http.rb', line 14 def get(path, = {}) uri = URI.parse(path) connection = establish_connection(uri.host, uri.port) response = connection.get(uri.request_uri) case response when Net::HTTPRedirection follow_redirection(response['location'], .fetch(:limit, 10)) when Net::HTTPSuccess parser.parse(response.body, response.content_type) else raise Oembed::ResponseError.new(response), 'HTTP error during request' end end |