Skip to content

Instantly share code, notes, and snippets.

@adriand
Created February 16, 2010 20:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adriand/305858 to your computer and use it in GitHub Desktop.
Save adriand/305858 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'ruby-debug'
def media_type_params(content_type)
debugger
return {} if content_type.nil?
content_type = content_type.split(/\s*[;,]\s*/)[1..-1]
content_type = content_type.collect { |s| s.split('=', 2) }
content_type = content_type.inject({}) { |hash,(k,v)| hash[k.downcase] = v ; hash }
content_type
end
content_type = "text/plain;charset=utf-8"
hashed = media_type_params(content_type)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment