Method: Mechanize::HTTP::ContentDispositionParser#parse_parameters
- Defined in:
- lib/mechanize/http/content_disposition_parser.rb
permalink #parse_parameters ⇒ Object
Extracts disposition-param and returns a Hash.
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/mechanize/http/content_disposition_parser.rb', line 86 def parse_parameters parameters = {} while true do return nil unless param = rfc_2045_token param.downcase! return nil unless @scanner.scan(/=/) value = case param when /^filename$/ then rfc_2045_value when /^(creation|modification|read)-date$/ then date = rfc_2045_quoted_string begin Time.rfc822 date rescue ArgumentError begin Time.iso8601 date rescue ArgumentError nil end end when /^size$/ then rfc_2045_value.to_i(10) else rfc_2045_value end return nil unless value parameters[param] = value spaces break if @scanner.eos? or not @scanner.scan(/;+/) spaces end parameters end |