Class: ActionDispatch::Http::ContentDisposition
Do not use. This class is for internal use only.
Relationships & Source Files | |
Inherits: | Object |
Defined in: | actionpack/lib/action_dispatch/http/content_disposition.rb |
Constant Summary
-
RFC_5987_ESCAPED_CHAR =
# File 'actionpack/lib/action_dispatch/http/content_disposition.rb', line 25/[^A-Za-z0-9!\#$&+.^_`|~-]/
-
TRADITIONAL_ESCAPED_CHAR =
# File 'actionpack/lib/action_dispatch/http/content_disposition.rb', line 19/[^ A-Za-z0-9!\#$+.^_`|~-]/
Class Method Summary
Instance Attribute Summary
- #disposition readonly
- #filename readonly
Instance Method Summary
Constructor Details
.new(disposition:, filename:) ⇒ ContentDisposition
# File 'actionpack/lib/action_dispatch/http/content_disposition.rb', line 14
def initialize(disposition:, filename:) @disposition = disposition @filename = filename end
Class Method Details
.format(disposition:, filename:)
[ GitHub ]# File 'actionpack/lib/action_dispatch/http/content_disposition.rb', line 8
def self.format(disposition:, filename:) new(disposition: disposition, filename: filename).to_s end
Instance Attribute Details
#disposition (readonly)
[ GitHub ]# File 'actionpack/lib/action_dispatch/http/content_disposition.rb', line 12
attr_reader :disposition, :filename
#filename (readonly)
[ GitHub ]# File 'actionpack/lib/action_dispatch/http/content_disposition.rb', line 12
attr_reader :disposition, :filename
Instance Method Details
#ascii_filename
[ GitHub ]# File 'actionpack/lib/action_dispatch/http/content_disposition.rb', line 21
def ascii_filename 'filename="' + percent_escape(I18n.transliterate(filename), TRADITIONAL_ESCAPED_CHAR) + '"' end
#percent_escape(string, pattern) (private)
[ GitHub ]# File 'actionpack/lib/action_dispatch/http/content_disposition.rb', line 40
def percent_escape(string, pattern) string.gsub(pattern) do |char| char.bytes.map { |byte| "%%%02X" % byte }.join end end
#to_s
[ GitHub ]# File 'actionpack/lib/action_dispatch/http/content_disposition.rb', line 31
def to_s if filename "#{disposition}; #{ascii_filename}; #{utf8_filename}" else "#{disposition}" end end
#utf8_filename
[ GitHub ]# File 'actionpack/lib/action_dispatch/http/content_disposition.rb', line 27
def utf8_filename "filename*=UTF-8''" + percent_escape(filename, RFC_5987_ESCAPED_CHAR) end