Sha256: 0ca8bd003067405d62f6baa1866cf0405f45fab481063e3ce07f80ad70067f4a

Contents?: true

Size: 1.18 KB

Versions: 13

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

require_relative 'http_request'
require_relative 'http_response'

module Akita
  module HarLogger
    # Encapsulates an HTTP request-response pair.
    class HarEntry
      attr_reader :request, :response

      # 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.
      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

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

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
akita-har_logger-0.2.14 lib/akita/har_logger/har_entry.rb
akita-har_logger-0.2.13 lib/akita/har_logger/har_entry.rb
akita-har_logger-0.2.12 lib/akita/har_logger/har_entry.rb
akita-har_logger-0.2.11 lib/akita/har_logger/har_entry.rb
akita-har_logger-0.2.10 lib/akita/har_logger/har_entry.rb
akita-har_logger-0.2.9 lib/akita/har_logger/har_entry.rb
akita-har_logger-0.2.8 lib/akita/har_logger/har_entry.rb
akita-har_logger-0.2.7 lib/akita/har_logger/har_entry.rb
akita-har_logger-0.2.6 lib/akita/har_logger/har_entry.rb
akita-har_logger-0.2.5 lib/akita/har_logger/har_entry.rb
akita-har_logger-0.2.4 lib/akita/har_logger/har_entry.rb
akita-har_logger-0.2.3 lib/akita/har_logger/har_entry.rb
akita-har_logger-0.2.2 lib/akita/har_logger/har_entry.rb