fluent-plugin-http-pull 0.8.2 → 0.8.3
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 +4 -4
- data/fluent-plugin-http-pull.gemspec +1 -1
- data/lib/fluent/plugin/in_http_pull.rb +46 -34
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ebdf162fc73a902dcc82066deded9baa3e6db27fc1bcaefafffc8853ba56414
|
4
|
+
data.tar.gz: bae9f6c485df205a49f6cc02d677dcab14b7a6a1001b1c5ae1d6750e7ea878b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 693cb1b84e4c6404dad557220d76985a3748d072f94ed50dcb33d37d48e8d49d40a425daf237e6d5d5dc38fb7f67fc1d5a712689abf7370a100d19d7db95e842
|
7
|
+
data.tar.gz: f9c936914205618d366b78a15bde44f00e65949783bb362b9ad9a743f8df609292d8d3e1129e8c9a29fc41e801767b11c5f3c88503fa47f3b2dc9ae491bb9e43
|
@@ -109,53 +109,24 @@ module Fluent
|
|
109
109
|
end
|
110
110
|
|
111
111
|
def on_timer
|
112
|
-
|
112
|
+
body = nil
|
113
|
+
record = nil
|
113
114
|
|
114
115
|
begin
|
115
|
-
request_options = { method: @http_method, url: @url, timeout: @timeout, headers: @_request_headers }
|
116
|
-
|
117
|
-
request_options[:proxy] = @proxy if @proxy
|
118
|
-
request_options[:user] = @user if @user
|
119
|
-
request_options[:password] = @password if @password
|
120
|
-
|
121
|
-
request_options[:verify_ssl] = @verify_ssl
|
122
|
-
if @verify_ssl and @ca_path and @ca_file
|
123
|
-
request_options[:ssl_ca_path] = @ca_path
|
124
|
-
request_options[:ssl_ca_file] = @ca_file
|
125
|
-
end
|
126
|
-
|
127
116
|
res = RestClient::Request.execute request_options
|
117
|
+
record, body = get_record(res)
|
128
118
|
|
129
|
-
record["status"] = res.code
|
130
|
-
record["body"] = res.body
|
131
|
-
|
132
|
-
record["header"] = {} unless @response_headers.empty?
|
133
|
-
@response_headers.each do |section|
|
134
|
-
name = section["header"]
|
135
|
-
symbolize_name = name.downcase.gsub(/-/, '_').to_sym
|
136
|
-
|
137
|
-
record["header"][name] = res.headers[symbolize_name]
|
138
|
-
end
|
139
119
|
rescue StandardError => err
|
120
|
+
record = { "url" => @url, "error" => err.message }
|
140
121
|
if err.respond_to? :http_code
|
141
122
|
record["status"] = err.http_code || 0
|
142
123
|
else
|
143
124
|
record["status"] = 0
|
144
125
|
end
|
145
|
-
|
146
|
-
record["error"] = err.message
|
147
126
|
end
|
148
127
|
|
149
128
|
record_time = Engine.now
|
150
|
-
|
151
|
-
if !@status_only && record["body"] != nil
|
152
|
-
@parser.parse(record["body"]) do |time, message|
|
153
|
-
record["message"] = message
|
154
|
-
record_time = time
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
158
|
-
record.delete("body")
|
129
|
+
record = parse(record, body)
|
159
130
|
router.emit(@tag, record_time, record)
|
160
131
|
end
|
161
132
|
|
@@ -163,6 +134,47 @@ module Fluent
|
|
163
134
|
super
|
164
135
|
end
|
165
136
|
|
137
|
+
private
|
138
|
+
def request_options
|
139
|
+
options = { method: @http_method, url: @url, timeout: @timeout, headers: @_request_headers }
|
140
|
+
|
141
|
+
options[:proxy] = @proxy if @proxy
|
142
|
+
options[:user] = @user if @user
|
143
|
+
options[:password] = @password if @password
|
144
|
+
|
145
|
+
options[:verify_ssl] = @verify_ssl
|
146
|
+
if @verify_ssl and @ca_path and @ca_file
|
147
|
+
options[:ssl_ca_path] = @ca_path
|
148
|
+
options[:ssl_ca_file] = @ca_file
|
149
|
+
end
|
150
|
+
|
151
|
+
return options
|
152
|
+
end
|
153
|
+
|
154
|
+
def get_record(response)
|
155
|
+
body = response.body
|
156
|
+
record = { "url" => @url, "status" => response.code }
|
157
|
+
record["header"] = {} unless @response_headers.empty?
|
158
|
+
@response_headers.each do |section|
|
159
|
+
name = section["header"]
|
160
|
+
symbolize_name = name.downcase.gsub(/-/, '_').to_sym
|
161
|
+
|
162
|
+
record["header"][name] = response.headers[symbolize_name]
|
163
|
+
end
|
164
|
+
|
165
|
+
return record, body
|
166
|
+
end
|
167
|
+
|
168
|
+
def parse(record, body)
|
169
|
+
if !@status_only && body != nil
|
170
|
+
@parser.parse(body) do |time, message|
|
171
|
+
record["message"] = message
|
172
|
+
record_time = time
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
return record
|
177
|
+
end
|
166
178
|
end
|
167
179
|
end
|
168
180
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-http-pull
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- filepang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|