lib/rack/throttle/limiter.rb in rack-throttle-0.4.0 vs lib/rack/throttle/limiter.rb in rack-throttle-0.4.1

- old
+ new

@@ -19,10 +19,11 @@ # @option options [String] :cache (Hash.new) # @option options [String] :key (nil) # @option options [String] :key_prefix (nil) # @option options [Integer] :code (403) # @option options [String] :message ("Rate Limit Exceeded") + # @option options [String] :type ("text/plain; charset=utf-8") def initialize(app, options = {}) @app, @options = app, options end ## @@ -187,11 +188,15 @@ # @param [Integer] code # @param [String, #to_s] message # @param [Hash{String => String}] headers # @return [Array(Integer, Hash, #each)] def http_error(code, message = nil, headers = {}) - [code, {'Content-Type' => 'text/plain; charset=utf-8'}.merge(headers), - [http_status(code), (message.nil? ? "\n" : " (#{message})\n")]] + contentType = 'text/plain; charset=utf-8' + if options[:type] + contentType = options[:type] + end + [code, {'Content-Type' => contentType}.merge(headers), + [message]] end ## # Returns the standard HTTP status message for the given status `code`. #