PATH:
opt
/
alt
/
ruby30
/
share
/
gems
/
gems
/
rack-3.0.8
/
lib
/
rack
# frozen_string_literal: true module Rack # Rack::MediaType parse media type and parameters out of content_type string class MediaType SPLIT_PATTERN = %r{\s*[;,]\s*} class << self # The media type (type/subtype) portion of the CONTENT_TYPE header # without any media type parameters. e.g., when CONTENT_TYPE is # "text/plain;charset=utf-8", the media-type is "text/plain". # # For more information on the use of media types in HTTP, see: # http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.7 def type(content_type) return nil unless content_type content_type.split(SPLIT_PATTERN, 2).first.tap(&:downcase!) end # The media type parameters provided in CONTENT_TYPE as a Hash, or # an empty Hash if no CONTENT_TYPE or media-type parameters were # provided. e.g., when the CONTENT_TYPE is "text/plain;charset=utf-8", # this method responds with the following Hash: # { 'charset' => 'utf-8' } def params(content_type) return {} if content_type.nil? content_type.split(SPLIT_PATTERN)[1..-1].each_with_object({}) do |s, hsh| k, v = s.split('=', 2) hsh[k.tap(&:downcase!)] = strip_doublequotes(v) end end private def strip_doublequotes(str) (str.start_with?('"') && str.end_with?('"')) ? str[1..-2] : str end end end end
[+]
auth
[-] common_logger.rb
[edit]
[-] rewindable_input.rb
[edit]
[-] deflater.rb
[edit]
[-] tempfile_reaper.rb
[edit]
[-] directory.rb
[edit]
[-] utils.rb
[edit]
[+]
multipart
[-] builder.rb
[edit]
[-] response.rb
[edit]
[-] conditional_get.rb
[edit]
[-] version.rb
[edit]
[-] request.rb
[edit]
[-] show_status.rb
[edit]
[-] mock_request.rb
[edit]
[-] method_override.rb
[edit]
[-] head.rb
[edit]
[-] logger.rb
[edit]
[-] static.rb
[edit]
[-] mock.rb
[edit]
[-] chunked.rb
[edit]
[-] runtime.rb
[edit]
[-] urlmap.rb
[edit]
[-] null_logger.rb
[edit]
[-] files.rb
[edit]
[-] query_parser.rb
[edit]
[-] mock_response.rb
[edit]
[+]
..
[-] show_exceptions.rb
[edit]
[-] mime.rb
[edit]
[-] config.rb
[edit]
[-] constants.rb
[edit]
[-] events.rb
[edit]
[-] lint.rb
[edit]
[-] content_type.rb
[edit]
[-] reloader.rb
[edit]
[-] recursive.rb
[edit]
[-] multipart.rb
[edit]
[-] body_proxy.rb
[edit]
[-] sendfile.rb
[edit]
[-] etag.rb
[edit]
[-] headers.rb
[edit]
[-] cascade.rb
[edit]
[-] file.rb
[edit]
[-] lock.rb
[edit]
[-] media_type.rb
[edit]
[-] content_length.rb
[edit]