Class: Riddl::Protocols::HTTP::Parser
- Inherits:
-
Object
- Object
- Riddl::Protocols::HTTP::Parser
- Defined in:
- lib/ruby/riddl/protocols/http/parser.rb
Constant Summary collapse
- MULTIPART_CONTENT_TYPES =
[ #{{{ 'multipart/form-data', 'multipart/related', 'multipart/mixed' #}}} ].freeze
- FORM_CONTENT_TYPES =
}}}
[ #{{{ 'application/x-www-form-urlencoded' #}}} ].freeze
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(query_string, input, content_type, content_length, content_disposition, content_id, riddl_type) ⇒ Parser
constructor
A new instance of Parser.
Constructor Details
#initialize(query_string, input, content_type, content_length, content_disposition, content_id, riddl_type) ⇒ Parser
Returns a new instance of Parser.
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/ruby/riddl/protocols/http/parser.rb', line 162 def initialize(query_string,input,content_type,content_length,content_disposition,content_id,riddl_type) #{{{ # rewind because in some cases it is not at start (when multipart without length) begin input.rewind if input.respond_to?(:rewind) rescue Errno::ESPIPE # Handles exceptions raised by input streams that cannot be rewound # such as when using plain CGI under Apache end media_type = content_type && content_type.split(/\s*[;,]\s*/, 2).first.downcase @params = Riddl::Parameter::Array.new parse_nested_query(query_string,:query) if MULTIPART_CONTENT_TYPES.include?(media_type) parse_multipart(input,content_type,content_length.to_i) elsif FORM_CONTENT_TYPES.include?(media_type) # sub is a fix for Safari Ajax postings that always append \0 parse_nested_query(input.read.sub(/\0\z/, ''),:body) else parse_content(input,content_type,content_length.to_i,content_disposition||'',content_id||'',riddl_type||'') end begin input.rewind if input.respond_to?(:rewind) rescue Errno::ESPIPE # Handles exceptions raised by input streams that cannot be rewound # such as when using plain CGI under Apache end #}}} end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
194 195 196 |
# File 'lib/ruby/riddl/protocols/http/parser.rb', line 194 def params @params end |
Class Method Details
.unescape(s) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/ruby/riddl/protocols/http/parser.rb', line 21 def self::unescape(s) #{{{ return s if s.nil? s.tr('+', ' ').gsub(/((?:%[0-9a-fA-F]{2})+)/n){ [$1.delete('%')].pack('H*') } #}}} end |