X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/f88b3d8cad3775806f1fc7ac8a382cba7e3be639..44f89a6814bc6b2f5bd96e16e5e12d1a0e0aadda:/services/api/app/controllers/application_controller.rb diff --git a/services/api/app/controllers/application_controller.rb b/services/api/app/controllers/application_controller.rb index 62b0ebd2e8..c39bdde4b8 100644 --- a/services/api/app/controllers/application_controller.rb +++ b/services/api/app/controllers/application_controller.rb @@ -196,7 +196,7 @@ class ApplicationController < ActionController::Base end err[:errors] ||= args err[:errors].map! do |err| - err += " (" + Thread.current[:request_id] + ")" + err += " (#{request.request_id})" end err[:error_token] = [Time.now.utc.to_i, "%08x" % rand(16 ** 8)].join("+") status = err.delete(:status) || 422 @@ -397,7 +397,7 @@ class ApplicationController < ActionController::Base if not current_user respond_to do |format| format.json { send_error("Not logged in", status: 401) } - format.html { redirect_to '/auth/joshid' } + format.html { redirect_to '/login' } end false end @@ -419,17 +419,9 @@ class ApplicationController < ActionController::Base end def set_current_request_id - req_id = request.headers['X-Request-Id'] - if !req_id || req_id.length < 1 || req_id.length > 1024 - # Client-supplied ID is either missing or too long to be - # considered friendly. - req_id = "req-" + Random::DEFAULT.rand(2**128).to_s(36)[0..19] - end - response.headers['X-Request-Id'] = Thread.current[:request_id] = req_id - Rails.logger.tagged(req_id) do + Rails.logger.tagged(request.request_id) do yield end - Thread.current[:request_id] = nil end def append_info_to_payload(payload) @@ -578,7 +570,7 @@ class ApplicationController < ActionController::Base if @objects.respond_to? :except list[:items_available] = @objects. except(:limit).except(:offset). - distinct.count(:id) + count(@distinct ? :id : '*') end when 'none' else @@ -611,7 +603,7 @@ class ApplicationController < ActionController::Base # Make sure params[key] is either true or false -- not a # string, not nil, etc. if not params.include?(key) - params[key] = info[:default] + params[key] = info[:default] || false elsif [false, 'false', '0', 0].include? params[key] params[key] = false elsif [true, 'true', '1', 1].include? params[key]