Class: Fluent::Plugin::GroongaInput::HTTPInput::RequestHandler
- Inherits:
-
Object
- Object
- Fluent::Plugin::GroongaInput::HTTPInput::RequestHandler
- Defined in:
- lib/fluent/plugin/in_groonga.rb
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
- #<<(chunk) ⇒ Object
-
#initialize(input, repeater) ⇒ RequestHandler
constructor
A new instance of RequestHandler.
- #on_body(chunk) ⇒ Object
- #on_headers_complete(headers) ⇒ Object
- #on_message_begin ⇒ Object
- #on_message_complete ⇒ Object
Constructor Details
#initialize(input, repeater) ⇒ RequestHandler
Returns a new instance of RequestHandler.
286 287 288 289 290 |
# File 'lib/fluent/plugin/in_groonga.rb', line 286 def initialize(input, repeater) @input = input @repeater = repeater @parser = Http::Parser.new(self) end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
284 285 286 |
# File 'lib/fluent/plugin/in_groonga.rb', line 284 def command @command end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
285 286 287 |
# File 'lib/fluent/plugin/in_groonga.rb', line 285 def params @params end |
Instance Method Details
#<<(chunk) ⇒ Object
292 293 294 |
# File 'lib/fluent/plugin/in_groonga.rb', line 292 def <<(chunk) @parser << chunk end |
#on_body(chunk) ⇒ Object
320 321 322 323 |
# File 'lib/fluent/plugin/in_groonga.rb', line 320 def on_body(chunk) @body << chunk @repeater.write(chunk) end |
#on_headers_complete(headers) ⇒ Object
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 |
# File 'lib/fluent/plugin/in_groonga.rb', line 302 def on_headers_complete(headers) method = @parser.http_method url = @parser.request_url http_version = @parser.http_version.join(".") @repeater.write("#{method} #{url} HTTP/#{http_version}\r\n") headers.each do |name, value| case name when /\AHost\z/i real_host = @input.real_host real_port = @input.real_port @repeater.write("#{name}: #{real_host}:#{real_port}\r\n") else @repeater.write("#{name}: #{value}\r\n") end end @repeater.write("\r\n") end |
#on_message_begin ⇒ Object
296 297 298 299 300 |
# File 'lib/fluent/plugin/in_groonga.rb', line 296 def @body = "" @command = nil @params = nil end |
#on_message_complete ⇒ Object
325 326 327 328 329 330 331 332 333 334 335 336 337 338 |
# File 'lib/fluent/plugin/in_groonga.rb', line 325 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 @command = command @params = params end end |