111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
# File 'lib/fluent/plugin/in_http_pull.rb', line 111
def on_timer
record = { "url" => @url }
begin
request_options = { method: @http_method, url: @url, timeout: @timeout, headers: @_request_headers }
request_options[:proxy] = @proxy if @proxy
request_options[:user] = @user if @user
request_options[:password] = @password if @password
request_options[:verify_ssl] = @verify_ssl
if @verify_ssl and @ca_path and @ca_file
request_options[:ssl_ca_path] = @ca_path
request_options[:ssl_ca_file] = @ca_file
end
res = RestClient::Request.execute request_options
record["status"] = res.code
record["body"] = res.body
record["header"] = {} unless @response_headers.empty?
@response_headers.each do |section|
name = section["header"]
symbolize_name = name.downcase.gsub(/-/, '_').to_sym
record["header"][name] = res.[symbolize_name]
end
rescue StandardError => err
if err.respond_to? :http_code
record["status"] = err.http_code || 0
else
record["status"] = 0
end
record["error"] = err.message
end
record_time = Engine.now
if !@status_only && record["body"] != nil
@parser.parse(record["body"]) do |time, message|
record["message"] = message
record_time = time
end
end
record.delete("body")
router.emit(@tag, record_time, record)
end
|