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

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

Instance Method Summary (collapse)

Constructor Details

- (Handler) initialize(socket, input)

Returns a new instance of Handler



179
180
181
182
# File 'lib/fluent/plugin/in_groonga.rb', line 179

def initialize(socket, input)
  super(socket)
  @input = input
end

Instance Method Details

- (Object) on_body(chunk)



201
202
203
# File 'lib/fluent/plugin/in_groonga.rb', line 201

def on_body(chunk)
  @body << chunk
end

- (Object) on_connect



184
185
186
187
# File 'lib/fluent/plugin/in_groonga.rb', line 184

def on_connect
  @parser = HTTP::Parser.new(self)
  @repeater = @input.create_repeater(self)
end

- (Object) on_headers_complete(headers)



198
199
# File 'lib/fluent/plugin/in_groonga.rb', line 198

def on_headers_complete(headers)
end

- (Object) on_message_begin



194
195
196
# File 'lib/fluent/plugin/in_groonga.rb', line 194

def on_message_begin
  @body = ""
end

- (Object) on_message_complete



205
206
207
208
209
210
211
212
213
214
215
216
217
# File 'lib/fluent/plugin/in_groonga.rb', line 205

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

- (Object) on_read(data)



189
190
191
192
# File 'lib/fluent/plugin/in_groonga.rb', line 189

def on_read(data)
  @parser << data
  @repeater.write(data)
end