New Ruby Curl bindings with Fiber native support

(github.com)

53 points | by taf2 10 hours ago ago

1 comments

  • taf2 10 hours ago

    Excited to announce Curb 1.2.0 with support for Fiber aware IO scheduling. It also builds way faster now by using multiple CPU's to configure itself in parallel.

    A new saner default when using Curl.head to not wait for a body since many http servers when sending a HEAD request will still respond with a Content-Length setting CURLOPT_NOBODY=1 is a much better default.

    Here's an example using making requests with async:

    require 'curl' require 'async'

    Async { |task|

        %w[https://example.com https://httpbin.org/get].each { |url|
    
            task.async {
    
              r = Curl.get(url) { |c| c.timeout = 10 }
              puts "#{url} -> #{r.response_code} (#{r.body_str.bytesize} bytes)"
    
            }
        }
    }

    You can still use Curl::Multi but now if your code is already in a http server you don't have to do anything to get the benefit of the overlapping IO