Class: Apt::Spy2::Request
- Inherits:
-
Object
- Object
- Apt::Spy2::Request
- Defined in:
- lib/apt/spy2/request.rb
Overview
make requests
Instance Method Summary collapse
- #get ⇒ Object
- #head ⇒ Object
-
#initialize(url) ⇒ Request
constructor
A new instance of Request.
Constructor Details
#initialize(url) ⇒ Request
Returns a new instance of Request.
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/apt/spy2/request.rb', line 11 def initialize(url) uri = URI(url) # sets hopefully sensible timeouts for read and connection http = Net::HTTP.new(uri.host, uri.port) http.read_timeout = 10 http.open_timeout = 10 http.use_ssl = true if uri.scheme == 'https' @http = http @request_uri = uri.request_uri end |
Instance Method Details
#get ⇒ Object
24 25 26 |
# File 'lib/apt/spy2/request.rb', line 24 def get @http.request(Net::HTTP::Get.new(@request_uri)) end |
#head ⇒ Object
28 29 30 |
# File 'lib/apt/spy2/request.rb', line 28 def head @http.request(Net::HTTP::Head.new(@request_uri)) end |