Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: Replace mime-types with mini_mime for content type lookup #769

Merged
merged 1 commit into from
Dec 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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