Setting custom headers in POST, worked in 0.2.8.0 doesnt work in latest 0.4.8.0

45 views
Skip to first unread message

gonzoprosperity

unread,
Jul 23, 2009, 6:40:45 PM7/23/09
to Curb - Ruby libcurl Bindings
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

gonzoprosperity

unread,
Jul 27, 2009, 5:19:10 PM7/27/09
to Curb - Ruby libcurl Bindings
Actually, it appears that all methods on a Curl::Multi instance are
not accessible, it just happened to be that +headers+ was the first
method I was trying. To wit:

http://pastie.org/560852

Basically, once inside an http_post block there are no standard
methods available.

/Cody
> http://groups.google.com/group/curb---ruby-libcurl-bindings/browse_th...

Todd Fisher

unread,
Jul 27, 2009, 10:22:03 PM7/27/09
to curb---ruby-li...@googlegroups.com
Hi Cody,

 Okay, I didn't have test coverage for this, this issue was introduced by this change: http://github.com/taf2/curb/commit/3be1812d8a426829add6a4cf2fdc3f581c1dd46b

I have a failing test case pushed and am working on a solution.

-Todd

Todd Fisher

unread,
Jul 27, 2009, 11:08:58 PM7/27/09
to curb---ruby-li...@googlegroups.com
http://github.com/taf2/curb/commit/f5bba65d82b45ca4a6bbd777bf268d4a11a21773

Now the config block is classed with the right object yielded Curl::Easy, but it's still called 2 times... working on a fix for that now..

Todd Fisher

unread,
Jul 27, 2009, 11:10:54 PM7/27/09
to curb---ruby-li...@googlegroups.com
Alright, and now it's fixed... thanks for catching this!
Reply all
Reply to author
Forward
0 new messages