Class: Sentry::RequestInterface

Inherits:
Interface show all
Defined in:
lib/sentry/interfaces/request.rb

Constant Summary collapse

REQUEST_ID_HEADERS =
%w[action_dispatch.request_id HTTP_X_REQUEST_ID].freeze
CONTENT_HEADERS =
%w[CONTENT_TYPE CONTENT_LENGTH].freeze
IP_HEADERS =
[
  "REMOTE_ADDR",
  "HTTP_CLIENT_IP",
  "HTTP_X_REAL_IP",
  "HTTP_X_FORWARDED_FOR"
].freeze
MAX_BODY_LIMIT =
4096 * 4

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Interface

#to_hash

Constructor Details

#initialize(env:, send_default_pii:, rack_env_whitelist:) ⇒ RequestInterface

Returns a new instance of RequestInterface.

Parameters:

  • env (Hash)
  • send_default_pii (Boolean)
  • rack_env_whitelist (Array)

See Also:



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/sentry/interfaces/request.rb', line 44

def initialize(env:, send_default_pii:, rack_env_whitelist:)
  env = env.dup

  unless send_default_pii
    # need to completely wipe out ip addresses
    RequestInterface::IP_HEADERS.each do |header|
      env.delete(header)
    end
  end

  request = ::Rack::Request.new(env)

  if send_default_pii
    self.data = read_data_from(request)
    self.cookies = request.cookies
    self.query_string = request.query_string
  end

  self.url = request.scheme && request.url.split("?").first
  self.method = request.request_method

  self.headers = filter_and_format_headers(env, send_default_pii)
  self.env     = filter_and_format_env(env, rack_env_whitelist)
end

Instance Attribute Details

#cookiesString

Returns:

  • (String)


31
32
33
# File 'lib/sentry/interfaces/request.rb', line 31

def cookies
  @cookies
end

#dataHash

Returns:

  • (Hash)


25
26
27
# File 'lib/sentry/interfaces/request.rb', line 25

def data
  @data
end

#envHash

Returns:

  • (Hash)


37
38
39
# File 'lib/sentry/interfaces/request.rb', line 37

def env
  @env
end

#headersHash

Returns:

  • (Hash)


34
35
36
# File 'lib/sentry/interfaces/request.rb', line 34

def headers
  @headers
end

#methodString

Returns:

  • (String)


22
23
24
# File 'lib/sentry/interfaces/request.rb', line 22

def method
  @method
end

#query_stringString

Returns:

  • (String)


28
29
30
# File 'lib/sentry/interfaces/request.rb', line 28

def query_string
  @query_string
end

#urlString

Returns:

  • (String)


19
20
21
# File 'lib/sentry/interfaces/request.rb', line 19

def url
  @url
end