fluent-plugin-http_shadow 0.0.9 → 0.1.0

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
  SHA1:
3
- metadata.gz: f8a930a8ebb5540b8b38c449bf9ef7328cfb4068
4
- data.tar.gz: 6c2a747dc2e12f5cb7d774d1e30964ff68c80673
3
+ metadata.gz: 3a9d29147a3f99994547fb1378583e77634ae8d3
4
+ data.tar.gz: bb7dc39257f466df902b250231b8e3a16ea9b50d
5
5
  SHA512:
6
- metadata.gz: 593f1ca4709653305671b95089cb28318ae9110562ac47e264722f970a574081d85939d7436ec1c187dad4d7c95c09ee59760e72e1e7a66d91336324bcb24f02
7
- data.tar.gz: 79e64101e5fecfbab0d38f8de68407577f360c76498728fbd955bc12cb8a43352a1403ddac660ce98d90f784266489d73c5c629c8c8b1b9e300cd128b6504a4c
6
+ metadata.gz: 579f5881ef955bc48fb5f700c2c129b9250fdd2481e360afd57e7b32996d34fc2756d88116facc22bf95ced80ba4260559e137fe33a48a8677f92681f00b19d1
7
+ data.tar.gz: 2cecd61dde598ab66c0a12d4da24c88674f581aed98ab86a009dd289f879ee9a738a8b0287f038ba6daa2eefd77bab2d6393d189a567bbbc2e1a94a3d08764f8
data/README.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  copy http request. use shadow proxy server.
4
4
 
5
+ ![Qiita](https://embed.gyazo.com/59d5fe9c4430325f6ad59c638971cc25.png "Qiita")
6
+
7
+ restored the http request from the logs that are sent to the fluentd.
8
+
5
9
  ## Examples
6
10
  ```
7
11
  <source>
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = "fluent-plugin-http_shadow"
5
- gem.version = "0.0.9"
5
+ gem.version = "0.1.0"
6
6
  gem.summary = %q{copy http request. use shadow proxy server.}
7
7
  gem.description = %q{copy http request. use shadow proxy server.}
8
8
  gem.license = "MIT"
@@ -18,8 +18,8 @@ Gem::Specification.new do |gem|
18
18
  gem.add_runtime_dependency "typhoeus"
19
19
  gem.add_runtime_dependency "addressable"
20
20
  gem.add_runtime_dependency "string-scrub" if RUBY_VERSION.to_f < 2.1
21
- gem.add_development_dependency 'bundler', '~> 1.7.2'
22
- gem.add_development_dependency 'fluentd', '~> 0.10.58'
21
+ gem.add_development_dependency 'bundler'
22
+ gem.add_development_dependency 'fluentd'
23
23
  gem.add_development_dependency 'pry', '~> 0.10.1'
24
24
  gem.add_development_dependency 'rake', '~> 10.3.2'
25
25
  gem.add_development_dependency 'rubocop', '~> 0.24.1'
@@ -2,6 +2,8 @@ module Fluent
2
2
  class HttpShadowOutput < Fluent::BufferedOutput
3
3
  Fluent::Plugin.register_output('http_shadow', self)
4
4
  SUPPORT_PROTOCOLS = ['http', 'https']
5
+ PLACEHOLDER_REGEXP = /\$\{([^}]+)\}/
6
+ ERB_REGEXP = "<%=record['" + '\1' + "'] %>"
5
7
 
6
8
  def initialize
7
9
  super
@@ -37,15 +39,14 @@ module Fluent
37
39
 
38
40
  def start
39
41
  super
40
- @regexp = /\$\{([^}]+)\}/
41
- @path_format = ERB.new(@path_format.gsub(@regexp, "<%=record['" + '\1' + "'] %>"))
42
- @protocol_format = ERB.new(@protocol_format.gsub(@regexp, "<%=record['" + '\1' + "'] %>"))
42
+ @path_format = ERB.new(@path_format.gsub(PLACEHOLDER_REGEXP, ERB_REGEXP))
43
+ @protocol_format = ERB.new(@protocol_format.gsub(PLACEHOLDER_REGEXP, ERB_REGEXP))
43
44
 
44
45
  @headers = get_formatter(@header_hash)
45
46
  @cookies = get_formatter(@cookie_hash)
46
47
 
47
48
  if @no_send_header_pattern
48
- @no_send_header_pattern = Regexp.new(@no_send_header_pattern)
49
+ @no_send_header_pattern = /#{@no_send_header_pattern}/
49
50
  end
50
51
  end
51
52
 
@@ -92,7 +93,8 @@ module Fluent
92
93
  protocol = @protocol_format.result(binding)
93
94
  protocol = SUPPORT_PROTOCOLS.include?(protocol) ? protocol : 'http'
94
95
 
95
- url = "#{protocol}://" + host + path
96
+ base_url = "#{protocol}://" + host
97
+ url = base_url + path
96
98
  uri = Addressable::URI.parse(url)
97
99
  params = uri.query_values
98
100
  params.merge(record[@params_key]) unless record[@params_key].nil?
@@ -107,14 +109,14 @@ module Fluent
107
109
  }
108
110
  option[:userpwd] = "#{@username}:#{@password}" if @username
109
111
 
110
- Typhoeus::Request.new("#{protocol}://" + host + uri.path, option)
112
+ Typhoeus::Request.new(base_url + uri.path, option)
111
113
  end
112
114
 
113
115
  def get_formatter(hash)
114
116
  formatter = {}
115
117
  return formatter unless hash
116
118
  hash.each do |k, v|
117
- format = v.gsub(@regexp, "<%=record['" + '\1' + "'] %>")
119
+ format = v.gsub(PLACEHOLDER_REGEXP, ERB_REGEXP)
118
120
  formatter[k] = ERB.new(format)
119
121
  end
120
122
  formatter
@@ -137,7 +139,7 @@ module Fluent
137
139
  @headers.each do |k, v|
138
140
  value = v.result(binding)
139
141
  if @no_send_header_pattern
140
- header[k] = value unless @no_send_header_pattern.match(value)
142
+ header[k] = value unless @no_send_header_pattern =~ value
141
143
  else
142
144
  header[k] = value
143
145
  end
@@ -150,10 +152,11 @@ module Fluent
150
152
  cookie = []
151
153
  @cookies.each do |k, v|
152
154
  value = v.result(binding)
155
+ pair = "#{k}=#{value}"
153
156
  if @no_send_header_pattern
154
- cookie << "#{k}=#{value}" unless @no_send_header_pattern.match(value)
157
+ cookie << pair unless @no_send_header_pattern =~ value
155
158
  else
156
- cookie << "#{k}=#{value}"
159
+ cookie << pair
157
160
  end
158
161
  end
159
162
  cookie.join('; ')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-http_shadow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiroshi Toyama
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-26 00:00:00.000000000 Z
11
+ date: 2016-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus
@@ -42,30 +42,30 @@ dependencies:
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 1.7.2
47
+ version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 1.7.2
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: fluentd
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: 0.10.58
61
+ version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: 0.10.58
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: pry
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -174,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
174
174
  version: '0'
175
175
  requirements: []
176
176
  rubyforge_project:
177
- rubygems_version: 2.4.2
177
+ rubygems_version: 2.4.8
178
178
  signing_key:
179
179
  specification_version: 4
180
180
  summary: copy http request. use shadow proxy server.