Class: Net::HTTP::Put
- Inherits:
-
Object
- Object
- Net::HTTP::Put
- Defined in:
- lib/nventory.rb
Overview
1.9 compatible solution for ruby 1.8 net/http bug that improperly encodes params in an array. Example: params = => [“1”, “2”, “3”] bad = param1=123 good = param1=1¶m1=2¶m1=3
Instance Method Summary collapse
Instance Method Details
#set_form_data(params, sep = '&') ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/nventory.rb', line 35 def set_form_data(params, sep = '&') params_array = params.map do |k,v| if v.is_a? Array v.inject([]){|c, val| c << "#{urlencode(k.to_s)}=#{urlencode(val.to_s)}"}.join(sep) else "#{urlencode(k.to_s)}=#{urlencode(v.to_s)}" end end self.body = params_array.join(sep) self.content_type = 'application/x-www-form-urlencoded' end |