There are some checkboxes in a form, so the post data is:
type: flowers
color[]: red
color[]: white
color[]: blue
My code is:
Net::HTTP.post_form(URI.parse("http://xxx"), { :type=>'flowers',
'color[]'=>%w[red white blue] })
It seems there is something wrong with my code, that I can't get the correct response. What's the correct code?
Is it a BUG?
I found a report about this:
http://rubyforge.org/tracker/?func=detail&atid=1698&aid=10340&group_id=426
It is reported in 2007, but seems not fixed. In my ruby 1.8.7 source code:
def set_form_data(params, sep = '&')
self.body = params.map {|k,v| "#{urlencode(k.to_s)}=#{urlencode(v.to_s)}" }.join(sep)
self.content_type = 'application/x-www-form-urlencoded'
end