Skip to content

Commit

Permalink
Merge pull request #769 from carlosantoniodasilva/ca-mini-mime
Browse files Browse the repository at this point in the history
Suggestion: Replace `mime-types` with `mini_mime` for content type lookup
  • Loading branch information
jnunemaker authored Dec 30, 2022
2 parents a577aca + 366745b commit 243a215
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion httparty.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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!"
Expand Down
2 changes: 1 addition & 1 deletion lib/httparty.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
require 'uri'
require 'zlib'
require 'multi_xml'
require 'mime/types'
require 'mini_mime'
require 'json'
require 'csv'

Expand Down
4 changes: 2 additions & 2 deletions lib/httparty/request/body.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 243a215

Please sign in to comment.