Setting custom headers during a POST operation worked in taf2-curb in
0.2.8.0 but upgrading to the latest 0.4.8.0 does not work - throws
this error:
script/curb.rb:11: undefined method `headers' for #<Curl::Multi:
0x5b098c> (NoMethodError)
from script/curb.rb:10:in `http_post'
from script/curb.rb:10
The code is:
post_fields = [
Curl::PostField.content('key', 'somekey'),
Curl::PostField.content('blog', "somethingelse")
]
c = Curl::Easy.http_post('
http://localhost:3000/', *post_fields) do |
curl|
curl.headers['User-Agent'] = 'Mozilla 0.5',
curl.headers['Content-Type'] = 'application/x-www-form-urlencoded'
curl.follow_location = true
curl.max_redirects = 5
curl.connect_timeout = 5
curl.timeout = 5
end
Like I said, works fine in 0.2.8.0, fails in 0.4.8.0. I *used* to set
my headers via a straight assignment:
curl.headers = my_headers_hash
But switched to the more verbose style of setting each one because I
thought this error might have been related to the previous bug with
headers and PUT:
http://groups.google.com/group/curb---ruby-libcurl-bindings/browse_thread/thread/f1bdacd0e7595aba
and your comment about having to do the hash-style of setting them.
But as you can see this error is different.
Thanks in advance.
/Cody