Class: Benchy::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/benchy.rb

Overview

Represents an HTTP Request, but can’t actually be executed

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, method, headers, body = nil) ⇒ Request

Returns a new instance of Request.



65
66
67
# File 'lib/benchy.rb', line 65

def initialize(url, method, headers, body=nil)
  @url, @method, @headers, @body = url, method, (headers || {}), body
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



63
64
65
# File 'lib/benchy.rb', line 63

def body
  @body
end

#headersObject

Returns the value of attribute headers.



63
64
65
# File 'lib/benchy.rb', line 63

def headers
  @headers
end

#methodObject

Returns the value of attribute method.



63
64
65
# File 'lib/benchy.rb', line 63

def method
  @method
end

#urlObject

Returns the value of attribute url.



63
64
65
# File 'lib/benchy.rb', line 63

def url
  @url
end

Instance Method Details

#emObject

Grab an instance of an Em::Http request so we can run it somewhere.



70
71
72
73
74
75
76
77
# File 'lib/benchy.rb', line 70

def em
  EventMachine::HttpRequest.new(url).send(method.downcase,
    :head => headers,
    :body => body,
    :connect_timeout => 9000,    # Disable
    :inactivity_timeout => 9000  # Disable
  )
end