Skip to content

Commit 243a215

Browse files
authored
Merge pull request #769 from carlosantoniodasilva/ca-mini-mime
Suggestion: Replace `mime-types` with `mini_mime` for content type lookup
2 parents a577aca + 366745b commit 243a215

File tree

4 files changed

+5
-4
lines changed

4 files changed

+5
-4
lines changed

Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## unreleased
22

33
* Fix request marshaling (https://github.com/jnunemaker/httparty/pull/767)
4+
* [Replace `mime-types` with `mini_mime`](https://github.com/jnunemaker/httparty/pull/769)
45

56
## 0.20.0
67

httparty.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
1616
s.required_ruby_version = '>= 2.3.0'
1717

1818
s.add_dependency 'multi_xml', ">= 0.5.2"
19-
s.add_dependency('mime-types', "~> 3.0")
19+
s.add_dependency 'mini_mime', ">= 1.0.0"
2020

2121
# If this line is removed, all hard partying will cease.
2222
s.post_install_message = "When you HTTParty, you must party hard!"

lib/httparty.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
require 'uri'
66
require 'zlib'
77
require 'multi_xml'
8-
require 'mime/types'
8+
require 'mini_mime'
99
require 'json'
1010
require 'csv'
1111

lib/httparty/request/body.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ def content_body(object)
8484

8585
def content_type(object)
8686
return object.content_type if object.respond_to?(:content_type)
87-
mime = MIME::Types.type_for(object.path)
88-
mime.empty? ? 'application/octet-stream' : mime[0].content_type
87+
mime = MiniMime.lookup_by_filename(object.path)
88+
mime ? mime.content_type : 'application/octet-stream'
8989
end
9090

9191
def file_name(object)

0 commit comments

Comments
 (0)