logstash-output-bcdb 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,38 +1,38 @@
1
- # encoding: utf-8
2
- #
3
- # based on relistan's rack handler
4
- # out of the box rack only gives use the rack deflater handler to return compressed
5
- # response, this gist offer the inverse and should work on all rack based app like sinatra or rails.
6
- #
7
- # original source: https://gist.github.com/relistan/2109707
8
- require "zlib"
9
-
10
- class CompressedRequests
11
- def initialize(app)
12
- @app = app
13
- end
14
-
15
- def encoding_handled?(env)
16
- ['gzip', 'deflate'].include? env['HTTP_CONTENT_ENCODING']
17
- end
18
-
19
- def call(env)
20
- if encoding_handled?(env)
21
- extracted = decode(env['rack.input'], env['HTTP_CONTENT_ENCODING'])
22
-
23
- env.delete('HTTP_CONTENT_ENCODING')
24
- env['CONTENT_LENGTH'] = extracted.bytesize
25
- env['rack.input'] = StringIO.new(extracted)
26
- end
27
-
28
- status, headers, response = @app.call(env)
29
- return [status, headers, response]
30
- end
31
-
32
- def decode(input, content_encoding)
33
- case content_encoding
34
- when 'gzip' then Zlib::GzipReader.new(input).read
35
- when 'deflate' then Zlib::Inflate.inflate(input.read)
36
- end
37
- end
38
- end
1
+ # encoding: utf-8
2
+ #
3
+ # based on relistan's rack handler
4
+ # out of the box rack only gives use the rack deflater handler to return compressed
5
+ # response, this gist offer the inverse and should work on all rack based app like sinatra or rails.
6
+ #
7
+ # original source: https://gist.github.com/relistan/2109707
8
+ require "zlib"
9
+
10
+ class CompressedRequests
11
+ def initialize(app)
12
+ @app = app
13
+ end
14
+
15
+ def encoding_handled?(env)
16
+ ['gzip', 'deflate'].include? env['HTTP_CONTENT_ENCODING']
17
+ end
18
+
19
+ def call(env)
20
+ if encoding_handled?(env)
21
+ extracted = decode(env['rack.input'], env['HTTP_CONTENT_ENCODING'])
22
+
23
+ env.delete('HTTP_CONTENT_ENCODING')
24
+ env['CONTENT_LENGTH'] = extracted.bytesize
25
+ env['rack.input'] = StringIO.new(extracted)
26
+ end
27
+
28
+ status, headers, response = @app.call(env)
29
+ return [status, headers, response]
30
+ end
31
+
32
+ def decode(input, content_encoding)
33
+ case content_encoding
34
+ when 'gzip' then Zlib::GzipReader.new(input).read
35
+ when 'deflate' then Zlib::Inflate.inflate(input.read)
36
+ end
37
+ end
38
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-output-bcdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Modex
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-23 00:00:00.000000000 Z
11
+ date: 2022-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logstash-core-plugin-api
@@ -132,7 +132,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
132
  - !ruby/object:Gem::Version
133
133
  version: '0'
134
134
  requirements: []
135
- rubygems_version: 3.1.2
135
+ rubyforge_project:
136
+ rubygems_version: 2.7.6
136
137
  signing_key:
137
138
  specification_version: 4
138
139
  summary: Sends events to a BCDB Database endpoint