Class: HTTPrb::HTTPCache

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/httprb/http_cache.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#httpObject (readonly)

Returns the value of attribute http.



16
17
18
# File 'lib/httprb/http_cache.rb', line 16

def http
  @http
end

Instance Method Details

#make_request(req) ⇒ Object

accepts an HTTPrb::Request object, performs the request, and returns the Net::HTTP result



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/httprb/http_cache.rb', line 20

def make_request(req)
  if @http && @http.address == req.uri.host && !@http.started?
    @http.start
  else
    @http = Net::HTTP.new(req.uri.host, req.uri.port)
    @http.use_ssl = req.ssl?
    @http.verify_mode = OpenSSL::SSL::VERIFY_NONE if req.ssl?
    @http.set_debug_output($stderr) if req.debug
    @http.start
  end
  @http.request(req.http_request)
end