fluent-plugin-http_shadow 0.0.7 → 0.0.8

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
  SHA1:
3
- metadata.gz: b53fa8b10186511eaf719ca67d3c0512fe1872ad
4
- data.tar.gz: 7233c7e0d9ce2a9f12688ed04ff804b855350655
3
+ metadata.gz: 6cd7508da92015ce2c17fb88b0885ae03f398762
4
+ data.tar.gz: 3b2422ae678f2d72dfa0f0565e3d2d32e23c0681
5
5
  SHA512:
6
- metadata.gz: 5106be8646155b8a574b36e8abd91cf56f12e28f36ebd22809c897a421145aa519303ae73a7ba62ad285d63756a3a76b7f109a1efc549d3aac2165662a794fe4
7
- data.tar.gz: c9325e85cd66ef50ae7de8394d3eed03e22043466ea9fe6c9cd55fb20cca452de780fd34ef00d0dc4988db8d060214b20e4dbe437fdae52f0ca8bb11d2b36683
6
+ metadata.gz: d3c7ff02fcb4f8676562c8e49cf38484bc9913752813d5f31f2dfcbd4643fd2774de04c3bc19a21a64d003a328b222d0538ee7e416c199139c3f76cc1a0bd5c9
7
+ data.tar.gz: da4d65b41b113bd1c9fa19864a5e7085f8b9ff7a3d539582c95e467de156617ecffc484a63e96ebbca878fc26c7fa2687f4edd98a0ac09878897b268441661fc
data/README.md CHANGED
@@ -60,6 +60,7 @@ GET http://staging.exsample.com/hoge/?id=1
60
60
  host_key host
61
61
  path_format ${path}
62
62
  method_key method
63
+ protocol_format ${x_forwarded_proto} # default: http
63
64
  header_hash { "Referer": "${referer}", "User-Agent": "${user_agent}" }
64
65
  </match>
65
66
  ```
@@ -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.7"
5
+ gem.version = "0.0.8"
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"
@@ -1,6 +1,7 @@
1
1
  module Fluent
2
2
  class HttpShadowOutput < Fluent::BufferedOutput
3
3
  Fluent::Plugin.register_output('http_shadow', self)
4
+ SUPPORT_PROTOCOLS = ['http', 'https']
4
5
 
5
6
  def initialize
6
7
  super
@@ -24,6 +25,7 @@ module Fluent
24
25
  config_param :password, :string, :default => nil
25
26
  config_param :rate, :integer, :default => 100
26
27
  config_param :replace_hash, :hash, :default => nil
28
+ config_param :protocol_format, :string, :default => 'http'
27
29
 
28
30
  def configure(conf)
29
31
  super
@@ -36,6 +38,7 @@ module Fluent
36
38
  super
37
39
  @regexp = /\$\{([^}]+)\}/
38
40
  @path_format = ERB.new(@path_format.gsub(@regexp, "<%=record['" + '\1' + "'] %>"))
41
+ @protocol_format = ERB.new(@protocol_format.gsub(@regexp, "<%=record['" + '\1' + "'] %>"))
39
42
 
40
43
  @headers = get_formatter(@header_hash)
41
44
  @cookies = get_formatter(@cookie_hash)
@@ -81,8 +84,10 @@ module Fluent
81
84
  method = (record[@method_key] || 'get').downcase.to_sym
82
85
  path = @path_format.result(binding)
83
86
  path = replace_string(path) if @replace_hash
87
+ protocol = @protocol_format.result(binding)
88
+ protocol = SUPPORT_PROTOCOLS.include?(protocol) ? protocol : 'http'
84
89
 
85
- url = "http://" + host + path
90
+ url = "#{protocol}://" + host + path
86
91
  uri = Addressable::URI.parse(url)
87
92
  params = uri.query_values
88
93
  params.merge(record[@params_key]) unless record[@params_key].nil?
@@ -97,7 +102,7 @@ module Fluent
97
102
  }
98
103
  option[:userpwd] = "#{@username}:#{@password}" if @username
99
104
 
100
- Typhoeus::Request.new("http://" + host + uri.path, option)
105
+ Typhoeus::Request.new("#{protocol}://" + host + uri.path, option)
101
106
  end
102
107
 
103
108
  def get_formatter(hash)
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.7
4
+ version: 0.0.8
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-06-24 00:00:00.000000000 Z
11
+ date: 2015-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus