Giter Club home page Giter Club logo

Comments (9)

taf2 avatar taf2 commented on August 15, 2024

Hi Wes,

Sorry for the long delay... This really comes down to a deficiency in the current callback interface, whether we say 20x is success or 30x is failure just means we really can't easily classify response codes binary as success or failure... I suggest using the on_complete callback...

from curb.

wesgurn avatar wesgurn commented on August 15, 2024

No worries. I ended up implementing using the on_complete callback and having it check in the on_failure callback to ignore if it was a 304 response code.

from curb.

taf2 avatar taf2 commented on August 15, 2024

Maybe for future releases the right thing to do here would be to add a on_redirect, and on_missing callback?

from curb.

wesgurn avatar wesgurn commented on August 15, 2024

Thats a good idea. Maybe define the set callbacks more specific for the various status response groups:
2xx codes on_success
3xx codes on_redirect
4xx codes on_missing
5xx codes on _failure

One thing that might get somewhat confusing is that network connection, DNS failed lookups, and 5xx reponse codes are getting grouped in on_failure callback. Not sure if you want to break those out in a separate ones or not.

Another possible solution is to add callbacks for each of the response status codes - on_200, on_301, on_404. This way the developer can be very specific as to how they want to handle each of the status codes.

from curb.

taf2 avatar taf2 commented on August 15, 2024

Okay, I'm thinking something such as. easy.on("304") {|c| ... } etc... There is a bit of overhead in this but I think it's not huge. Will update as I make progress

from curb.

jeisenlo avatar jeisenlo commented on August 15, 2024

Any updates on this? Thanks.

from curb.

taf2 avatar taf2 commented on August 15, 2024

will work on this for the 0.8 series... porting more c code to ruby will make this kind of interface easier to implement.

from curb.

jeisenlo avatar jeisenlo commented on August 15, 2024

Awesome, Todd! Thank you!

from curb.

taf2 avatar taf2 commented on August 15, 2024

for 0.8 release on_redirect and on_missing will be included in addition to on_success, on_failure and on_complete.

from curb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.