Class: Fluent::GroongaInput::HTTPInput::Handler

Inherits:
Coolio::Socket
  • Object
show all
Defined in:
lib/fluent/plugin/in_groonga.rb

Instance Method Summary collapse

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_connectObject



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_beginObject



203
204
205
# File 'lib/fluent/plugin/in_groonga.rb', line 203

def on_message_begin
  @body = ""
end

#on_message_completeObject



214
215
216
217
218
219
220
221
222
223
224
225
226
# File 'lib/fluent/plugin/in_groonga.rb', line 214

def on_message_complete
  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