class Curl::Easy

def cert=(cert_file)

def cert=(cert_file)
  pos = cert_file.rindex(':')
  if pos && pos > 1
    self.native_cert= cert_file[0..pos-1]
    self.certpassword= cert_file[pos+1..-1]
  else
    self.native_cert= cert_file
  end
  self.cert
end

def cookiefile=(value)


engine, or this option will be ignored.
*Note* that you must set enable_cookies true to enable the cookie

Set a file that contains cookies to be sent in subsequent requests by this Curl::Easy instance.

easy.cookiefile = string => string
call-seq:
def cookiefile=(value)
  set :cookiefile, value
end

def cookiejar=(value)


engine, or this option will be ignored.
*Note* that you must set enable_cookies true to enable the cookie

Cookies from the response will be written into this file.
Set a cookiejar file to use for this Curl::Easy instance.

easy.cookiejar = string => string
call-seq:
def cookiejar=(value)
  set :cookiejar, value
end

def cookies=(value)


Set multiple cookies in one string like this: "name1=content1; name2=content2;" etc.
be NAME=CONTENTS, where NAME is the cookie name and CONTENTS is what the cookie should contain.
Set cookies to be sent by this Curl::Easy instance. The format of the string should

easy.cookies = "name1=content1; name2=content2;" => string
call-seq:
def cookies=(value)
  set :cookie, value
end

def delete=(onoff)


easy.perform
end
c.delete = true
easy = Curl::Easy.new("url") do|c|
call-seq:
def delete=(onoff)
  set :customrequest, onoff ? 'DELETE' : nil
  onoff
end

def download(url, filename = url.split(/\?/).first.split(/\//).last, &blk)

and a Curl::Err::AbortedByCallbackError will be raised.
offending chunk will *not* be written to the file, the file will be closed,
returns a size that differs from the data chunk size - in this case, the
necessary. As usual, the transfer will be aborted if the on_body handler
to the file, allowing the handler to perform mutative operations where
data string is passed to the handler *before* it is written
download, to account for the automatic routing of data to the specified file: The
*Note* that the semantics of the on_body handler are subtly changed when using

perform call.
If a block is supplied, it will be passed the curl instance prior to the

usually be the filename most simple urls).
supplied filename (defaults to the last component of the URL path, which will
Stream the specified url (via perform) and save the data directly to the

Curl::Easy.download(url, filename = url.split(/\?/).first.split(/\//).last) { |curl| ... }
call-seq:
def download(url, filename = url.split(/\?/).first.split(/\//).last, &blk)
  curl = Curl::Easy.new(url, &blk)
  output = if filename.is_a? IO
    filename.binmode if filename.respond_to?(:binmode)
    filename
  else
    File.open(filename, 'wb')
  end
  begin
    old_on_body = curl.on_body do |data|
      result = old_on_body ?  old_on_body.call(data) : data.length
      output << data if result == data.length
      result
    end
    curl.perform
  ensure
    output.close rescue IOError
  end
  return curl
end

def follow_location=(onoff)


specified by +max_redirects+.
in HTTP responses. Redirects will only be followed to the extent
Configure whether this Curl instance will follow Location: headers

easy.follow_location = boolean => boolean
call-seq:
def follow_location=(onoff)
  set :followlocation, onoff
end

def head=(onoff)


easy.perform
end
c.head = true
easy = Curl::Easy.new("url") do|c|
call-seq:
def head=(onoff)
  set :nobody, onoff
end

def http_delete


an exception (defined under Curl::Err) on error.
this Curl::Easy instance. This method always returns true, or raises
DELETE the currently configured URL using the current options set for

easy.http_delete
call-seq:
def http_delete
  self.http :DELETE
end

def http_delete(*args)


the +http_delete+ call.
If a block is supplied, the new instance will be yielded just prior to

the specified URL and calls +http_delete+, before returning the new instance.
Convenience method that creates a new Curl::Easy instance with

Curl::Easy.http_delete(url) { |easy| ... } => #
call-seq:
def http_delete(*args)
  c = Curl::Easy.new(*args)
  yield c if block_given?
  c.http_delete
  c
end

def http_get


an exception (defined under Curl::Err) on error.
this Curl::Easy instance. This method always returns true, or raises
GET the currently configured URL using the current options set for

easy.http_get => true
call-seq:
def http_get
  set :httpget, true
  http :GET
end

def http_get(*args)


the +http_get+ call.
If a block is supplied, the new instance will be yielded just prior to

the specified URL and calls +http_get+, before returning the new instance.
Convenience method that creates a new Curl::Easy instance with

Curl::Easy.http_get(url) { |easy| ... } => #
call-seq:
def http_get(*args)
  c = Curl::Easy.new(*args)
  yield c if block_given?
  c.http_get
  c
end

def http_head


Curl::Err) on error.
method always returns true, or raises an exception (defined under
method and current options set for this Curl::Easy instance. This
Request headers from the currently configured URL using the HEAD

easy.http_head => true
call-seq:
def http_head
  set :nobody, true
  ret = self.perform
  set :nobody, false
  ret
end

def http_head(*args)


the +http_head+ call.
If a block is supplied, the new instance will be yielded just prior to

the specified URL and calls +http_head+, before returning the new instance.
Convenience method that creates a new Curl::Easy instance with

Curl::Easy.http_head(url) { |easy| ... } => #
call-seq:
def http_head(*args)
  c = Curl::Easy.new(*args)
  yield c if block_given?
  c.http_head
  c
end

def http_post(*args)


information.
in order to set multipart_form_post true. See #http_post for more
If you wish to use multipart form encoding, you'll need to supply a block

Curl::Err) on error.
always returns true, or raises an exception (defined under
the current options set for this Curl::Easy instance. This method
POST the specified formdata to the currently configured URL using

Curl::Easy.http_post(url, Curl::PostField, Curl::PostField ..., Curl::PostField) => true
Curl::Easy.http_post(url, "some=urlencoded%20form%20data", Curl::PostField, "and=so%20on", ...) => true
Curl::Easy.http_post(url, "some=urlencoded%20form%20data", "and=so%20on", ...) => true
Curl::Easy.http_post(url, "some=urlencoded%20form%20data&and=so%20on") => true
call-seq:
def http_post(*args)
  url = args.shift
  c = Curl::Easy.new url
  yield c if block_given?
  c.http_post(*args)
  c
end

def http_put(url, data)


see easy.http_put

Curl::Easy.http_put(url, data) {|c| ... }
call-seq:
def http_put(url, data)
  c = Curl::Easy.new url
  yield c if block_given?
  c.http_put data
  c
end

def interface=(value)


The name can be an interface name, an IP address or a host name.
Set the interface name to use as the outgoing network interface.

easy.interface = string => string
call-seq:
def interface=(value)
  set :interface, value
end

def nosignal=(onoff)


easy.nosignal = true
easy = Curl::Easy.new

call-seq:
def nosignal=(onoff)
  set :nosignal, !!onoff
end

def perform


the configured HTTP Verb.
Curl::Easy instance. If this is an HTTP URL, it will be transferred via
Transfer the currently configured URL using the options set for this

easy.perform => true
call-seq:
def perform
  self.multi = Curl::Multi.new if self.multi.nil?
  self.multi.add self
  ret = self.multi.perform
  self.multi.remove self
  if Curl::Multi.autoclose
    self.multi.close
    self.multi = nil
  end
  if self.last_result != 0 && self.on_failure.nil?
    (err_class, err_summary) = Curl::Easy.error(self.last_result)
    err_detail = self.last_error
    raise err_class.new([err_summary, err_detail].compact.join(": "))
  end
  ret
end

def perform(*args)


the +http_get+ call.
If a block is supplied, the new instance will be yielded just prior to

the new instance. For HTTP URLs, this is equivalent to calling +http_get+.
the specified URL and calls the general +perform+ method, before returning
Convenience method that creates a new Curl::Easy instance with

Curl::Easy.perform(url) { |easy| ... } => #
call-seq:
def perform(*args)
  c = Curl::Easy.new(*args)
  yield c if block_given?
  c.perform
  c
end

def proxy_url=(url)


proxy_url, including protocol prefix (http://) and embedded user + password.
variables can be specified the exact same way as the proxy can be set with
Starting with libcurl 7.14.1, the proxy host string given in environment

override any possibly set environment variables.
*all_proxy* etc, if any of those is set. The proxy_url option does however
libcurl respects the environment variables *http_proxy*, *ftp_proxy*,

tunneling is activated with proxy_tunnel = true.
FTP specifics that don't work unless you tunnel through the HTTP proxy. Such
an impact on what other features of the library you can use, such as
convert operations to HTTP even if you specify an FTP URL etc. This may have
When you tell the library to use an HTTP proxy, libcurl will transparently

the separate option proxy_port .
will be ignored. The proxy's port number may optionally be specified with
The proxy string may be prefixed with [protocol]:// since any such prefix
port number in this string, append :[port] to the end of the host name.
The URL should specify the the host name or dotted IP address. To specify
Set the URL of the HTTP proxy to use for subsequent calls to +perform+.

easy.proxy_url = string => string
call-seq:
def proxy_url=(url)
  set :proxy, url
end

def proxypwd=(value)


form "username:password"
subsequent calls to +perform+. The supplied string should have the
Set the username/password string to use for proxy connection during

easy.proxypwd = string => string
call-seq:
def proxypwd=(value)
  set :proxyuserpwd, value
end

def set(opt,val)


set options on the curl easy handle see http://curl.haxx.se/libcurl/c/curl_easy_setopt.html

easy.set :sym|Fixnum, value
call-seq:
def set(opt,val)
  if opt.is_a?(Symbol)
    option = sym2curl(opt)
  else
    option = opt.to_i
  end
  begin
    setopt(option, val)
  rescue TypeError
    raise TypeError, "Curb doesn't support setting #{opt} [##{option}] option"
  end
end

def ssl_verify_host=(value)

def ssl_verify_host=(value)
  value = 1 if value.class == TrueClass
  value = 0 if value.class == FalseClass
  self.ssl_verify_host_integer=value
end

def ssl_verify_host?


is for the server it is known as.
Determine whether this Curl instance will verify that the server cert

can be one of [0,1,2]
Deprecated: call easy.ssl_verify_host instead

easy.ssl_verify_host? => boolean
call-seq:
def ssl_verify_host?
  ssl_verify_host.nil? ? false : (ssl_verify_host > 0)
end

def status


easy.status => String
call-seq:
def status
  # Matches the last HTTP Status - following the HTTP protocol specification 'Status-Line = HTTP-Version SP Status-Code SP (Opt:)Reason-Phrase CRLF'
  statuses = self.header_str.to_s.scan(/HTTP\/\d(\.\d)?\s(\d+\s.*)\r\n/).map {|match| match[1] }
  statuses.last.strip if statuses.length > 0
end

def sym2curl(opt)


translates ruby symbols to libcurl options

easy.sym2curl :symbol => Fixnum
call-seq:
def sym2curl(opt)
  Curl.const_get("CURLOPT_#{opt.to_s.upcase}")
end

def url=(u)


the URL between calls to +perform+.
(and even recommended) to reuse Curl::Easy instances by reassigning
Set the URL for subsequent calls to +perform+. It is acceptable

easy.url = "http://some.url/" => "http://some.url/"
call-seq:
def url=(u)
  set :url, u
end

def userpwd=(value)


The supplied string should have the form "username:password"
Set the username/password string to use for subsequent calls to +perform+.

easy.userpwd = string => string
call-seq:
def userpwd=(value)
  set :userpwd, value
end

def version=(http_version)


easy.version = Curl::HTTP_NONE
easy.version = Curl::HTTP_1_0
easy.version = Curl::HTTP_1_1
easy.version = Curl::HTTP_2_0
easy = Curl::Easy.new("url")

call-seq:
def version=(http_version)
  set :http_version, http_version
end