module TCellAgent::Utils::Rails

Constants

STATUSES_MISSING_CONTENT_LENGTH

Public Class Methods

empty_content?(status_code, headers) click to toggle source
# File lib/tcell_agent/rails/responses.rb, line 6
def self.empty_content?(status_code, headers)
  STATUSES_MISSING_CONTENT_LENGTH.include?(status_code.to_i) ||
    (headers['Content-Length'] && headers['Content-Length'].to_i.zero?)
end
processable_response?(response_headers) click to toggle source
# File lib/tcell_agent/rails/responses.rb, line 11
def self.processable_response?(response_headers)
  content_disposition = response_headers['Content-Disposition']
  is_attachment = content_disposition && content_disposition =~ /^attachment/i

  content_type = response_headers['Content-Type']
  applicable_content_type = content_type &&
                            (content_type =~ %r{application/json}i ||
                             content_type =~ %r{application/xml}i ||
                             content_type =~ /^text/i)
  !is_attachment && applicable_content_type
end
reverse_proxy_header(request) click to toggle source
# File lib/tcell_agent/rails/better_ip.rb, line 7
def self.reverse_proxy_header(request)
  return unless TCellAgent.configuration.reverse_proxy

  TCellAgent::Instrumentation.safe_block('Extracting reverse proxy header') do
    reverse_proxy_header = TCellAgent.configuration.reverse_proxy_ip_address_header

    return if reverse_proxy_header.nil? || reverse_proxy_header.empty?

    return request.env["HTTP_#{reverse_proxy_header.upcase.tr('-', '_')}"]
  end
end