lib/fluent/plugin/wendelin_client.rb in fluent-plugin-wendelin-0.2 vs lib/fluent/plugin/wendelin_client.rb in fluent-plugin-wendelin-0.3
- old
+ new
@@ -39,14 +39,14 @@
req = Net::HTTP::Post.new(uri)
if @credentials.has_key?('user')
req.basic_auth @credentials['user'], @credentials['password']
end
- # TODO ensure content-type is 'raw', e.g. this way
- # (but then querystring ?reference=... is lost)
- # req.body = data_chunk
- # req.content_type = 'application/octet-stream'
- req.set_form_data('data_chunk' => data_chunk)
+ # When using 'application/x-www-form-urlencoded', Ruby encodes with regex
+ # and it is far too slow. Such POST is legit:
+ # https://stackoverflow.com/a/14710450
+ req.body = data_chunk
+ req.content_type = 'application/octet-stream'
@log.on_trace do
@log.trace '>>> REQUEST'
@log.trace "method\t=> #{req.method}"
@log.trace "path\t=> #{req.path}"