X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/6c1d73a509a1ac2216a704f3dc5534d573e5d7ae..22946d703a1186d0ec7fb18a663f73855bb49546:/app/controllers/application_controller.rb?ds=sidebyside diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index bb32e7e6e..d3f57f086 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -161,7 +161,7 @@ class ApplicationController < ActionController::Base response.headers["Error"] = message if request.headers["X-Error-Format"]&.casecmp("xml")&.zero? - result = OSM::API.new.get_xml_doc + result = OSM::API.new.xml_doc result.root.name = "osmError" result.root << (XML::Node.new("status") << "#{Rack::Utils.status_code(status)} #{Rack::Utils::HTTP_STATUS_CODES[status]}") result.root << (XML::Node.new("message") << message) @@ -231,6 +231,7 @@ class ApplicationController < ActionController::Base def api_call_timeout(&block) Timeout.timeout(Settings.api_timeout, Timeout::Error, &block) rescue Timeout::Error + ActiveRecord::Base.connection.raw_connection.cancel raise OSM::APITimeoutError end @@ -243,11 +244,13 @@ class ApplicationController < ActionController::Base if e.is_a?(Timeout::Error) || (e.is_a?(ActiveRecord::StatementInvalid) && e.message.include?("execution expired")) + ActiveRecord::Base.connection.raw_connection.cancel render :action => "timeout" else raise end rescue Timeout::Error + ActiveRecord::Base.connection.raw_connection.cancel render :action => "timeout" end @@ -363,7 +366,7 @@ class ApplicationController < ActionController::Base end # extract authorisation credentials from headers, returns user = nil if none - def get_auth_data + def auth_data if request.env.key? "X-HTTP_AUTHORIZATION" # where mod_rewrite might have put it authdata = request.env["X-HTTP_AUTHORIZATION"].to_s.split elsif request.env.key? "REDIRECT_X_HTTP_AUTHORIZATION" # mod_fcgi