house keeping for the readme with some new examples #59
Annotations
2 errors
Run bundle exec rake:
tests/tc_curl_easy.rb#L1062
<"# Curb - Libcurl bindings for Ruby\n" +
"\n" +
"* [CI Build Status](https://github.com/taf2/curb/actions/workflows/CI.yml)\n" +
"* [rubydoc rdoc](http://www.rubydoc.info/github/taf2/curb/)\n" +
"* [github project](http://github.com/taf2/curb/tree/master)\n" +
"\n" +
"Curb (probably CUrl-RuBy or something) provides Ruby-language bindings for the\n" +
"libcurl(3), a fully-featured client-side URL transfer library.\n" +
"cURL and libcurl live at [https://curl.se/libcurl/](https://curl.se/libcurl/) .\n" +
"\n" +
"Curb is a work-in-progress, and currently only supports libcurl's `easy` and `multi` modes.\n" +
"\n" +
"## License\n" +
"\n" +
"Curb is copyright (c) 2006 Ross Bamford, and released under the terms of the\n" +
"Ruby license. See the LICENSE file for the gory details.\n" +
"\n" +
"## Easy mode\n" +
"\n" +
"GET request\n" +
"```\n" +
" res = Curl.get(\"https://www.google.com/\") {|http|\n" +
" http.timeout = 10 # raise exception if request/response not handled within 10 seconds\n" +
" }\n" +
" puts res.code\n" +
" puts res.head\n" +
" puts res.body\n" +
"```\n" +
"\n" +
"POST request\n" +
"```\n" +
" res = Curl.post(\"https://your-server.com/endpoint\", {post: \"this\"}.to_json) {|http|\n" +
" http.headers[\"Content-Type\"] = \"application/json\"\n" +
" }\n" +
" puts res.code\n" +
" puts res.head\n" +
" puts res.body\n" +
"```\n" +
"\n" +
"## FTP Support\n" +
"\n" +
"require 'curb'\n" +
"\n" +
"### Basic FTP Download\n" +
"```ruby\n" +
"puts \"=== FTP Download Example ===\"\n" +
"ftp = Curl::Easy.new('ftp://ftp.example.com/remote/file.txt')\n" +
"ftp.username = 'user'\n" +
"ftp.password = 'password'\n" +
"ftp.perform\n" +
"puts ftp.body\n" +
"```\n" +
"\n" +
"### FTP Upload\n" +
"```ruby\n" +
"puts \"\\n=== FTP Upload Example ===\"\n" +
"upload = Curl::Easy.new('ftp://ftp.example.com/remote/upload.txt')\n" +
"upload.username = 'user'\n" +
"upload.password = 'password'\n" +
"upload.upload = true\n" +
"upload.put_data = File.read('local_file.txt')\n" +
"upload.perform\n" +
"```\n" +
"\n" +
"### List Directory Contents\n" +
"```ruby\n" +
"puts \"\\n=== FTP Directory Listing Example ===\"\n" +
"list = Curl::Easy.new('ftp://ftp.example.com/remote/directory/')\n" +
"list.username = 'user'\n" +
"list.password = 'password'\n" +
"list.dirlistonly = true\n" +
"list.perform\n" +
"puts list.body\n" +
"```\n" +
"\n" +
"### Advanced FTP Usage with Various Options\n" +
"```\n" +
"puts \"\\n=== Advanced FTP Example ===\"\n" +
"advanced = Curl::Easy.new do |curl|\n" +
" curl.url = 'ftp://ftp.example.com/remote/file.txt'\n" +
" curl.username = 'user'\n" +
" curl.password = 'password'\n" +
"\n" +
" # FTP Options\n" +
" curl.ftp_response_timeout = 30\n" +
" curl.ftp_create_missing_dirs = true # Create directories if they don't exist\n" +
" curl.ftp_filemethod = Curl::CURL_MULTICWD # Use multicwd method for traversing paths\n" +
"\n" +
" # SSL/TLS Options for FTPS\n" +
" curl.use_ssl = Curl::CURLUSESSL_ALL # Use SSL/TLS for control and data\n" +
" curl.ssl_verify_peer = true\n" +
" curl.ssl_verify_host = true\n" +
" curl.cacert = \"/path/to/cacert.pem\"\n" +
"\n" +
" # Progress callback\n" +
" curl.on_progress do |dl_total, dl_now, ul_total, ul_now|\n" +
" puts \"Download: \#{dl_now}/\#{dl_total} Upload: \#{ul_now}/\#{ul_total}\"\n" +
" true # must return true to continue\n" +
" end\n" +
"\n" +
" # Debug output\n" +
" curl.verbose = true\n" +
" curl.on_debug do |type, data|\n" +
" puts \"\#{type}: \#{data}\"\n" +
" true\n" +
" end\n" +
"end\n" +
"\n" +
"advanced.perform\n" +
"```\n" +
"\n" +
"### Parallel FTP Downloads\n" +
"```\n" +
"puts \"\\n=== Parallel FTP Downloads Example ===\"\n" +
"urls = [\n" +
" 'ftp://ftp.example.com/file1.txt',\n" +
" 'ftp://ftp.example.com/file2.txt',\n" +
" 'ftp://ftp.example.com/file3.txt'\n" +
"]\n" +
"```\n" +
"\n" +
"### Common options for all connections\n" +
"```\n" +
"options = {\n" +
" :username => 'user',\n" +
" :password => 'password',\n" +
" :timeout => 30,\n" +
" :on_success => proc { |easy| puts \"Successfully downloaded: \#{easy.url}
|
Run bundle exec rake
Process completed with exit code 1.
|
Loading