Class: Fluent::GroongaInput::HTTPInput::Handler
- Inherits:
-
Coolio::Socket
- Object
- Coolio::Socket
- Fluent::GroongaInput::HTTPInput::Handler
- Defined in:
- lib/fluent/plugin/in_groonga.rb
Instance Method Summary collapse
-
#initialize(socket, input) ⇒ Handler
constructor
A new instance of Handler.
- #on_body(chunk) ⇒ Object
- #on_connect ⇒ Object
- #on_headers_complete(headers) ⇒ Object
- #on_message_begin ⇒ Object
- #on_message_complete ⇒ Object
- #on_read(data) ⇒ Object
Constructor Details
#initialize(socket, input) ⇒ Handler
Returns a new instance of Handler.
188 189 190 191 |
# File 'lib/fluent/plugin/in_groonga.rb', line 188 def initialize(socket, input) super(socket) @input = input end |
Instance Method Details
#on_body(chunk) ⇒ Object
210 211 212 |
# File 'lib/fluent/plugin/in_groonga.rb', line 210 def on_body(chunk) @body << chunk end |
#on_connect ⇒ Object
193 194 195 196 |
# File 'lib/fluent/plugin/in_groonga.rb', line 193 def on_connect @parser = HTTP::Parser.new(self) @repeater = @input.create_repeater(self) end |
#on_headers_complete(headers) ⇒ Object
207 208 |
# File 'lib/fluent/plugin/in_groonga.rb', line 207 def on_headers_complete(headers) end |
#on_message_begin ⇒ Object
203 204 205 |
# File 'lib/fluent/plugin/in_groonga.rb', line 203 def @body = "" end |
#on_message_complete ⇒ Object
214 215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/fluent/plugin/in_groonga.rb', line 214 def uri = URI.parse(@parser.request_url) params = WEBrick::HTTPUtils.parse_query(uri.query) path_info = uri.path case path_info when /\A\/d\// command = $POSTMATCH if command == "load" params["values"] = @body unless @body.empty? end @input.emit(command, params) end end |
#on_read(data) ⇒ Object
198 199 200 201 |
# File 'lib/fluent/plugin/in_groonga.rb', line 198 def on_read(data) @parser << data @repeater.write(data) end |