Class: Gnarly::Request
- Inherits:
-
Object
- Object
- Gnarly::Request
- Includes:
- QueryStringParser
- Defined in:
- lib/gnarly/request.rb
Instance Attribute Summary collapse
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Instance Method Summary collapse
- #accept ⇒ Object
- #body ⇒ Object
- #charset ⇒ Object
- #content_type ⇒ Object
-
#initialize(state) ⇒ Request
constructor
A new instance of Request.
- #method ⇒ Object
- #params ⇒ Object
- #path ⇒ Object
Constructor Details
#initialize(state) ⇒ Request
Returns a new instance of Request.
10 11 12 13 |
# File 'lib/gnarly/request.rb', line 10 def initialize(state) @state = state parse_content_type end |
Instance Attribute Details
#state ⇒ Object (readonly)
Returns the value of attribute state.
8 9 10 |
# File 'lib/gnarly/request.rb', line 8 def state @state end |
Instance Method Details
#accept ⇒ Object
23 24 25 |
# File 'lib/gnarly/request.rb', line 23 def accept() @accept ||= @state["HTTP_ACCEPT"] end |
#body ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/gnarly/request.rb', line 35 def body() unless @body input = @state["rack.input"] @body = input.read input.rewind @body.force_encoding charset if charset end @body end |
#charset ⇒ Object
31 32 33 |
# File 'lib/gnarly/request.rb', line 31 def charset() @charset end |
#content_type ⇒ Object
27 28 29 |
# File 'lib/gnarly/request.rb', line 27 def content_type() @content_type end |
#method ⇒ Object
19 20 21 |
# File 'lib/gnarly/request.rb', line 19 def method() @method ||= @state["REQUEST_METHOD"].downcase.to_sym end |
#params ⇒ Object
45 46 47 |
# File 'lib/gnarly/request.rb', line 45 def params() @params ||= qs_parse(@state["QUERY_STRING"]) end |
#path ⇒ Object
15 16 17 |
# File 'lib/gnarly/request.rb', line 15 def path() @path ||= @state["PATH_INFO"] end |