我目前正在反复用头撞墙,直到我通过这个问题。我正在使用 ruby-1.9.3-p194 和 Rails。我正在尝试发出一个可以使用 Net::HTTP.post_form 完成的发布请求,但我不能在这里使用它,因为我需要在标题中设置一个 cookie。http.post 出错说
"undefined method `bytesize' for #<Hash:0xb1b6c04>"
因为我猜它正在尝试对正在发送的数据执行一些操作。
有没有人有某种修复或解决方法?
谢谢
headers = {'Cookie' => 'mycookieinformationinhere'}
uri = URI.parse("http://asite.com/where/I/want/to/go")
http = Net::HTTP.new(uri.host, uri.port)
response = http.post(uri.path, {'test' => 'test'}, headers)