Class: Contrast::Agent::Reporting::Headers

Inherits:
Object
  • Object
show all
Includes:
Utils::ObjectShare
Defined in:
lib/contrast/agent/reporting/reporting_utilities/headers.rb

Overview

This class will build the required headers for agent reporting to TS

Constant Summary collapse

ENCODING =
'base64'
CONTENT_TYPE =
'application/json'
COMPRESSION =
'gzip'

Constants included from Utils::ObjectShare

Utils::ObjectShare::AMPERSAND, Utils::ObjectShare::ASTERISK, Utils::ObjectShare::AT, Utils::ObjectShare::BACK_SLASH, Utils::ObjectShare::BANG, Utils::ObjectShare::CACHE, Utils::ObjectShare::CARROT, Utils::ObjectShare::COLON, Utils::ObjectShare::COLON_SLASH_SLASH, Utils::ObjectShare::COMMA, Utils::ObjectShare::CONTRAST_DOT, Utils::ObjectShare::CONTRAST_PATCHED_METHOD_START, Utils::ObjectShare::DASH, Utils::ObjectShare::DIGIT_REGEXP, Utils::ObjectShare::DOLLAR_SIGN, Utils::ObjectShare::DOUBLE_QUOTE, Utils::ObjectShare::DOUBLE_UNDERSCORE, Utils::ObjectShare::EMPTY_ARRAY, Utils::ObjectShare::EMPTY_HASH, Utils::ObjectShare::EMPTY_STRING, Utils::ObjectShare::EQUALS, Utils::ObjectShare::EXCLAMATION, Utils::ObjectShare::FALSE, Utils::ObjectShare::HTTPS_START, Utils::ObjectShare::HTTP_SCORE, Utils::ObjectShare::HTTP_START, Utils::ObjectShare::INDEX, Utils::ObjectShare::LEFT_ANGLE, Utils::ObjectShare::NEW_LINE, Utils::ObjectShare::NIL_64_STRING, Utils::ObjectShare::NIL_STRING, Utils::ObjectShare::NOT_WHITE_SPACE_REGEXP, Utils::ObjectShare::OBJECT_KEY, Utils::ObjectShare::OVERRIDE_MESSAGE, Utils::ObjectShare::PARENT_PATH, Utils::ObjectShare::PERIOD, Utils::ObjectShare::POUND_SIGN, Utils::ObjectShare::QUESTION_MARK, Utils::ObjectShare::RETURN, Utils::ObjectShare::RETURN_KEY, Utils::ObjectShare::RUBY, Utils::ObjectShare::SEMICOLON, Utils::ObjectShare::SINGLE_QUOTE, Utils::ObjectShare::SLASH, Utils::ObjectShare::SPACE, Utils::ObjectShare::TRUE, Utils::ObjectShare::UNDERSCORE, Utils::ObjectShare::UNKNOWN, Utils::ObjectShare::WHITE_SPACE_REGEXP, Utils::ObjectShare::WRITE_FLAG

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeHeaders

Returns a new instance of Headers.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/contrast/agent/reporting/reporting_utilities/headers.rb', line 21

def initialize
  @app_name = Base64.strict_encode64(Contrast::APP_CONTEXT.name) # rubocop:disable Security/Module/Name
  @api_key = Contrast::API.api_key
  @agent_version = [RUBY, Contrast::Agent::VERSION].join(SPACE)
  @app_language = RUBY
  @app_path = Base64.strict_encode64(Contrast::APP_CONTEXT.path)
  @app_version = Contrast::APP_CONTEXT.version
  @authorization = Base64.strict_encode64("#{ Contrast::API.user_name }:#{ Contrast::API.service_key }")
  @server_name = Base64.strict_encode64(Contrast::APP_CONTEXT.server_name)
  @server_path = Base64.strict_encode64(Contrast::APP_CONTEXT.server_path)
  @server_type = Base64.strict_encode64(Contrast::APP_CONTEXT.server_type)
  @session_id = Contrast::CONFIG.session_id
  @content_type = CONTENT_TYPE
  @encoding = ENCODING
  @compression = COMPRESSION
end

Instance Attribute Details

#agent_versionObject (readonly)

Returns the value of attribute agent_version.



13
14
15
# File 'lib/contrast/agent/reporting/reporting_utilities/headers.rb', line 13

def agent_version
  @agent_version
end

#api_keyObject (readonly)

Returns the value of attribute api_key.



13
14
15
# File 'lib/contrast/agent/reporting/reporting_utilities/headers.rb', line 13

def api_key
  @api_key
end

#app_languageObject (readonly)

Returns the value of attribute app_language.



13
14
15
# File 'lib/contrast/agent/reporting/reporting_utilities/headers.rb', line 13

def app_language
  @app_language
end

#app_nameObject (readonly)

Returns the value of attribute app_name.



13
14
15
# File 'lib/contrast/agent/reporting/reporting_utilities/headers.rb', line 13

def app_name
  @app_name
end

#app_pathObject (readonly)

Returns the value of attribute app_path.



13
14
15
# File 'lib/contrast/agent/reporting/reporting_utilities/headers.rb', line 13

def app_path
  @app_path
end

#app_versionObject (readonly)

Returns the value of attribute app_version.



13
14
15
# File 'lib/contrast/agent/reporting/reporting_utilities/headers.rb', line 13

def app_version
  @app_version
end

#authorizationObject (readonly)

Returns the value of attribute authorization.



13
14
15
# File 'lib/contrast/agent/reporting/reporting_utilities/headers.rb', line 13

def authorization
  @authorization
end

#compressionObject (readonly)

Returns the value of attribute compression.



13
14
15
# File 'lib/contrast/agent/reporting/reporting_utilities/headers.rb', line 13

def compression
  @compression
end

#content_typeObject (readonly)

Returns the value of attribute content_type.



13
14
15
# File 'lib/contrast/agent/reporting/reporting_utilities/headers.rb', line 13

def content_type
  @content_type
end

#encodingObject (readonly)

Returns the value of attribute encoding.



13
14
15
# File 'lib/contrast/agent/reporting/reporting_utilities/headers.rb', line 13

def encoding
  @encoding
end

#server_nameObject (readonly)

Returns the value of attribute server_name.



13
14
15
# File 'lib/contrast/agent/reporting/reporting_utilities/headers.rb', line 13

def server_name
  @server_name
end

#server_pathObject (readonly)

Returns the value of attribute server_path.



13
14
15
# File 'lib/contrast/agent/reporting/reporting_utilities/headers.rb', line 13

def server_path
  @server_path
end

#server_typeObject (readonly)

Returns the value of attribute server_type.



13
14
15
# File 'lib/contrast/agent/reporting/reporting_utilities/headers.rb', line 13

def server_type
  @server_type
end

#session_idObject (readonly)

Returns the value of attribute session_id.



13
14
15
# File 'lib/contrast/agent/reporting/reporting_utilities/headers.rb', line 13

def session_id
  @session_id
end

Instance Method Details

#to_contrast_hashObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/contrast/agent/reporting/reporting_utilities/headers.rb', line 38

def to_contrast_hash
  {
      app_name: @app_name,
      api_key: @api_key,
      agent_version: @agent_version,
      app_language: @app_language,
      app_path: @app_path,
      app_version: @app_version,
      authorization: @authorization,
      server_name: @server_name,
      server_path: @server_path,
      server_type: @server_type,
      'Session-ID': @session_id,
      content_type: @content_type,
      encoding: @encoding,
      compression: @compression
  }.cs__freeze
end