fluent-plugin-http_shadow 0.0.8 → 0.0.9

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: 6cd7508da92015ce2c17fb88b0885ae03f398762
4
- data.tar.gz: 3b2422ae678f2d72dfa0f0565e3d2d32e23c0681
3
+ metadata.gz: f8a930a8ebb5540b8b38c449bf9ef7328cfb4068
4
+ data.tar.gz: 6c2a747dc2e12f5cb7d774d1e30964ff68c80673
5
5
  SHA512:
6
- metadata.gz: d3c7ff02fcb4f8676562c8e49cf38484bc9913752813d5f31f2dfcbd4643fd2774de04c3bc19a21a64d003a328b222d0538ee7e416c199139c3f76cc1a0bd5c9
7
- data.tar.gz: da4d65b41b113bd1c9fa19864a5e7085f8b9ff7a3d539582c95e467de156617ecffc484a63e96ebbca878fc26c7fa2687f4edd98a0ac09878897b268441661fc
6
+ metadata.gz: 593f1ca4709653305671b95089cb28318ae9110562ac47e264722f970a574081d85939d7436ec1c187dad4d7c95c09ee59760e72e1e7a66d91336324bcb24f02
7
+ data.tar.gz: 79e64101e5fecfbab0d38f8de68407577f360c76498728fbd955bc12cb8a43352a1403ddac660ce98d90f784266489d73c5c629c8c8b1b9e300cd128b6504a4c
data/README.md CHANGED
@@ -34,6 +34,7 @@ Assume following input is coming:
34
34
  "path": "/hoge/?id=1",
35
35
  "code": "200",
36
36
  "size": "1578",
37
+ "x_forwarded_proto": "http",
37
38
  "referer": "http://exsample.com/other/",
38
39
  "agent": "Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko"
39
40
  }
@@ -62,6 +63,7 @@ GET http://staging.exsample.com/hoge/?id=1
62
63
  method_key method
63
64
  protocol_format ${x_forwarded_proto} # default: http
64
65
  header_hash { "Referer": "${referer}", "User-Agent": "${user_agent}" }
66
+ no_send_header_pattern ^(-|)$
65
67
  </match>
66
68
  ```
67
69
 
@@ -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.8"
5
+ gem.version = "0.0.9"
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"
@@ -26,6 +26,7 @@ module Fluent
26
26
  config_param :rate, :integer, :default => 100
27
27
  config_param :replace_hash, :hash, :default => nil
28
28
  config_param :protocol_format, :string, :default => 'http'
29
+ config_param :no_send_header_pattern, :string, :default => nil
29
30
 
30
31
  def configure(conf)
31
32
  super
@@ -42,6 +43,10 @@ module Fluent
42
43
 
43
44
  @headers = get_formatter(@header_hash)
44
45
  @cookies = get_formatter(@cookie_hash)
46
+
47
+ if @no_send_header_pattern
48
+ @no_send_header_pattern = Regexp.new(@no_send_header_pattern)
49
+ end
45
50
  end
46
51
 
47
52
  def shutdown
@@ -115,15 +120,6 @@ module Fluent
115
120
  formatter
116
121
  end
117
122
 
118
- def get_header(record)
119
- header = {}
120
- @headers.each do |k, v|
121
- header[k] = v.result(binding)
122
- end
123
- header['Cookie'] = get_cookie_string(record) if @cookie_hash
124
- header
125
- end
126
-
127
123
  def replace_string(str)
128
124
  return nil if str.nil?
129
125
  @replace_hash.each do |k, v|
@@ -136,10 +132,31 @@ module Fluent
136
132
  Hash[params.map { |k,v| [k, replace_string(v)] }]
137
133
  end
138
134
 
135
+ def get_header(record)
136
+ header = {}
137
+ @headers.each do |k, v|
138
+ value = v.result(binding)
139
+ if @no_send_header_pattern
140
+ header[k] = value unless @no_send_header_pattern.match(value)
141
+ else
142
+ header[k] = value
143
+ end
144
+ end
145
+ header['Cookie'] = get_cookie_string(record) if @cookie_hash
146
+ header
147
+ end
148
+
139
149
  def get_cookie_string(record)
140
- @cookies.map{|k, v|
141
- "#{k}=#{v.result(binding)}"
142
- }.join('; ')
150
+ cookie = []
151
+ @cookies.each do |k, v|
152
+ value = v.result(binding)
153
+ if @no_send_header_pattern
154
+ cookie << "#{k}=#{value}" unless @no_send_header_pattern.match(value)
155
+ else
156
+ cookie << "#{k}=#{value}"
157
+ end
158
+ end
159
+ cookie.join('; ')
143
160
  end
144
161
  end
145
162
  end
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.8
4
+ version: 0.0.9
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-19 00:00:00.000000000 Z
11
+ date: 2015-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus