# Use system CA certificates
@api_client.ssl_config.add_trust_ca('/etc/ssl/certs')
end
+ if Rails.configuration.api_response_compression
+ @api_client.transparent_gzip_decompression = true
+ end
end
end
url.sub! '/arvados/v1/../../', '/'
query = {
- 'api_token' => tokens[:arvados_api_token] || Thread.current[:arvados_api_token] || '',
- 'reader_tokens' => (tokens[:reader_tokens] || Thread.current[:reader_tokens] || []).to_json,
+ 'api_token' => (tokens[:arvados_api_token] ||
+ Thread.current[:arvados_api_token] ||
+ ''),
+ 'reader_tokens' => ((tokens[:reader_tokens] ||
+ Thread.current[:reader_tokens] ||
+ []) +
+ [Rails.configuration.anonymous_user_token]).to_json,
}
if !data.nil?
data.each do |k,v|
elsif v == false
query[k] = 0
else
- query[k] = JSON.dump(v)
+ query[k] = Oj.dump(v, mode: :compat)
end
end
else
query["_method"] = "GET"
end
- # Use anonymous token for GET requests when no api_token is available
- if ((query["_method"] == "GET") or (query[:_method] == "GET")) && query["api_token"].empty?
- query['api_token'] = Rails.configuration.anonymous_user_token
- end
-
if @@profiling_enabled
query["_profile"] = "true"
end
header = {"Accept" => "application/json"}
- profile_checkpoint { "Prepare request #{url} #{query[:uuid]} #{query[:where]} #{query[:filters]} #{query[:order]}" }
+ profile_checkpoint { "Prepare request #{query["_method"] or "POST"} #{url} #{query[:uuid]} #{query.inspect[0,256]}" }
msg = @client_mtx.synchronize do
begin
@api_client.post(url, query, header: header)
end
end
profile_checkpoint 'API transaction'
+ if @@profiling_enabled
+ if msg.headers['X-Runtime']
+ Rails.logger.info "API server: #{msg.headers['X-Runtime']} runtime reported"
+ end
+ Rails.logger.info "Content-Encoding #{msg.headers['Content-Encoding'].inspect}, Content-Length #{msg.headers['Content-Length'].inspect}, actual content size #{msg.content.size}"
+ end
begin
resp = Oj.load(msg.content, :symbol_keys => true)