Class: Raven::HttpInterface
- Defined in:
- lib/raven/interfaces/http.rb
Instance Method Summary collapse
- #from_rack(env) ⇒ Object
-
#initialize(*arguments) ⇒ HttpInterface
constructor
A new instance of HttpInterface.
Methods inherited from Interface
#assert_required_properties_set!, name
Constructor Details
#initialize(*arguments) ⇒ HttpInterface
Returns a new instance of HttpInterface.
16 17 18 19 20 |
# File 'lib/raven/interfaces/http.rb', line 16 def initialize(*arguments) self.headers = {} self.env = {} super(*arguments) end |
Instance Method Details
#from_rack(env) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/raven/interfaces/http.rb', line 22 def from_rack(env) require 'rack' req = ::Rack::Request.new(env) self.url = req.url.split('?').first self.method = req.request_method self.query_string = req.query_string env.each_pair do |key, value| 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 else # 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 |