Class: PerformanceTester::Outcome::Request
- Inherits:
-
Object
- Object
- PerformanceTester::Outcome::Request
- Defined in:
- lib/performance_tester/outcome.rb
Overview
Models an executed http request
Defined Under Namespace
Classes: NullResponse
Instance Attribute Summary collapse
-
#host_aliases ⇒ Object
readonly
Returns the value of attribute host_aliases.
-
#request_time ⇒ Object
readonly
Returns the value of attribute request_time.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #content_type ⇒ Object
- #host ⇒ Object
- #host_alias ⇒ Object
-
#initialize(request, hosts) ⇒ Request
constructor
A new instance of Request.
- #null_response ⇒ Object
- #parse_response(response_parts) ⇒ Object
- #path ⇒ Object
- #response_time ⇒ Object
- #status ⇒ Object
- #time_elapsed ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(request, hosts) ⇒ Request
Returns a new instance of Request.
39 40 41 42 43 44 |
# File 'lib/performance_tester/outcome.rb', line 39 def initialize(request, hosts) @url = URI.parse(request.url) @request_time = request.time @response = parse_response(request.response_parts) @host_aliases = hosts.invert end |
Instance Attribute Details
#host_aliases ⇒ Object (readonly)
Returns the value of attribute host_aliases.
37 38 39 |
# File 'lib/performance_tester/outcome.rb', line 37 def host_aliases @host_aliases end |
#request_time ⇒ Object (readonly)
Returns the value of attribute request_time.
37 38 39 |
# File 'lib/performance_tester/outcome.rb', line 37 def request_time @request_time end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
37 38 39 |
# File 'lib/performance_tester/outcome.rb', line 37 def response @response end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
37 38 39 |
# File 'lib/performance_tester/outcome.rb', line 37 def url @url end |
Instance Method Details
#content_type ⇒ Object
74 75 76 |
# File 'lib/performance_tester/outcome.rb', line 74 def content_type response.content_type end |
#host ⇒ Object
50 51 52 |
# File 'lib/performance_tester/outcome.rb', line 50 def host url.host end |
#host_alias ⇒ Object
46 47 48 |
# File 'lib/performance_tester/outcome.rb', line 46 def host_alias host_aliases.fetch(host) { host } end |
#null_response ⇒ Object
86 87 88 |
# File 'lib/performance_tester/outcome.rb', line 86 def null_response NullResponse.new(request_time, 0, '') end |
#parse_response(response_parts) ⇒ Object
78 79 80 81 82 83 84 |
# File 'lib/performance_tester/outcome.rb', line 78 def parse_response(response_parts) if response_parts && !response_parts.empty? response_parts.last else null_response end end |
#path ⇒ Object
54 55 56 |
# File 'lib/performance_tester/outcome.rb', line 54 def path url.request_uri end |
#response_time ⇒ Object
66 67 68 |
# File 'lib/performance_tester/outcome.rb', line 66 def response_time response.time end |
#status ⇒ Object
70 71 72 |
# File 'lib/performance_tester/outcome.rb', line 70 def status response.status end |
#time_elapsed ⇒ Object
58 59 60 |
# File 'lib/performance_tester/outcome.rb', line 58 def time_elapsed response_time - request_time end |
#to_s ⇒ Object
62 63 64 |
# File 'lib/performance_tester/outcome.rb', line 62 def to_s [host_alias, path, status, content_type, time_elapsed].inspect end |