diff --git a/Changelog.md b/Changelog.md index 139438d8..50637a66 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,6 +1,7 @@ ## unreleased * Fix request marshaling (/~https://github.com/jnunemaker/httparty/pull/767) +* [Replace `mime-types` with `mini_mime`](/~https://github.com/jnunemaker/httparty/pull/769) ## 0.20.0 diff --git a/httparty.gemspec b/httparty.gemspec index bec51d60..a0f251b8 100644 --- a/httparty.gemspec +++ b/httparty.gemspec @@ -16,7 +16,7 @@ Gem::Specification.new do |s| s.required_ruby_version = '>= 2.3.0' s.add_dependency 'multi_xml', ">= 0.5.2" - s.add_dependency('mime-types', "~> 3.0") + s.add_dependency 'mini_mime', ">= 1.0.0" # If this line is removed, all hard partying will cease. s.post_install_message = "When you HTTParty, you must party hard!" diff --git a/lib/httparty.rb b/lib/httparty.rb index cf20488b..772ffcac 100644 --- a/lib/httparty.rb +++ b/lib/httparty.rb @@ -5,7 +5,7 @@ require 'uri' require 'zlib' require 'multi_xml' -require 'mime/types' +require 'mini_mime' require 'json' require 'csv' diff --git a/lib/httparty/request/body.rb b/lib/httparty/request/body.rb index 4479e1b6..f498cb3d 100644 --- a/lib/httparty/request/body.rb +++ b/lib/httparty/request/body.rb @@ -84,8 +84,8 @@ def content_body(object) def content_type(object) return object.content_type if object.respond_to?(:content_type) - mime = MIME::Types.type_for(object.path) - mime.empty? ? 'application/octet-stream' : mime[0].content_type + mime = MiniMime.lookup_by_filename(object.path) + mime ? mime.content_type : 'application/octet-stream' end def file_name(object)