logstash-input-http 2.2.2 → 2.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/LICENSE +1 -1
- data/README.md +12 -3
- data/logstash-input-http.gemspec +2 -2
- data/spec/inputs/http_spec.rb +145 -164
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 369d5bdf4eb3849fe8c1c22be51872b77f306e99
|
4
|
+
data.tar.gz: 7f4c99931dd5bbbd45afc51dd689bc3ddaf21291
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8101c5b9b09393a672d4807bad8980265e5592dc9ba979e6cd70798ff02cd07919be12a9f1a6dfd5608447fe44aa5849f5a262eae417c93928c01a2564889678
|
7
|
+
data.tar.gz: 4b8f65d565b7b49dfc0d31b09665fda3361b775b3816bddde7a2cd4e51f925333ae52f486176bf1b903c529b3fc22b194dc2e8f76678d852ef5dda8f68b9369c
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
# 2.2.3
|
2
|
+
- fix hanging tests
|
3
|
+
- added some meta documents to the repository like contributing guide and github templates
|
1
4
|
# 2.2.2
|
2
5
|
- Depend on logstash-core-plugin-api instead of logstash-core, removing the need to mass update plugins on major releases of logstash
|
3
6
|
# 2.2.1
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# Logstash Plugin
|
2
2
|
|
3
|
-
[![Build
|
4
|
-
Status](http://build-eu-00.elastic.co/view/LS%20Plugins/view/LS%20Inputs/job/logstash-plugin-input-http-unit/badge/icon)](http://build-eu-00.elastic.co/view/LS%20Plugins/view/LS%20Inputs/job/logstash-plugin-input-http-unit/)
|
3
|
+
[![Travis Build Status](https://travis-ci.org/logstash-plugins/logstash-input-http.svg)](https://travis-ci.org/logstash-plugins/logstash-input-http)
|
5
4
|
|
6
5
|
This is a plugin for [Logstash](https://github.com/elastic/logstash).
|
7
6
|
|
@@ -56,7 +55,12 @@ gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
|
|
56
55
|
```
|
57
56
|
- Install plugin
|
58
57
|
```sh
|
58
|
+
# Logstash 2.3 and higher
|
59
|
+
bin/logstash-plugin install --no-verify
|
60
|
+
|
61
|
+
# Prior to Logstash 2.3
|
59
62
|
bin/plugin install --no-verify
|
63
|
+
|
60
64
|
```
|
61
65
|
- Run Logstash with your plugin
|
62
66
|
```sh
|
@@ -74,7 +78,12 @@ gem build logstash-filter-awesome.gemspec
|
|
74
78
|
```
|
75
79
|
- Install the plugin from the Logstash home
|
76
80
|
```sh
|
77
|
-
|
81
|
+
# Logstash 2.3 and higher
|
82
|
+
bin/logstash-plugin install --no-verify
|
83
|
+
|
84
|
+
# Prior to Logstash 2.3
|
85
|
+
bin/plugin install --no-verify
|
86
|
+
|
78
87
|
```
|
79
88
|
- Start Logstash and proceed to test the plugin
|
80
89
|
|
data/logstash-input-http.gemspec
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-input-http'
|
3
|
-
s.version = '2.2.
|
3
|
+
s.version = '2.2.3'
|
4
4
|
s.licenses = ['Apache License (2.0)']
|
5
5
|
s.summary = "Logstash Input plugin that receives HTTP requests"
|
6
|
-
s.description
|
6
|
+
s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
|
7
7
|
s.authors = ["Elastic"]
|
8
8
|
s.email = 'info@elastic.co'
|
9
9
|
s.homepage = "http://www.elastic.co/guide/en/logstash/current/index.html"
|
data/spec/inputs/http_spec.rb
CHANGED
@@ -16,149 +16,179 @@ describe LogStash::Inputs::Http do
|
|
16
16
|
let(:queue) { Queue.new }
|
17
17
|
let(:port) { rand(5000) + 1025 }
|
18
18
|
|
19
|
-
after :each do
|
20
|
-
subject.stop
|
21
|
-
end
|
22
|
-
|
23
19
|
it_behaves_like "an interruptible input plugin" do
|
24
20
|
let(:config) { { "port" => port } }
|
25
21
|
end
|
26
22
|
|
27
|
-
|
23
|
+
after :each do
|
24
|
+
subject.stop
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "request handling" do
|
28
28
|
subject { LogStash::Inputs::Http.new }
|
29
29
|
before :each do
|
30
30
|
subject.register
|
31
|
-
Thread.new { subject.run(queue) }
|
31
|
+
t = Thread.new { subject.run(queue) }
|
32
|
+
sleep 0.01 until subject.instance_variable_get(:@server).running == 0
|
32
33
|
end
|
34
|
+
|
33
35
|
it "should include remote host in \"host\" property" do
|
34
36
|
agent.post!("http://localhost:8080/meh.json",
|
35
|
-
|
36
|
-
|
37
|
+
:headers => { "content-type" => "text/plain" },
|
38
|
+
:body => "hello")
|
37
39
|
event = queue.pop
|
38
40
|
expect(event["host"]).to eq("127.0.0.1")
|
39
41
|
end
|
40
|
-
end
|
41
42
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
43
|
+
context "with default codec" do
|
44
|
+
subject { LogStash::Inputs::Http.new("port" => port) }
|
45
|
+
context "when receiving a text/plain request" do
|
46
|
+
it "should process the request normally" do
|
47
|
+
agent.post!("http://localhost:#{port}/meh.json",
|
48
|
+
:headers => { "content-type" => "text/plain" },
|
49
|
+
:body => "hello")
|
50
|
+
event = queue.pop
|
51
|
+
expect(event["message"]).to eq("hello")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
context "when receiving a deflate compressed text/plain request" do
|
55
|
+
it "should process the request normally" do
|
56
|
+
agent.post!("http://localhost:#{port}/meh.json",
|
57
|
+
:headers => { "content-type" => "text/plain", "content-encoding" => "deflate" },
|
58
|
+
:body => Zlib::Deflate.deflate("hello"))
|
59
|
+
event = queue.pop
|
60
|
+
expect(event["message"]).to eq("hello")
|
61
|
+
end
|
62
|
+
end
|
63
|
+
context "when receiving a deflate text/plain request that cannot be decompressed" do
|
64
|
+
it "should respond with 400" do
|
65
|
+
response = agent.post!("http://localhost:#{port}/meh.json",
|
66
|
+
:headers => { "content-type" => "text/plain", "content-encoding" => "deflate" },
|
67
|
+
:body => "hello")
|
68
|
+
expect(response.status).to eq(400)
|
69
|
+
end
|
70
|
+
it "should respond with a decompression error" do
|
71
|
+
response = agent.post!("http://localhost:#{port}/meh.json",
|
72
|
+
:headers => { "content-type" => "text/plain", "content-encoding" => "deflate" },
|
73
|
+
:body => "hello")
|
74
|
+
expect(response.read_body).to eq("Failed to decompress body")
|
75
|
+
end
|
76
|
+
end
|
77
|
+
context "when receiving a gzip compressed text/plain request" do
|
78
|
+
it "should process the request normally" do
|
79
|
+
z = StringIO.new ""
|
80
|
+
w = Zlib::GzipWriter.new z
|
81
|
+
w.write("hello")
|
82
|
+
w.finish
|
83
|
+
agent.post!("http://localhost:#{port}/meh.json",
|
84
|
+
:headers => { "content-type" => "text/plain", "content-encoding" => "gzip" },
|
85
|
+
:body => z.string)
|
86
|
+
event = queue.pop
|
87
|
+
expect(event["message"]).to eq("hello")
|
88
|
+
end
|
89
|
+
end
|
90
|
+
context "when receiving a gzip text/plain request that cannot be decompressed" do
|
91
|
+
let(:response) do
|
92
|
+
agent.post!("http://localhost:#{port}/meh.json",
|
93
|
+
:headers => { "content-type" => "text/plain", "content-encoding" => "gzip" },
|
94
|
+
:body => "hello")
|
95
|
+
end
|
96
|
+
it "should respond with 400" do
|
97
|
+
expect(response.status).to eq(400)
|
98
|
+
end
|
99
|
+
it "should respond with a decompression error" do
|
100
|
+
expect(response.read_body).to eq("Failed to decompress body")
|
101
|
+
end
|
102
|
+
end
|
103
|
+
context "when receiving an application/json request" do
|
104
|
+
it "should parse the json body" do
|
105
|
+
agent.post!("http://localhost:#{port}/meh.json",
|
106
|
+
:headers => { "content-type" => "application/json" },
|
107
|
+
:body => { "message_body" => "Hello" }.to_json)
|
108
|
+
event = queue.pop
|
109
|
+
expect(event["message_body"]).to eq("Hello")
|
110
|
+
end
|
79
111
|
end
|
80
112
|
end
|
81
|
-
context "
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
z = StringIO.new ""
|
86
|
-
w = Zlib::GzipWriter.new z
|
87
|
-
w.write("hello")
|
88
|
-
w.finish
|
89
|
-
agent.post!("http://localhost:#{port}/meh.json",
|
90
|
-
:headers => { "content-type" => "text/plain", "content-encoding" => "gzip" },
|
91
|
-
:body => z.string)
|
113
|
+
context "with json codec" do
|
114
|
+
subject { LogStash::Inputs::Http.new("port" => port, "codec" => "json") }
|
115
|
+
it "should parse the json body" do
|
116
|
+
agent.post!("http://localhost:#{port}/meh.json", :body => { "message" => "Hello" }.to_json)
|
92
117
|
event = queue.pop
|
93
|
-
expect(event["message"]).to eq("
|
94
|
-
end
|
95
|
-
end
|
96
|
-
context "when receiving a gzip text/plain request that cannot be decompressed" do
|
97
|
-
let!(:response) do
|
98
|
-
subject.register
|
99
|
-
Thread.new { subject.run(queue) }
|
100
|
-
agent.post!("http://localhost:#{port}/meh.json",
|
101
|
-
:headers => { "content-type" => "text/plain", "content-encoding" => "gzip" },
|
102
|
-
:body => "hello")
|
103
|
-
end
|
104
|
-
it "should respond with 400" do
|
105
|
-
expect(response.status).to eq(400)
|
106
|
-
end
|
107
|
-
it "should respond with a decompression error" do
|
108
|
-
expect(response.read_body).to eq("Failed to decompress body")
|
118
|
+
expect(event["message"]).to eq("Hello")
|
109
119
|
end
|
110
120
|
end
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
121
|
+
|
122
|
+
context "when using a custom codec mapping" do
|
123
|
+
subject { LogStash::Inputs::Http.new("port" => port,
|
124
|
+
"additional_codecs" => { "application/json" => "plain" }) }
|
125
|
+
it "should decode the message accordingly" do
|
126
|
+
body = { "message" => "Hello" }.to_json
|
115
127
|
agent.post!("http://localhost:#{port}/meh.json",
|
116
128
|
:headers => { "content-type" => "application/json" },
|
117
|
-
|
129
|
+
:body => body)
|
118
130
|
event = queue.pop
|
119
|
-
expect(event["
|
131
|
+
expect(event["message"]).to eq(body)
|
120
132
|
end
|
121
133
|
end
|
122
|
-
end
|
123
|
-
|
124
|
-
context "with json codec" do
|
125
|
-
subject { LogStash::Inputs::Http.new("port" => port, "codec" => "json") }
|
126
|
-
it "should parse the json body" do
|
127
|
-
subject.register
|
128
|
-
Thread.new { subject.run(queue) }
|
129
|
-
agent.post!("http://localhost:#{port}/meh.json", :body => { "message" => "Hello" }.to_json)
|
130
|
-
event = queue.pop
|
131
|
-
expect(event["message"]).to eq("Hello")
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
context "when using a custom codec mapping" do
|
136
|
-
subject { LogStash::Inputs::Http.new("port" => port,
|
137
|
-
"additional_codecs" => { "application/json" => "plain" }) }
|
138
|
-
it "should decode the message accordingly" do
|
139
|
-
body = { "message" => "Hello" }.to_json
|
140
|
-
subject.register
|
141
|
-
Thread.new { subject.run(queue) }
|
142
|
-
agent.post!("http://localhost:#{port}/meh.json",
|
143
|
-
:headers => { "content-type" => "application/json" },
|
144
|
-
:body => body)
|
145
|
-
event = queue.pop
|
146
|
-
expect(event["message"]).to eq(body)
|
147
|
-
end
|
148
|
-
end
|
149
134
|
|
150
|
-
|
151
|
-
|
152
|
-
|
135
|
+
context "when using custom headers" do
|
136
|
+
let(:custom_headers) { { 'access-control-allow-origin' => '*' } }
|
137
|
+
subject { LogStash::Inputs::Http.new("port" => port, "response_headers" => custom_headers) }
|
153
138
|
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
139
|
+
describe "the response" do
|
140
|
+
it "should include the custom headers" do
|
141
|
+
response = agent.post!("http://localhost:#{port}/meh", :body => "hello")
|
142
|
+
expect(response.headers.to_hash).to include(custom_headers)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
describe "basic auth" do
|
147
|
+
user = "test"; password = "pwd"
|
148
|
+
subject { LogStash::Inputs::Http.new("port" => port, "user" => user, "password" => password) }
|
149
|
+
let(:auth_token) { Base64.strict_encode64("#{user}:#{password}") }
|
150
|
+
context "when client doesn't present auth token" do
|
151
|
+
let!(:response) { agent.post!("http://localhost:#{port}/meh", :body => "hi") }
|
152
|
+
it "should respond with 401" do
|
153
|
+
expect(response.status).to eq(401)
|
154
|
+
end
|
155
|
+
it "should not generate an event" do
|
156
|
+
expect(queue).to be_empty
|
157
|
+
end
|
158
|
+
end
|
159
|
+
context "when client presents incorrect auth token" do
|
160
|
+
let!(:response) do
|
161
|
+
agent.post!("http://localhost:#{port}/meh",
|
162
|
+
:headers => {
|
163
|
+
"content-type" => "text/plain",
|
164
|
+
"authorization" => "Basic meh"
|
165
|
+
},
|
166
|
+
:body => "hi")
|
167
|
+
end
|
168
|
+
it "should respond with 401" do
|
169
|
+
expect(response.status).to eq(401)
|
170
|
+
end
|
171
|
+
it "should not generate an event" do
|
172
|
+
expect(queue).to be_empty
|
173
|
+
end
|
174
|
+
end
|
175
|
+
context "when client presents correct auth token" do
|
176
|
+
let!(:response) do
|
177
|
+
agent.post!("http://localhost:#{port}/meh",
|
178
|
+
:headers => {
|
179
|
+
"content-type" => "text/plain",
|
180
|
+
"authorization" => "Basic #{auth_token}"
|
181
|
+
}, :body => "hi")
|
182
|
+
end
|
183
|
+
it "should respond with 200" do
|
184
|
+
expect(response.status).to eq(200)
|
185
|
+
end
|
186
|
+
it "should generate an event" do
|
187
|
+
expect(queue).to_not be_empty
|
188
|
+
end
|
160
189
|
end
|
161
190
|
end
|
191
|
+
|
162
192
|
end
|
163
193
|
|
164
194
|
context "with :ssl => false" do
|
@@ -184,53 +214,4 @@ describe LogStash::Inputs::Http do
|
|
184
214
|
end
|
185
215
|
end
|
186
216
|
end
|
187
|
-
describe "basic auth" do
|
188
|
-
user = "test"; password = "pwd"
|
189
|
-
subject { LogStash::Inputs::Http.new("port" => port, "user" => user, "password" => password) }
|
190
|
-
let(:auth_token) { Base64.strict_encode64("#{user}:#{password}") }
|
191
|
-
before :each do
|
192
|
-
subject.register
|
193
|
-
Thread.new { subject.run(queue) }
|
194
|
-
end
|
195
|
-
context "when client doesn't present auth token" do
|
196
|
-
let!(:response) { agent.post!("http://localhost:#{port}/meh", :body => "hi") }
|
197
|
-
it "should respond with 401" do
|
198
|
-
expect(response.status).to eq(401)
|
199
|
-
end
|
200
|
-
it "should not generate an event" do
|
201
|
-
expect(queue).to be_empty
|
202
|
-
end
|
203
|
-
end
|
204
|
-
context "when client presents incorrect auth token" do
|
205
|
-
let!(:response) do
|
206
|
-
agent.post!("http://localhost:#{port}/meh",
|
207
|
-
:headers => {
|
208
|
-
"content-type" => "text/plain",
|
209
|
-
"authorization" => "Basic meh"
|
210
|
-
},
|
211
|
-
:body => "hi")
|
212
|
-
end
|
213
|
-
it "should respond with 401" do
|
214
|
-
expect(response.status).to eq(401)
|
215
|
-
end
|
216
|
-
it "should not generate an event" do
|
217
|
-
expect(queue).to be_empty
|
218
|
-
end
|
219
|
-
end
|
220
|
-
context "when client presents correct auth token" do
|
221
|
-
let!(:response) do
|
222
|
-
agent.post!("http://localhost:#{port}/meh",
|
223
|
-
:headers => {
|
224
|
-
"content-type" => "text/plain",
|
225
|
-
"authorization" => "Basic #{auth_token}"
|
226
|
-
}, :body => "hi")
|
227
|
-
end
|
228
|
-
it "should respond with 200" do
|
229
|
-
expect(response.status).to eq(200)
|
230
|
-
end
|
231
|
-
it "should generate an event" do
|
232
|
-
expect(queue).to_not be_empty
|
233
|
-
end
|
234
|
-
end
|
235
|
-
end
|
236
217
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-input-http
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,7 +128,7 @@ dependencies:
|
|
128
128
|
- - ">="
|
129
129
|
- !ruby/object:Gem::Version
|
130
130
|
version: '0'
|
131
|
-
description: This gem is a
|
131
|
+
description: This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program
|
132
132
|
email: info@elastic.co
|
133
133
|
executables: []
|
134
134
|
extensions: []
|
@@ -166,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
166
166
|
version: '0'
|
167
167
|
requirements: []
|
168
168
|
rubyforge_project:
|
169
|
-
rubygems_version: 2.
|
169
|
+
rubygems_version: 2.6.3
|
170
170
|
signing_key:
|
171
171
|
specification_version: 4
|
172
172
|
summary: Logstash Input plugin that receives HTTP requests
|