curb

getting the status code of a HTTP redirected page

♀尐吖头ヾ 提交于 2019-12-08 07:09:06
问题 I'm using curb to test some URLs in Ruby: require 'curb' def test_url() c = Curl::Easy.new("http://www.wikipedia.org/wiki/URL_redirection") do |curl| curl.follow_location= true curl.head = true end c.perform puts "status => " + c.status puts "body => " + c.body_str puts "final url => " + c.last_effective_url end test_url This outputs: status => 301 Moved Permanently body => final url => http://en.wikipedia.org/wiki/URL_redirection In this case, www.wikipedia.org/wiki/URL_redirection redirects

SSLCaertBadFile error heroku curb

五迷三道 提交于 2019-12-07 06:03:16
I have a rake task that pulls and parses JSON data over an SSL connection from an external API. I use a gem that wraps this external API and have no problems running locally, but the task fails when run on heroku with #<Curl::Err::SSLCaertBadFile: Curl::Err::SSLCaertBadFile> I installed the piggyback SSL add-on, hoping it might fix it, but no dice. Any ideas? UPDATE I managed to fix it by disabling ssl verification on the curl request previously set by the following two fields: request.ssl_verify_peer request.ssl_verify_host I don't know enough about SSL to know exactly why the error was

Zipfile download through CURL to an actual Zip-file in your file structure

别来无恙 提交于 2019-12-06 06:54:45
问题 I am trying to build a file downloader with the RubyGem Curb. (Look at This Question.) I am trying to download a zip file and then with the class File I am trying to actually make the file so that I can double click it in Finder (I am on OS X). How would I go about to convert this "Curl'ed" body to a zip-file. require 'rubygems' require 'curb' class Download def start curl = Curl::Easy.new('http://wordpress.org/latest.zip') curl.perform curl.on_body { |d| f = File.new('test.zip', 'w') {|f| f

Having Issues with Curb gem on Mac Snow Leopard

巧了我就是萌 提交于 2019-12-06 02:18:31
This has consumed hours of my time. in the console i run: require 'curb' i get the error: LoadError: dlopen(/usr/local/lib/ruby/gems/1.8/gems/taf2-curb-0.5.4.0/lib/curb_core.bundle, 9): no suitable image found. Did find: /usr/local/lib/ruby/gems/1.8/gems/taf2-curb-0.5.4.0/lib/curb_core.bundle: mach-o, but wrong architecture - /usr/local/lib/ruby/gems/1.8/gems/taf2-curb-0.5.4.0/lib/curb_core.bundle from /usr/local/lib/ruby/gems/1.8/gems/taf2-curb-0.5.4.0/lib/curb_core.bundle from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from /Users/user/Sites/CSG/vendor/rails

Zipfile download through CURL to an actual Zip-file in your file structure

一曲冷凌霜 提交于 2019-12-04 11:33:43
I am trying to build a file downloader with the RubyGem Curb. (Look at This Question .) I am trying to download a zip file and then with the class File I am trying to actually make the file so that I can double click it in Finder (I am on OS X). How would I go about to convert this "Curl'ed" body to a zip-file. require 'rubygems' require 'curb' class Download def start curl = Curl::Easy.new('http://wordpress.org/latest.zip') curl.perform curl.on_body { |d| f = File.new('test.zip', 'w') {|f| f.write d} } end end dl = Download.new dl.start I am not getting any error, neither can I find any file.

An error occurred while installing curb (0.8.5)

末鹿安然 提交于 2019-12-04 09:57:31
问题 While bundling an old project, this error came up: Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. /home/dd/.rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb checking for curl-config... no checking for main() in -lcurl... no *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options. Provided configuration options: -

Ruby: How do I send a JSON POST request using Curb?

筅森魡賤 提交于 2019-12-03 12:21:15
问题 How can I set the request body of a CURB request to be my json string? I am trying to do a JSON POST request using Curb. My code: require 'rubygems' require 'curb' require 'json' myarray = {} myarray['key'] = 'value' json_string = myarray.to_json() c = Curl::Easy.http_post("https://example.com" # how do I set json_string to be the request body? ) do |curl| curl.headers['Accept'] = 'application/json' curl.headers['Content-Type'] = 'application/json' curl.headers['Api-Version'] = '2.2' end 回答1:

An error occurred while installing curb (0.8.5)

爷,独闯天下 提交于 2019-12-03 05:31:08
While bundling an old project, this error came up: Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. /home/dd/.rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb checking for curl-config... no checking for main() in -lcurl... no *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options. Provided configuration options: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib

Can't find libcurl or curl/curl.h (RuntimeError)

醉酒当歌 提交于 2019-12-03 00:55:15
I am trying to install curb 0.8.0 on a Windows computer but I can not seem to get anywhere. I have been trying every website 3 pages deep on my Google search. Please, anyone have an idea of how I can get this single thing installed. I have downloaded curl and extracted it to C:\curl. I have added it to my path and am running the command: gem install curb -- --with-curl-lib=C:\curl\bin --with-curl-include=C:\curl\include But it doesn't work. I keep getting the same error. Any suggestions? The curb gem requires libcurl , something that is related to, but different from curl . It's the library

Get response headers from Curb

不羁的心 提交于 2019-11-30 12:36:08
I intend to make a call from a Ruby on Rails application: c = Curl::Easy.http_post("https://example.com", json_string_goes_here) do |curl| curl.headers['Accept'] = 'application/json' curl.headers['Content-Type'] = 'application/json' curl.headers['Api-Version'] = '2.2' end The response should have custom headers: X-Custom1 : "some value" X-Custom2 : "another value" How do I iterate over the response headers to compare the values to what I was expecting? Using Curl::Easy's header_str you can access the returned headers as a string. From the documentation: Return the response header from the