resat 0.8.1 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/api_request.rb +23 -2
- data/lib/resat.rb +1 -1
- metadata +4 -4
data/lib/api_request.rb
CHANGED
@@ -85,8 +85,11 @@ module Resat
|
|
85
85
|
end
|
86
86
|
form_data = Hash.new
|
87
87
|
@headers.each { |header| @request[header['name']] = header['value'] }
|
88
|
-
@params.each
|
89
|
-
|
88
|
+
@params.each do |param|
|
89
|
+
form_data[param['name']] ||= []
|
90
|
+
form_data[param['name']] << param['value']
|
91
|
+
end
|
92
|
+
set_form_data(@request, form_data) unless form_data.empty?
|
90
93
|
Log.request(@request)
|
91
94
|
|
92
95
|
# 4. Send request and check response code
|
@@ -172,6 +175,24 @@ module Resat
|
|
172
175
|
seconds || 0
|
173
176
|
end
|
174
177
|
|
178
|
+
# Using custom set_form_data and urlencode
|
179
|
+
# Ruby NET/HTTP does not support duplicate parameter names
|
180
|
+
# File net/http.rb, line 1426
|
181
|
+
def set_form_data(request, params, sep = '&')
|
182
|
+
request.body = params.map {|k,v|
|
183
|
+
if v.instance_of?(Array)
|
184
|
+
v.map {|e| "#{urlencode(k.to_s)}=#{urlencode(e.to_s)}"}.join(sep)
|
185
|
+
else
|
186
|
+
"#{urlencode(k.to_s)}=#{urlencode(v.to_s)}"
|
187
|
+
end
|
188
|
+
}.join(sep)
|
189
|
+
request.content_type = 'application/x-www-form-urlencoded'
|
190
|
+
end
|
191
|
+
|
192
|
+
def urlencode(str)
|
193
|
+
str.gsub(/[^a-zA-Z0-9_\.\-]/n) {|s| sprintf('%%%02x', s[0]) }
|
194
|
+
end
|
195
|
+
|
175
196
|
end
|
176
197
|
|
177
198
|
end
|
data/lib/resat.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 59
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 8
|
9
|
-
-
|
10
|
-
version: 0.8.
|
9
|
+
- 2
|
10
|
+
version: 0.8.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Raphael Simon
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-07-25 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|