Issue with on_success and on_failure

416 views
Skip to first unread message

kadoudal

unread,
Sep 5, 2010, 1:13:17 PM9/5/10
to Curb - Ruby libcurl Bindings
I am testing a script , and I wrote the success/failure checking as
following :

request = Curl::Easy.new("#{resource_uri}") do |curl|
curl.headers["X-TrackerToken"] = @token
curl.on_success do |response|
# doing some funny thing
end
curl.on_failure do |response, err|
print "We have failure. The response code is
#{response.response_code}\n"
print "Error is: #{err.inspect}\n"

I am testing against PostBin.org, which returns a 302 code by
default..
with this coding an error is raised ... which should not be ( it's not
a failure ..)

We have failure. The response code is 302
Error is: [Curl::Err::CurlOK, "No error"]

how should I write my code to pass this test ?

Todd Fisher

unread,
Sep 6, 2010, 11:27:12 AM9/6/10
to curb---ruby-li...@googlegroups.com
Hi If you add 

curl.follow_location = true

Does it work?


--
You received this message because you are subscribed to the Google Groups "Curb - Ruby libcurl Bindings" group.
To post to this group, send email to curb---ruby-li...@googlegroups.com.
To unsubscribe from this group, send email to curb---ruby-libcurl-...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/curb---ruby-libcurl-bindings?hl=en.


Todd Fisher

unread,
Sep 6, 2010, 10:20:57 PM9/6/10
to curb---ruby-li...@googlegroups.com
Yes, I've just updated the README on github here: http://github.com/taf2/curb

The gist is 20x trigger a on_success, anything else is on_failure  and to assert response code/status on your own use on_complete.

On Mon, Sep 6, 2010 at 1:21 PM, <kado...@gmail.com> wrote:
I added curl.on_complete and it works.. ( the redirection is only during tests on postbin.org, )

is there any place ( link) where I can find some info on the on the different callbacks ? are they listed somewhere in the gem ?

thanks a lot

Le , Todd Fisher <todd....@gmail.com> a écrit :
Reply all
Reply to author
Forward
0 new messages