Sha256: 1b329ff4fb1c3c47e016a8953044763e97cec4a45ac72f9176b1464347be61a3
Contents?: true
Size: 1.41 KB
Versions: 3
Compression:
Stored size: 1.41 KB
Contents
require 'raven/interfaces' module Raven class HttpInterface < Interface name 'request' attr_accessor :url attr_accessor :method attr_accessor :data attr_accessor :query_string attr_accessor :cookies attr_accessor :headers attr_accessor :env def initialize(*arguments) self.headers = {} self.env = {} super(*arguments) end def from_rack(env) req = ::Rack::Request.new(env) self.url = req.scheme && req.url.split('?').first self.method = req.request_method self.query_string = req.query_string env.each_pair do |key, value| key = key.to_s #rack env can contain symbols next unless key.upcase == key # Non-upper case stuff isn't either if key.start_with?('HTTP_') # Header http_key = key[5..key.length - 1].split('_').map { |s| s.capitalize }.join('-') self.headers[http_key] = value.to_s elsif ['CONTENT_TYPE', 'CONTENT_LENGTH'].include? key self.headers[key.capitalize] = value.to_s elsif ['REMOTE_ADDR', 'SERVER_NAME', 'SERVER_PORT'].include? key # Environment self.env[key] = value.to_s end end self.data = if req.form_data? req.POST elsif req.body data = req.body.read req.body.rewind data end end end register_interface :http => HttpInterface end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
sentry-raven-0.12.3 | lib/raven/interfaces/http.rb |
sentry-raven-0.12.2 | lib/raven/interfaces/http.rb |
sentry-raven-0.12.1 | lib/raven/interfaces/http.rb |