module Curl

expose shortcut methods

Constants

CURB_VERSION
CURLAUTH_ANY
CURLAUTH_ANYSAFE
CURLAUTH_BASIC
CURLAUTH_DIGEST
CURLAUTH_GSSNEGOTIATE
CURLAUTH_NTLM
CURLINFO_DATA_IN

Passed to on_debug handler to indicate that the data is protocol data received from the peer.

CURLINFO_DATA_OUT

Passed to on_debug handler to indicate that the data is protocol data sent to the peer.

CURLINFO_HEADER_IN

Passed to on_debug handler to indicate that the data is header (or header-like) data received from the peer.

CURLINFO_HEADER_OUT

Passed to on_debug handler to indicate that the data is header (or header-like) data sent to the peer.

CURLINFO_TEXT

Passed to on_debug handler to indicate that the data is informational text.

CURLPROXY_HTTP
CURLPROXY_SOCKS4
CURLPROXY_SOCKS4A
CURLPROXY_SOCKS5
CURL_LONG_VERSION
CURL_MULTICWD
CURL_NOCWD
CURL_SINGLECWD
CURL_SSLVERSION_DEFAULT
CURL_SSLVERSION_SSLv2
CURL_SSLVERSION_SSLv3
CURL_SSLVERSION_TLSv1
CURL_USESSL_ALL
CURL_USESSL_CONTROL
CURL_USESSL_NONE
CURL_USESSL_TRY
CURL_VERNUM
CURL_VERSION
HTTP_1_0
HTTP_1_1
HTTP_NONE
LONG_VERSION
VERNUM
VERSION

Public Class Methods

asyncdns? → true or false click to toggle source

Returns true if the installed libcurl was built with support for asynchronous name lookups, which allows more exact timeouts (even on Windows) and less blocking when using the multi interface. For libcurl versions < 7.10.7, always returns false.

static VALUE ruby_curl_asyncdns_q(VALUE mod) {
#ifdef HAVE_CURL_VERSION_ASYNCHDNS
  curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW);
  return((ver->features & CURL_VERSION_ASYNCHDNS) ? Qtrue : Qfalse);
#else
  return Qfalse;
#endif
}
conv? → true or false click to toggle source

Returns true if the installed libcurl was built with support for character conversions. For libcurl versions < 7.15.4, always returns false.

static VALUE ruby_curl_conv_q(VALUE mod) {
#ifdef HAVE_CURL_VERSION_CONV
  curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW);
  return((ver->features & CURL_VERSION_CONV) ? Qtrue : Qfalse);
#else
  return Qfalse;
#endif
}
debug? → true or false click to toggle source

Returns true if the installed libcurl was built with extra debug capabilities built-in. For libcurl versions < 7.10.6, always returns false.

static VALUE ruby_curl_debug_q(VALUE mod) {
#ifdef HAVE_CURL_VERSION_DEBUG
  curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW);
  return((ver->features & CURL_VERSION_DEBUG) ? Qtrue : Qfalse);
#else
  return Qfalse;
#endif
}
delete(url, params={}, &block) click to toggle source
# File lib/curl.rb, line 33
def self.delete(url, params={}, &block)
  http :DELETE, url, postalize(params), nil, &block
end
get(url, params={}, &block) click to toggle source
# File lib/curl.rb, line 21
def self.get(url, params={}, &block)
  http :GET, urlalize(url, params), nil, nil, &block
end
gssnegotiate? → true or false click to toggle source

Returns true if the installed libcurl supports HTTP GSS-Negotiate. For libcurl versions < 7.10.6, always returns false.

static VALUE ruby_curl_gssnegotiate_q(VALUE mod) {
#ifdef HAVE_CURL_VERSION_GSSNEGOTIATE
  curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW);
  return((ver->features & CURL_VERSION_GSSNEGOTIATE) ? Qtrue : Qfalse);
#else
  return Qfalse;
#endif
}
head(url, params={}, &block) click to toggle source
# File lib/curl.rb, line 41
def self.head(url, params={}, &block)
  http :HEAD, urlalize(url, params), nil, nil, &block
end
http(verb, url, post_body=nil, put_data=nil) { |handle| ... } click to toggle source
# File lib/curl.rb, line 10
def self.http(verb, url, post_body=nil, put_data=nil, &block)
  handle = Thread.current[:curb_curl] ||= Curl::Easy.new
  handle.reset
  handle.url = url
  handle.post_body = post_body if post_body
  handle.put_data = put_data if put_data
  yield handle if block_given?
  handle.http(verb)
  handle
end
idn? → true or false click to toggle source

Returns true if the installed libcurl was built with support for IDNA, domain names with international letters. For libcurl versions < 7.12.0, always returns false.

static VALUE ruby_curl_idn_q(VALUE mod) {
#ifdef HAVE_CURL_VERSION_IDN
  curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW);
  return((ver->features & CURL_VERSION_IDN) ? Qtrue : Qfalse);
#else
  return Qfalse;
#endif
}
ipv6? → true or false click to toggle source

Returns true if the installed libcurl supports IPv6.

static VALUE ruby_curl_ipv6_q(VALUE mod) {
  curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW);
  return((ver->features & CURL_VERSION_IPV6) ? Qtrue : Qfalse);
}
kerberos4? → true or false click to toggle source

Returns true if the installed libcurl supports Kerberos4 authentication with FTP connections.

static VALUE ruby_curl_kerberos4_q(VALUE mod) {
  curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW);
  return((ver->features & CURL_VERSION_KERBEROS4) ? Qtrue : Qfalse);
}
largefile? → true or false click to toggle source

Returns true if the installed libcurl was built with support for large files. For libcurl versions < 7.11.1, always returns false.

static VALUE ruby_curl_largefile_q(VALUE mod) {
#ifdef HAVE_CURL_VERSION_LARGEFILE
  curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW);
  return((ver->features & CURL_VERSION_LARGEFILE) ? Qtrue : Qfalse);
#else
  return Qfalse;
#endif
}
libz? → true or false click to toggle source

Returns true if the installed libcurl supports HTTP deflate using libz. For libcurl versions < 7.10, always returns false.

static VALUE ruby_curl_libz_q(VALUE mod) {
#ifdef HAVE_CURL_VERSION_LIBZ
  curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW);
  return((ver->features & CURL_VERSION_LIBZ) ? Qtrue : Qfalse);
#else
  return Qfalse;
#endif
}
ntlm? → true or false click to toggle source

Returns true if the installed libcurl supports HTTP NTLM. For libcurl versions < 7.10.6, always returns false.

static VALUE ruby_curl_ntlm_q(VALUE mod) {
#ifdef HAVE_CURL_VERSION_NTLM
  curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW);
  return((ver->features & CURL_VERSION_NTLM) ? Qtrue : Qfalse);
#else
  return Qfalse;
#endif
}
options(url, params={}, &block) click to toggle source
# File lib/curl.rb, line 45
def self.options(url, params={}, &block)
  http :OPTIONS, urlalize(url, params), nil, nil, &block
end
patch(url, params={}, &block) click to toggle source
# File lib/curl.rb, line 37
def self.patch(url, params={}, &block)
  http :PATCH, url, postalize(params), nil, &block
end
post(url, params={}, &block) click to toggle source
# File lib/curl.rb, line 25
def self.post(url, params={}, &block)
  http :POST, url, postalize(params), nil, &block
end
postalize(params={}) click to toggle source
# File lib/curl.rb, line 60
def self.postalize(params={})
  params.respond_to?(:map) ? URI.encode_www_form(params) : (params.respond_to?(:to_s) ? params.to_s : params)
end
put(url, params={}, &block) click to toggle source
# File lib/curl.rb, line 29
def self.put(url, params={}, &block)
  http :PUT, url, nil, postalize(params), &block
end
reset() click to toggle source
# File lib/curl.rb, line 64
def self.reset
  Thread.current[:curb_curl] = Curl::Easy.new
end
spnego? → true or false click to toggle source

Returns true if the installed libcurl was built with support for SPNEGO authentication (Simple and Protected GSS-API Negotiation Mechanism, defined in RFC 2478). For libcurl versions < 7.10.8, always returns false.

static VALUE ruby_curl_spnego_q(VALUE mod) {
#ifdef HAVE_CURL_VERSION_SPNEGO
  curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW);
  return((ver->features & CURL_VERSION_SPNEGO) ? Qtrue : Qfalse);
#else
  return Qfalse;
#endif
}
ssl? → true or false click to toggle source

Returns true if the installed libcurl supports SSL connections. For libcurl versions < 7.10, always returns false.

static VALUE ruby_curl_ssl_q(VALUE mod) {
#ifdef HAVE_CURL_VERSION_SSL
  curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW);
  return((ver->features & CURL_VERSION_SSL) ? Qtrue : Qfalse);
#else
  return Qfalse;
#endif
}
sspi? → true or false click to toggle source

Returns true if the installed libcurl was built with support for SSPI. This is only available on Windows and makes libcurl use Windows-provided functions for NTLM authentication. It also allows libcurl to use the current user and the current user's password without the app having to pass them on. For libcurl versions < 7.13.2, always returns false.

static VALUE ruby_curl_sspi_q(VALUE mod) {
#ifdef HAVE_CURL_VERSION_SSPI
  curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW);
  return((ver->features & CURL_VERSION_SSPI) ? Qtrue : Qfalse);
#else
  return Qfalse;
#endif
}
urlalize(url, params={}) click to toggle source
# File lib/curl.rb, line 49
def self.urlalize(url, params={})
  query_str = params.map {|k,v| "#{URI.escape(k.to_s)}=#{CGI.escape(v.to_s)}" }.join('&')
  if url.match(/\?/)
    "#{url}&#{query_str}"
  elsif query_str.size > 0
    "#{url}?#{query_str}"
  else
    url
  end
end