Class: Fluent::PluginHelper::HttpServer::Request
- Inherits:
-
Object
- Object
- Fluent::PluginHelper::HttpServer::Request
- Defined in:
- lib/fluent/plugin_helper/http_server/request.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#query_string ⇒ Object
readonly
Returns the value of attribute query_string.
Instance Method Summary collapse
- #body ⇒ Object
- #headers ⇒ Object
-
#initialize(request) ⇒ Request
constructor
A new instance of Request.
- #query ⇒ Object
Constructor Details
#initialize(request) ⇒ Request
Returns a new instance of Request.
27 28 29 30 31 |
# File 'lib/fluent/plugin_helper/http_server/request.rb', line 27 def initialize(request) @request = request path = request.path @path, @query_string = path.split('?', 2) end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
25 26 27 |
# File 'lib/fluent/plugin_helper/http_server/request.rb', line 25 def path @path end |
#query_string ⇒ Object (readonly)
Returns the value of attribute query_string.
25 26 27 |
# File 'lib/fluent/plugin_helper/http_server/request.rb', line 25 def query_string @query_string end |
Instance Method Details
#body ⇒ Object
47 48 49 |
# File 'lib/fluent/plugin_helper/http_server/request.rb', line 47 def body @request.body&.read end |
#headers ⇒ Object
33 34 35 |
# File 'lib/fluent/plugin_helper/http_server/request.rb', line 33 def headers @request.headers end |
#query ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/fluent/plugin_helper/http_server/request.rb', line 37 def query if @query_string hash = Hash.new { |h, k| h[k] = [] } # For compatibility with CGI.parse URI.decode_www_form(@query_string).each_with_object(hash) do |(key, value), h| h[key] << value end end end |