Class: Fluent::GroongaInput::HTTPInput::RequestHandler
- Inherits:
-
Object
- Object
- Fluent::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.
305 306 307 308 309 |
# File 'lib/fluent/plugin/in_groonga.rb', line 305 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.
303 304 305 |
# File 'lib/fluent/plugin/in_groonga.rb', line 303 def command @command end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
304 305 306 |
# File 'lib/fluent/plugin/in_groonga.rb', line 304 def params @params end |
Instance Method Details
#<<(chunk) ⇒ Object
311 312 313 |
# File 'lib/fluent/plugin/in_groonga.rb', line 311 def <<(chunk) @parser << chunk end |
#on_body(chunk) ⇒ Object
339 340 341 342 |
# File 'lib/fluent/plugin/in_groonga.rb', line 339 def on_body(chunk) @body << chunk @repeater.write(chunk) end |
#on_headers_complete(headers) ⇒ Object
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 |
# File 'lib/fluent/plugin/in_groonga.rb', line 321 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
315 316 317 318 319 |
# File 'lib/fluent/plugin/in_groonga.rb', line 315 def @body = "" @command = nil @params = nil end |
#on_message_complete ⇒ Object
344 345 346 347 348 349 350 351 352 353 354 355 356 357 |
# File 'lib/fluent/plugin/in_groonga.rb', line 344 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 |