Class: LogStash::Inputs::Http::MessageHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/inputs/http/message_handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input, default_codec, additional_codecs, auth_token) ⇒ MessageHandler

Returns a new instance of MessageHandler.



10
11
12
13
14
15
# File 'lib/logstash/inputs/http/message_handler.rb', line 10

def initialize(input, default_codec, additional_codecs, auth_token)
  @input = input
  @default_codec = default_codec
  @additional_codecs = additional_codecs
  @auth_token = auth_token
end

Instance Attribute Details

#inputObject (readonly)

Returns the value of attribute input.



8
9
10
# File 'lib/logstash/inputs/http/message_handler.rb', line 8

def input
  @input
end

Instance Method Details

#clone_additional_codecsObject



37
38
39
40
41
42
43
# File 'lib/logstash/inputs/http/message_handler.rb', line 37

def clone_additional_codecs
  clone_additional_codecs = {}
  @additional_codecs.each do |content_type, codec|
    clone_additional_codecs[content_type] = codec.clone
  end
  clone_additional_codecs
end

#copyObject



33
34
35
# File 'lib/logstash/inputs/http/message_handler.rb', line 33

def copy
  MessageHandler.new(@input, @default_codec.clone, clone_additional_codecs(), @auth_token)
end

#onNewMessage(remote_address, headers, body) ⇒ Object



29
30
31
# File 'lib/logstash/inputs/http/message_handler.rb', line 29

def onNewMessage(remote_address, headers, body)
  @input.decode_body(headers, remote_address, body, @default_codec, @additional_codecs)
end

#requires_tokenObject



25
26
27
# File 'lib/logstash/inputs/http/message_handler.rb', line 25

def requires_token
  !!@auth_token
end

#response_headersObject



45
46
47
# File 'lib/logstash/inputs/http/message_handler.rb', line 45

def response_headers
  @input.response_headers
end

#validates_token(token) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/logstash/inputs/http/message_handler.rb', line 17

def validates_token(token)
  if @auth_token
    @auth_token == token
  else
    true
  end
end