fluent-plugin-out-http 1.1.4 → 1.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3ec10329a626597058faa33835bcc4b553d28595fc973353e5807f1ffbea4036
4
- data.tar.gz: 6ee543bbd1835b69d9bd80cf1b13af9e9f39d3fcd83ee823425408607d8fc240
3
+ metadata.gz: 20528b9969ef989e76a578e92acc7c6f9079cd178343fb976bb3a9539811082e
4
+ data.tar.gz: 42d677355ce88012cc89ad5b47a831ffd3f62fd127f2e7ca15bf7d8b30629253
5
5
  SHA512:
6
- metadata.gz: 9dfb53ea8a4773adf2407646e34cb98c8d789d472220b066a90b51a325fea123a2f9af283c02f2fb304c0e0e3e0df67187d4883c936c8dcb329c90853d533fc6
7
- data.tar.gz: 4bb782810c5f9c5bebf2b56c3be308809e6788d35211a814bdfb9b9e15628f866282ee49a9011d64c2682c0eed2bd6c1540d8d2ee63afad0405ef4f67aca86c9
6
+ metadata.gz: 07ba94b30b47f82dbe1973e2a7e49447927509d025fdd2caa97403d9e58daae623e6aaa007038388725794a315546cc120aac3e4b78b14911bd378b4be42d249
7
+ data.tar.gz: 0fc8df5a1224ec02e166e5f8c5643340a390333e65fdae87e155a211a001fd63268eafbd5df8b992196ab8e0e6818f09c2970cb8c94a671c7ab452155e918109
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ### 1.1.5
4
+ * Add :raw serializer
5
+
3
6
  ### 1.1.4
4
7
  * Add custom formatter feature
5
8
  * Tweak Travis CI tasks
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = "fluent-plugin-out-http"
5
- gem.version = "1.1.4"
5
+ gem.version = "1.1.5"
6
6
  gem.authors = ["Marica Odagaki"]
7
7
  gem.email = ["ento.entotto@gmail.com"]
8
8
  gem.summary = %q{A generic Fluentd output plugin to send logs to an HTTP endpoint}
@@ -24,8 +24,8 @@ class Fluent::Plugin::HTTPOutput < Fluent::Plugin::Output
24
24
  # HTTP method
25
25
  config_param :http_method, :enum, list: [:get, :put, :post, :delete], :default => :post
26
26
 
27
- # form | json
28
- config_param :serializer, :enum, list: [:json, :form, :text], :default => :form
27
+ # form | json | text | raw
28
+ config_param :serializer, :enum, list: [:json, :form, :text, :raw], :default => :form
29
29
 
30
30
  # Simple rate limiting: ignore any records within `rate_limit_msec`
31
31
  # since the last one.
@@ -93,6 +93,8 @@ class Fluent::Plugin::HTTPOutput < Fluent::Plugin::Output
93
93
  set_json_body(req, record)
94
94
  elsif @serializer == :text
95
95
  set_text_body(req, record)
96
+ elsif @serializer == :raw
97
+ set_raw_body(req, record)
96
98
  else
97
99
  req.set_form_data(record)
98
100
  end
@@ -120,6 +122,11 @@ class Fluent::Plugin::HTTPOutput < Fluent::Plugin::Output
120
122
  req['Content-Type'] = 'text/plain'
121
123
  end
122
124
 
125
+ def set_raw_body(req, data)
126
+ req.body = data.to_s
127
+ req['Content-Type'] = 'application/octet-stream'
128
+ end
129
+
123
130
  def create_request(tag, time, record)
124
131
  url = format_url(tag, time, record)
125
132
  uri = URI.parse(url)
@@ -104,6 +104,8 @@ class HTTPOutputTestBase < Test::Unit::TestCase
104
104
  elsif req.content_type == 'text/plain'
105
105
  puts req
106
106
  record[:data] = req.body
107
+ elsif req.content_type == 'application/octet-stream'
108
+ record[:data] = req.body
107
109
  else
108
110
  record[:form] = Hash[*(req.body.split('&').map{|kv|kv.split('=')}.flatten)]
109
111
  end
@@ -219,6 +221,11 @@ class HTTPOutputTest < HTTPOutputTestBase
219
221
  serializer text
220
222
  ]
221
223
 
224
+ CONFIG_RAW = %[
225
+ endpoint_url http://127.0.0.1:#{port}/api/
226
+ serializer raw
227
+ ]
228
+
222
229
  CONFIG_PUT = %[
223
230
  endpoint_url http://127.0.0.1:#{port}/api/
224
231
  http_method put
@@ -470,6 +477,18 @@ class HTTPOutputTest < HTTPOutputTestBase
470
477
  assert_nil record[:auth]
471
478
  end
472
479
 
480
+ def test_emit_raw
481
+ binary_string = "\xe3\x81\x82"
482
+ d = create_driver CONFIG_RAW + %[format msgpack]
483
+ d.run(default_tag: 'test.metrics') do
484
+ d.feed({ "message" => "hello" })
485
+ end
486
+ assert_equal 1, @posts.size
487
+ record = @posts[0]
488
+ assert_equal ({ "message" => "hello" }).to_msgpack, record[:data]
489
+ assert_nil record[:auth]
490
+ end
491
+
473
492
  def test_http_error_is_raised
474
493
  d = create_driver CONFIG_HTTP_ERROR
475
494
  assert_raise Errno::ECONNREFUSED do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-out-http
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marica Odagaki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-15 00:00:00.000000000 Z
11
+ date: 2019-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yajl-ruby