# File lib/picnic/authentication.rb, line 95 def service(*a) app = Kernel.const_get self.class.name.gsub(/^(\w+)::.+$/, '\1') unless app.respond_to? :authenticate raise "Basic authentication is enabled but the 'authenticate' method has not been defined." end @credentials = read_credentials || {} if app.authenticate(@credentials) s = super(*a) else @status = 401 headers['Content-type'] = @headers['Content-type'] || 'text/plain' #headers['Status'] = 'Unauthorized' headers['WWW-Authenticate'] = "Basic realm=\"#{app}\"" @body = 'Unauthorized' s = self end s end