httmultiparty 0.3.5 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/httmultiparty.rb +7 -4
- data/lib/httmultiparty/version.rb +1 -1
- metadata +2 -2
data/lib/httmultiparty.rb
CHANGED
@@ -43,7 +43,7 @@ module HTTMultiParty
|
|
43
43
|
def post(path, options={})
|
44
44
|
method = Net::HTTP::Post
|
45
45
|
options[:body] ||= options.delete(:query)
|
46
|
-
if
|
46
|
+
if hash_contains_files?(options[:body])
|
47
47
|
method = MultipartPost
|
48
48
|
options[:query_string_normalizer] = HTTMultiParty::QUERY_STRING_NORMALIZER
|
49
49
|
end
|
@@ -53,7 +53,7 @@ module HTTMultiParty
|
|
53
53
|
def put(path, options={})
|
54
54
|
method = Net::HTTP::Put
|
55
55
|
options[:body] ||= options.delete(:query)
|
56
|
-
if
|
56
|
+
if hash_contains_files?(options[:body])
|
57
57
|
method = MultipartPut
|
58
58
|
options[:query_string_normalizer] = HTTMultiParty::QUERY_STRING_NORMALIZER
|
59
59
|
end
|
@@ -61,12 +61,15 @@ module HTTMultiParty
|
|
61
61
|
end
|
62
62
|
|
63
63
|
private
|
64
|
-
def
|
65
|
-
|
64
|
+
def hash_contains_files?(hash)
|
65
|
+
hash.is_a?(Hash) && HTTMultiParty.flatten_params(hash).select do |(k,v)|
|
66
|
+
v.is_a?(File) || v.is_a?(UploadIO)
|
67
|
+
end.size > 0
|
66
68
|
end
|
67
69
|
end
|
68
70
|
end
|
69
71
|
|
72
|
+
require 'httmultiparty/version'
|
70
73
|
require 'httmultiparty/multipartable'
|
71
74
|
require 'httmultiparty/multipart_post'
|
72
75
|
require 'httmultiparty/multipart_put'
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: httmultiparty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.3.
|
5
|
+
version: 0.3.6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Johannes Wagener
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-09-12 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|