logstash-codec-form 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/lib/logstash/codecs/form.rb +23 -8
- data/logstash-codec-form.gemspec +1 -2
- data/spec/codecs/form_spec.rb +2 -2
- metadata +3 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bfcf038963d59e55a83ea30b52c96b5bfbb6a9ea
|
4
|
+
data.tar.gz: 056c57a5f14af66f7b8eef42af690abce74c5e91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d653f3053739345765d5a243cc43282a8e375c6e3d0ac6916ad6876e275a09695208aca4b186f5677cccfc535a1a3cff3d8634b700646c6352679eaacd8343d
|
7
|
+
data.tar.gz: f5fa54a7d428fb12c58571d5144b3bc76404b95d2f58aaf819307f7dedccf2586e878cfbed40e9846397d5782db4785fd254740e825b842fe5ede6e789d84639
|
data/CHANGELOG.md
ADDED
data/lib/logstash/codecs/form.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'logstash/codecs/base'
|
3
|
-
require 'logstash/
|
3
|
+
require 'logstash/util/charset'
|
4
4
|
require 'uri'
|
5
5
|
|
6
6
|
class LogStash::Codecs::Form < LogStash::Codecs::Base
|
@@ -29,10 +29,13 @@ class LogStash::Codecs::Form < LogStash::Codecs::Base
|
|
29
29
|
# }
|
30
30
|
config_name 'form'
|
31
31
|
|
32
|
+
# The character encoding used in this codec. Defaults to "UTF-8".
|
33
|
+
config :charset, validate: ::Encoding.name_list, default: "UTF-8"
|
34
|
+
|
32
35
|
private
|
33
|
-
def parse(
|
36
|
+
def parse(payload)
|
34
37
|
event = {}
|
35
|
-
keypairs = URI.decode_www_form
|
38
|
+
keypairs = URI.decode_www_form payload
|
36
39
|
keypairs.each do |keypair|
|
37
40
|
if event.has_key? keypair[0]
|
38
41
|
event[keypair[0]] << keypair[1]
|
@@ -45,19 +48,31 @@ class LogStash::Codecs::Form < LogStash::Codecs::Base
|
|
45
48
|
|
46
49
|
private
|
47
50
|
def dump(event)
|
48
|
-
URI.encode_www_form
|
51
|
+
URI.encode_www_form event.to_hash
|
49
52
|
end
|
50
53
|
|
51
54
|
public
|
52
55
|
def register
|
53
|
-
@
|
54
|
-
@
|
56
|
+
@converter = LogStash::Util::Charset.new @charset
|
57
|
+
@converter.logger = @logger
|
55
58
|
end
|
56
59
|
|
57
60
|
public
|
58
61
|
def decode(payload)
|
59
|
-
@
|
60
|
-
|
62
|
+
payload = @converter.convert payload
|
63
|
+
begin
|
64
|
+
yield LogStash::Event.new(parse(payload))
|
65
|
+
rescue StandardError => e
|
66
|
+
@logger.warn(
|
67
|
+
"An unexpected error occurred",
|
68
|
+
message: e.message,
|
69
|
+
backtrace: e.backtrace,
|
70
|
+
input: payload
|
71
|
+
)
|
72
|
+
yield LogStash::Event.new(
|
73
|
+
"message" => payload,
|
74
|
+
"tags" => ["_formparsefailure"]
|
75
|
+
)
|
61
76
|
end
|
62
77
|
end
|
63
78
|
|
data/logstash-codec-form.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-codec-form'
|
3
|
-
s.version = '1.
|
3
|
+
s.version = '1.1.0'
|
4
4
|
s.licenses = ['Apache License (2.0)']
|
5
5
|
s.summary = "Read or write events in a application/x-www-form-urlencoded format."
|
6
6
|
s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program."
|
@@ -20,7 +20,6 @@ Gem::Specification.new do |s|
|
|
20
20
|
|
21
21
|
# Gem dependencies
|
22
22
|
s.add_runtime_dependency "logstash-core", ">= 2.0.0.beta2", "< 3.0.0"
|
23
|
-
s.add_runtime_dependency "logstash-codec-line", "~> 2.0", ">= 2.0.2"
|
24
23
|
|
25
24
|
s.add_development_dependency 'logstash-devutils'
|
26
25
|
end
|
data/spec/codecs/form_spec.rb
CHANGED
@@ -17,7 +17,7 @@ describe LogStash::Codecs::Form do
|
|
17
17
|
it 'should return an application/x-www-form-urlencoded formatted line' do
|
18
18
|
expect(subject).to receive(:on_event).once.and_call_original
|
19
19
|
subject.on_event do |e, d|
|
20
|
-
insist {d} == "message=hello+world&host=test&%40version=1&%40timestamp=#{URI.encode_www_form_component(event.timestamp)}
|
20
|
+
insist {d} == "message=hello+world&host=test&%40version=1&%40timestamp=#{URI.encode_www_form_component(event.timestamp)}"
|
21
21
|
end
|
22
22
|
subject.encode(event)
|
23
23
|
end
|
@@ -26,7 +26,7 @@ describe LogStash::Codecs::Form do
|
|
26
26
|
context '#decode' do
|
27
27
|
it 'should return an event from an application/x-www-form-urlencoded string' do
|
28
28
|
decoded = false
|
29
|
-
subject.decode("message=hello+world&host=test
|
29
|
+
subject.decode("message=hello+world&host=test") do |e|
|
30
30
|
decoded = true
|
31
31
|
insist { e.is_a?(LogStash::Event) }
|
32
32
|
insist { e['message'] } == ['hello world']
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-codec-form
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brendan ODonnell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -30,26 +30,6 @@ dependencies:
|
|
30
30
|
- - <
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 3.0.0
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
requirement: !ruby/object:Gem::Requirement
|
35
|
-
requirements:
|
36
|
-
- - ~>
|
37
|
-
- !ruby/object:Gem::Version
|
38
|
-
version: '2.0'
|
39
|
-
- - '>='
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
version: 2.0.2
|
42
|
-
name: logstash-codec-line
|
43
|
-
prerelease: false
|
44
|
-
type: :runtime
|
45
|
-
version_requirements: !ruby/object:Gem::Requirement
|
46
|
-
requirements:
|
47
|
-
- - ~>
|
48
|
-
- !ruby/object:Gem::Version
|
49
|
-
version: '2.0'
|
50
|
-
- - '>='
|
51
|
-
- !ruby/object:Gem::Version
|
52
|
-
version: 2.0.2
|
53
33
|
- !ruby/object:Gem::Dependency
|
54
34
|
requirement: !ruby/object:Gem::Requirement
|
55
35
|
requirements:
|
@@ -70,6 +50,7 @@ executables: []
|
|
70
50
|
extensions: []
|
71
51
|
extra_rdoc_files: []
|
72
52
|
files:
|
53
|
+
- CHANGELOG.md
|
73
54
|
- Gemfile
|
74
55
|
- LICENSE
|
75
56
|
- NOTICE.TXT
|