Class: Raven::HttpInterface
- Defined in:
- lib/raven/interfaces/http.rb
Instance Attribute Summary collapse
-
#cookies ⇒ Object
Returns the value of attribute cookies.
-
#data ⇒ Object
Returns the value of attribute data.
-
#env ⇒ Object
Returns the value of attribute env.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#method ⇒ Object
Returns the value of attribute method.
-
#query_string ⇒ Object
Returns the value of attribute query_string.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #from_rack(env) ⇒ Object
-
#initialize(*arguments) ⇒ HttpInterface
constructor
A new instance of HttpInterface.
Methods inherited from Interface
Constructor Details
#initialize(*arguments) ⇒ HttpInterface
Returns a new instance of HttpInterface.
15 16 17 18 19 20 |
# File 'lib/raven/interfaces/http.rb', line 15 def initialize(*arguments) self.headers = {} self.env = {} self. = nil super(*arguments) end |
Instance Attribute Details
#cookies ⇒ Object
Returns the value of attribute cookies.
11 12 13 |
# File 'lib/raven/interfaces/http.rb', line 11 def @cookies end |
#data ⇒ Object
Returns the value of attribute data.
9 10 11 |
# File 'lib/raven/interfaces/http.rb', line 9 def data @data end |
#env ⇒ Object
Returns the value of attribute env.
13 14 15 |
# File 'lib/raven/interfaces/http.rb', line 13 def env @env end |
#headers ⇒ Object
Returns the value of attribute headers.
12 13 14 |
# File 'lib/raven/interfaces/http.rb', line 12 def headers @headers end |
#method ⇒ Object
Returns the value of attribute method.
8 9 10 |
# File 'lib/raven/interfaces/http.rb', line 8 def method @method end |
#query_string ⇒ Object
Returns the value of attribute query_string.
10 11 12 |
# File 'lib/raven/interfaces/http.rb', line 10 def query_string @query_string end |
#url ⇒ Object
Returns the value of attribute url.
7 8 9 |
# File 'lib/raven/interfaces/http.rb', line 7 def url @url 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 47 48 49 50 |
# File 'lib/raven/interfaces/http.rb', line 22 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 |