logstash-filter-http 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 676e5abcdac3f6a16a8274eb18793cd7d75fe26545f7b2bfee9f707b6cf1fb90
4
- data.tar.gz: 3ed6f080ba7323a07621cc69380f693a07b51ab5b374d0172d660a8682396f90
3
+ metadata.gz: 4d5469fab82031f6b39e205f18142291d9896c97cd4b650c5124ff0f661ca945
4
+ data.tar.gz: 878169ea102e2c342fabed654cc8d265df31a7a935fbe8dd4260f79c2b393fce
5
5
  SHA512:
6
- metadata.gz: 76adf00a0498d9f2f1d43b898457d744dce0a8ecef5bc15b559682513e2fc3cf09747925dea0a01b515762cbba9f9e5106ee316ea7c44a420a13b67596c24656
7
- data.tar.gz: ceeaadb9afcc5678f87f7b1d3ccf6446d56826db73354655bc5f4976d0bf07698bc061db234fd27cf569de9fd1b467dbb6a75c918a04929918235ef42a08869e
6
+ metadata.gz: 6f0f5d51f50ec667de851cf7223d004062d3946c1bc0ee4b849edb3de26bc3da5246a168502c3a169023d646772835f79ebf990daf615085e4ce57a8ed5cc2db
7
+ data.tar.gz: 25d1125226d4c5adbc0bb74bac0ba1d0e7aa02eba55d765e0a15c084638efea664bab10e618eeb80d85e36cc4e94140708c93b26fab6843e3c9a15d13947732a
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 1.2.1
2
+ - Fix: do not set content-type if provided by user [#36](https://github.com/logstash-plugins/logstash-filter-http/pull/36)
3
+
1
4
  ## 1.2.0
2
5
  - Feat: improve ECS compatibility [#35](https://github.com/logstash-plugins/logstash-filter-http/pull/35)
3
6
 
@@ -59,10 +59,8 @@ class LogStash::Filters::Http < LogStash::Filters::Base
59
59
  def filter(event)
60
60
  url_for_event = event.sprintf(@url)
61
61
  headers_sprintfed = sprintf_object(event, @headers)
62
- if body_format == "json"
63
- headers_sprintfed["content-type"] = "application/json"
64
- else
65
- headers_sprintfed["content-type"] = "text/plain"
62
+ if !headers_sprintfed.key?('content-type') && !headers_sprintfed.key?('Content-Type')
63
+ headers_sprintfed['content-type'] = @body_format == "json" ? "application/json" : "text/plain"
66
64
  end
67
65
  query_sprintfed = sprintf_object(event, @query)
68
66
  body_sprintfed = sprintf_object(event, @body)
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-filter-http'
3
- s.version = '1.2.0'
3
+ s.version = '1.2.1'
4
4
  s.licenses = ['Apache License (2.0)']
5
5
  s.summary = 'This filter requests data from a RESTful Web Service.'
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/logstash-plugin install logstash-filter-http. This gem is not a stand-alone program'
@@ -209,12 +209,14 @@ describe LogStash::Filters::Http do
209
209
  end.and_return(response)
210
210
  subject.filter(event)
211
211
  end
212
+
212
213
  it "sets content-type to application/json" do
213
214
  expect(subject).to receive(:request_http) do |verb, url, options|
214
215
  expect(options).to include(:headers => { "content-type" => "application/json"})
215
216
  end.and_return(response)
216
217
  subject.filter(event)
217
218
  end
219
+
218
220
  end
219
221
  context "when is text" do
220
222
  let(:body_format) { "text" }
@@ -226,12 +228,29 @@ describe LogStash::Filters::Http do
226
228
  end.and_return(response)
227
229
  subject.filter(event)
228
230
  end
231
+
229
232
  it "sets content-type to text/plain" do
230
233
  expect(subject).to receive(:request_http) do |verb, url, options|
231
234
  expect(options).to include(:headers => { "content-type" => "text/plain"})
232
235
  end.and_return(response)
233
236
  subject.filter(event)
234
237
  end
238
+
239
+ context 'content-type header present' do
240
+
241
+ let(:config) { super().merge 'headers' => { 'X-UA' => 'FOO', 'Content-Type' => 'application/x-www-form-urlencoded' } }
242
+
243
+ it "respects set header and does not add another" do
244
+ expect(subject).to receive(:request_http) do |verb, url, options|
245
+ headers = options[:headers]
246
+ expect(headers).to include("Content-Type" => "application/x-www-form-urlencoded")
247
+ expect(headers).to_not include("content-type")
248
+ end.and_return(response)
249
+ subject.filter(event)
250
+ end
251
+
252
+ end
253
+
235
254
  end
236
255
  end
237
256
  context "when using field references" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-filter-http
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-06 00:00:00.000000000 Z
11
+ date: 2021-12-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement