Class: Akita::HarLogger::HarEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/akita/har_logger/har_entry.rb

Overview

Encapsulates an HTTP request-response pair.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(start_time, wait_time_ms, env, status, headers, body) ⇒ HarEntry

Params:

start_time

a Time object representing the request’s start time.

env

the request’s HTTP environment.

status

the response’s HTTP status code.

headers

the response’s HTTP headers.

body

the response’s HTTP body.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/akita/har_logger/har_entry.rb', line 18

def initialize(start_time, wait_time_ms, env, status, headers, body)
  @self = {
    startedDateTime: start_time.strftime('%FT%T.%L%:z'),
    time: wait_time_ms,
    request: (HttpRequest.new env),
    response: (HttpResponse.new env, status, headers, body),
    cache: {},  # Not applicable to server-side logging.
    timings: {
      send: 0,  # Mandatory, but not applicable to server-side logging.
      wait: wait_time_ms,
      receive: 0,  # Mandatory, but not applicable to server-side logging.
    },
  }
end

Instance Attribute Details

#requestObject (readonly)

Returns the value of attribute request.



10
11
12
# File 'lib/akita/har_logger/har_entry.rb', line 10

def request
  @request
end

#responseObject (readonly)

Returns the value of attribute response.



10
11
12
# File 'lib/akita/har_logger/har_entry.rb', line 10

def response
  @response
end

Instance Method Details

#to_json(*args) ⇒ Object



33
34
35
# File 'lib/akita/har_logger/har_entry.rb', line 33

def to_json(*args)
  @self.to_json(*args)
end