Class: Curl::Easy
- Inherits:
-
Object
- Object
- Curl::Easy
- Defined in:
- lib/curb.rb,
ext/curb_easy.c
Class Method Summary collapse
-
.download(url, filename = url.split(/\?/).first.split(/\//).last, &blk) ⇒ Object
call-seq: Curl::Easy.download(url, filename = url.split(/?/).first.split(///).last) { |curl| … } Stream the specified url (via perform) and save the data directly to the supplied filename (defaults to the last component of the URL path, which will usually be the filename most simple urls).
-
.Curl::Easy.http_delete(url) {|easy| ... } ⇒ #<Curl::Easy...>
Convenience method that creates a new Curl::Easy instance with the specified URL and calls
http_delete
, before returning the new instance. -
.Curl::Easy.http_get(url) {|easy| ... } ⇒ #<Curl::Easy...>
Convenience method that creates a new Curl::Easy instance with the specified URL and calls
http_get
, before returning the new instance. -
.Curl::Easy.http_head(url) {|easy| ... } ⇒ #<Curl::Easy...>
Convenience method that creates a new Curl::Easy instance with the specified URL and calls
http_head
, before returning the new instance. -
.http_post(*args) ⇒ Object
POST the specified formdata to the currently configured URL using the current options set for this Curl::Easy instance.
-
.Curl::Easy.http_put(url, data) {|c| ... } ⇒ Object
see easy.http_put.
-
.new(*args) ⇒ Object
Create a new Curl::Easy instance, optionally supplying the URL.
-
.Curl::Easy.perform(url) {|easy| ... } ⇒ #<Curl::Easy...>
Convenience method that creates a new Curl::Easy instance with the specified URL and calls the general
perform
method, before returning the new instance.
Instance Method Summary collapse
-
#autoreferer=(autoreferer) ⇒ Object
easy = Curl::Easy.new easy.autoreferer=true.
-
#body_str ⇒ Object
Return the response body from the previous call to
perform
. -
#cacert ⇒ String
Obtain the cacert file to use for this Curl::Easy instance.
-
#cacert=(string) ⇒ Object
Set a cacert bundle to use for this Curl::Easy instance.
-
#cert ⇒ String
Obtain the cert file to use for this Curl::Easy instance.
-
#cert=(string) ⇒ Object
Set a cert file to use for this Curl::Easy instance.
-
#cert_key ⇒ Object
Obtain the cert key file to use for this Curl::Easy instance.
-
#cert_key=(cert_key) ⇒ Object
Set a cert key to use for this Curl::Easy instance.
-
#certpassword=(string) ⇒ Object
Set a password used to open the specified cert.
-
#certtype ⇒ String
Obtain the cert type used for this Curl::Easy instance.
-
#certtype=(certtype) ⇒ Object
Set a cert type to use for this Curl::Easy instance.
-
#clone ⇒ Object
(also: #dup)
Clone this Curl::Easy instance, creating a new instance.
-
#close ⇒ nil
Close the Curl::Easy instance.
-
#connect_time ⇒ Float
Retrieve the time, in seconds, it took from the start until the connect to the remote host (or proxy) was completed.
-
#connect_timeout ⇒ Fixnum?
Obtain the maximum time in seconds that you allow the connection to the server to take.
-
#connect_timeout=(fixnum) ⇒ Fixnum?
Set the maximum time in seconds that you allow the connection to the server to take.
-
#content_type ⇒ nil
Retrieve the content-type of the downloaded object.
-
#cookiefile ⇒ String
Obtain the cookiefile file for this Curl::Easy instance.
-
#cookiefile=(string) ⇒ String
Set a file that contains cookies to be sent in subsequent requests by this Curl::Easy instance.
-
#cookiejar ⇒ String
Obtain the cookiejar file to use for this Curl::Easy instance.
-
#cookiejar=(string) ⇒ String
Set a cookiejar file to use for this Curl::Easy instance.
-
#cookies ⇒ Object
Obtain the cookies for this Curl::Easy instance.
-
#cookies=(cookies) ⇒ Object
Set cookies to be sent by this Curl::Easy instance.
- #delete=(onoff) ⇒ Object
-
#dns_cache_timeout ⇒ Fixnum?
Obtain the dns cache timeout in seconds.
-
#dns_cache_timeout=(fixnum) ⇒ Fixnum?
Set the dns cache timeout in seconds.
-
#download_speed ⇒ Float
Retrieve the average download speed that curl measured for the preceeding complete download.
-
#downloaded_bytes ⇒ Float
Retrieve the total amount of bytes that were downloaded in the preceeding transfer.
-
#downloaded_content_length ⇒ Float
Retrieve the content-length of the download.
-
#enable_cookies=(boolean) ⇒ Boolean
Configure whether the libcurl cookie engine is enabled for this Curl::Easy instance.
-
#enable_cookies? ⇒ Boolean
Determine whether the libcurl cookie engine is enabled for this Curl::Easy instance.
-
#encoding ⇒ String
Get the set encoding types.
-
#encoding=(string) ⇒ String
Set the accepted encoding types, curl will handle all of the decompression.
-
#escape("some text") ⇒ Object
Convert the given input string to a URL encoded string and return the result.
-
#fetch_file_time=(boolean) ⇒ Boolean
Configure whether this Curl instance will fetch remote file times, if available.
-
#fetch_file_time? ⇒ Boolean
Determine whether this Curl instance will fetch remote file times, if available.
-
#file_time ⇒ Fixnum
Retrieve the remote time of the retrieved document (in number of seconds since 1 jan 1970 in the GMT/UTC time zone).
-
#follow_location=(boolean) ⇒ Boolean
Configure whether this Curl instance will follow Location: headers in HTTP responses.
-
#follow_location? ⇒ Boolean
Determine whether this Curl instance will follow Location: headers in HTTP responses.
-
#ftp_commands ⇒ Object
call-seq easy.ftp_commands => array or nil.
-
#ftp_commands=(ftp_commands) ⇒ Object
Explicitly sets the list of commands to execute on the FTP server when calling perform.
-
#ftp_entry_path ⇒ nil
Retrieve the path of the entry path.
-
#ftp_filemethod(ftp_filemethod) ⇒ Object
call-seq easy.ftp_filemethod => fixnum.
-
#ftp_filemethod=(value) ⇒ Fixnum?
Controls how libcurl reaches files on the server.
-
#ftp_response_timeout ⇒ Fixnum?
Obtain the maximum time that libcurl will wait for FTP command responses.
-
#ftp_response_timeout=(fixnum) ⇒ Fixnum?
Set a timeout period (in seconds) on the amount of time that the server is allowed to take in order to generate a response message for a command before the session is considered hung.
- #head=(onoff) ⇒ Object
-
#header_in_body=(boolean) ⇒ Boolean
Configure whether this Curl instance will return HTTP headers combined with body data.
-
#header_in_body? ⇒ Boolean
Determine whether this Curl instance will verify the SSL peer certificate.
-
#header_size ⇒ Fixnum
Retrieve the total size of all the headers received in the preceeding transfer.
-
#header_str ⇒ Object
Return the response header from the previous call to
perform
. -
#headers ⇒ Hash, ...
Obtain the custom HTTP headers for following requests.
-
#headers=(headers) ⇒ Object
easy.headers = => “val” …, “Header” => “val” => val”, … easy.headers = [“Header: val” …, “Header: val”] => [“Header: val”, …].
-
#http(verb) ⇒ Object
Send an HTTP request with method set to verb, using the current options set for this Curl::Easy instance.
-
#http_auth_types ⇒ Fixnum?
Obtain the HTTP authentication types that may be used for the following
perform
calls. -
#http_auth_types=(*args) ⇒ Object
VALUE self, VALUE http_auth_types) {.
-
#http_connect_code ⇒ Fixnum
Retrieve the last received proxy response code to a CONNECT request.
-
#http_delete ⇒ Object
DELETE the currently configured URL using the current options set for this Curl::Easy instance.
-
#http_get ⇒ true
GET the currently configured URL using the current options set for this Curl::Easy instance.
-
#http_head ⇒ true
Request headers from the currently configured URL using the HEAD method and current options set for this Curl::Easy instance.
-
#http_post(*args) ⇒ Object
POST the specified formdata to the currently configured URL using the current options set for this Curl::Easy instance.
-
#http_put(data) ⇒ true
PUT the supplied data to the currently configured URL using the current options set for this Curl::Easy instance.
- #inspect ⇒ "#<Curl::Easy http://google.com/>"
-
#interface ⇒ String
Obtain the interface name that is used as the outgoing network interface.
-
#interface=(string) ⇒ String
Set the interface name to use as the outgoing network interface.
-
#last_effective_url ⇒ nil
Retrieve the last effective URL used by this instance.
-
#local_port ⇒ Fixnum?
Obtain the local port that will be used for the following
perform
calls. -
#local_port=(fixnum) ⇒ Fixnum?
Set the local port that will be used for the following
perform
calls. -
#local_port_range ⇒ Fixnum?
Obtain the local port range that will be used for the following
perform
calls. -
#local_port_range=(fixnum) ⇒ Fixnum?
Set the local port range that will be used for the following
perform
calls. -
#max_redirects ⇒ Fixnum?
Obtain the maximum number of redirections to follow in the following
perform
calls. -
#max_redirects=(fixnum) ⇒ Fixnum?
Set the maximum number of redirections to follow in the following
perform
calls. -
#multipart_form_post=(boolean) ⇒ Boolean
Configure whether this Curl instance uses multipart/formdata content type for HTTP POST requests.
-
#multipart_form_post? ⇒ Boolean
Determine whether this Curl instance uses multipart/formdata content type for HTTP POST requests.
-
#name_lookup_time ⇒ Float
Retrieve the time, in seconds, it took from the start until the name resolving was completed.
-
#native_cert= ⇒ Object
Allow the incoming cert string to be file:password but be careful to not use a colon from a windows file path as the split point.
-
#nosignal=(onoff) ⇒ Object
easy = Curl::Easy.new easy.nosignal = true.
-
#num_connects ⇒ Integer
Retrieve the number of new connections libcurl had to create to achieve the previous transfer (only the successful connects are counted).
-
#on_body {|body_data| ... } ⇒ Object
Assign or remove the
on_body
handler for this Curl::Easy instance. -
#on_complete {|easy| ... } ⇒ Object
Assign or remove the
on_complete
handler for this Curl::Easy instance. -
#on_debug {|type, data| ... } ⇒ Object
Assign or remove the
on_debug
handler for this Curl::Easy instance. -
#on_failure {|easy, code| ... } ⇒ Object
Assign or remove the
on_failure
handler for this Curl::Easy instance. -
#on_header {|header_data| ... } ⇒ Object
Assign or remove the
on_header
handler for this Curl::Easy instance. -
#on_progress {|dl_total, dl_now, ul_total, ul_now| ... } ⇒ Object
Assign or remove the
on_progress
handler for this Curl::Easy instance. -
#on_success {|easy| ... } ⇒ Object
Assign or remove the
on_success
handler for this Curl::Easy instance. -
#os_errno ⇒ Integer
Retrieve the errno variable from a connect failure (requires libcurl 7.12.2 or higher, otherwise 0 is always returned).
-
#password ⇒ String
Get the current password.
-
#password=(string) ⇒ String
Set the HTTP Authentication password.
-
#perform ⇒ true
Transfer the currently configured URL using the options set for this Curl::Easy instance.
-
#post_body ⇒ String?
Obtain the POST body used in this Curl::Easy instance.
-
#post_body=(post_body) ⇒ Object
Sets the POST body of this Curl::Easy instance.
-
#pre_transfer_time ⇒ Float
Retrieve the time, in seconds, it took from the start until the file transfer is just about to begin.
-
#primary_ip ⇒ nil
Retrieve the resolved IP of the most recent connection done with this curl handle.
-
#proxy_auth_types ⇒ Fixnum?
Obtain the proxy authentication types that may be used for the following
perform
calls. -
#proxy_auth_types=(fixnum) ⇒ Fixnum?
Set the proxy authentication types that may be used for the following
perform
calls. -
#proxy_port ⇒ Fixnum?
Obtain the proxy port that will be used for the following
perform
calls. -
#proxy_port=(fixnum) ⇒ Fixnum?
Set the proxy port that will be used for the following
perform
calls. -
#proxy_tunnel=(boolean) ⇒ Boolean
Configure whether this Curl instance will use proxy tunneling.
-
#proxy_tunnel? ⇒ Boolean
Determine whether this Curl instance will use proxy tunneling.
-
#proxy_type ⇒ Fixnum?
Obtain the proxy type that will be used for the following
perform
calls. -
#proxy_type=(fixnum) ⇒ Fixnum?
Set the proxy type that will be used for the following
perform
calls. -
#proxy_url ⇒ String
Obtain the HTTP Proxy URL that will be used by subsequent calls to
perform
. -
#proxy_url=(string) ⇒ String
Set the URL of the HTTP proxy to use for subsequent calls to
perform
. -
#proxypwd ⇒ String
Obtain the username/password string that will be used for proxy connection during subsequent calls to
perform
. -
#proxypwd=(string) ⇒ String
Set the username/password string to use for proxy connection during subsequent calls to
perform
. -
#put_data=(data) ⇒ Object
Points this Curl::Easy instance to data to be uploaded via PUT.
-
#redirect_count ⇒ Integer
Retrieve the total number of redirections that were actually followed.
-
#redirect_time ⇒ Float
Retrieve the total time, in seconds, it took for all redirection steps include name lookup, connect, pretransfer and transfer before final transaction was started.
-
#request_size ⇒ Fixnum
Retrieve the total size of the issued requests.
-
#reset ⇒ Hash
Reset the Curl::Easy instance, clears out all settings.
-
#response_code ⇒ Fixnum
Retrieve the last received HTTP or FTP code.
-
#ssl_verify_host=(boolean) ⇒ Boolean
Configure whether this Curl instance will verify that the server cert is for the server it is known as.
-
#ssl_verify_host? ⇒ Boolean
Determine whether this Curl instance will verify that the server cert is for the server it is known as.
-
#ssl_verify_peer=(boolean) ⇒ Boolean
Configure whether this Curl instance will verify the SSL peer certificate.
-
#ssl_verify_peer? ⇒ Boolean
Determine whether this Curl instance will verify the SSL peer certificate.
-
#ssl_verify_result ⇒ Integer
Retrieve the result of the certification verification that was requested (by setting
ssl_verify_peer?
totrue
). -
#ssl_version ⇒ Fixnum
Get the version of SSL/TLS that libcurl will attempt to use.
-
#ssl_version=(value) ⇒ Fixnum?
Sets the version of SSL/TLS that libcurl will attempt to use.
-
#start_transfer_time ⇒ Float
Retrieve the time, in seconds, it took from the start until the first byte is just about to be transferred.
-
#timeout ⇒ Fixnum?
Obtain the maximum time in seconds that you allow the libcurl transfer operation to take.
-
#timeout=(fixnum) ⇒ Fixnum?
Set the maximum time in seconds that you allow the libcurl transfer operation to take.
-
#total_time ⇒ Float
Retrieve the total time in seconds for the previous transfer, including name resolving, TCP connect etc.
-
#unescape("some%20text") ⇒ Object
Convert the given URL encoded input string to a “plain string” and return the result.
-
#unrestricted_auth=(boolean) ⇒ Boolean
Configure whether this Curl instance may use any HTTP authentication method available when necessary.
-
#unrestricted_auth? ⇒ Boolean
Determine whether this Curl instance may use any HTTP authentication method available when necessary.
-
#upload_speed ⇒ Float
Retrieve the average upload speed that curl measured for the preceeding complete upload.
-
#uploaded_bytes ⇒ Float
Retrieve the total amount of bytes that were uploaded in the preceeding transfer.
-
#uploaded_content_length ⇒ Float
Retrieve the content-length of the upload.
-
#url ⇒ String
Obtain the URL that will be used by subsequent calls to
perform
. -
#url=(url) ⇒ Object
Set the URL for subsequent calls to
perform
. -
#use_netrc=(boolean) ⇒ Boolean
Configure whether this Curl instance will use data from the user’s .netrc file for FTP connections.
-
#use_netrc? ⇒ Boolean
Determine whether this Curl instance will use data from the user’s .netrc file for FTP connections.
-
#use_ssl ⇒ Fixnum
Get the desired level for using SSL on FTP connections.
-
#use_ssl=(value) ⇒ Fixnum?
Ensure libcurl uses SSL for FTP connections.
-
#useragent ⇒ "Ruby/Curb"
Obtain the user agent string used for this Curl::Easy instance.
-
#useragent=(useragent) ⇒ Object
Set the user agent string for this Curl::Easy instance.
-
#username ⇒ String
Get the current username.
-
#username=(string) ⇒ String
Set the HTTP Authentication username.
-
#userpwd ⇒ String
Obtain the username/password string that will be used for subsequent calls to
perform
. -
#userpwd=(string) ⇒ String
Set the username/password string to use for subsequent calls to
perform
. -
#verbose=(boolean) ⇒ Boolean
Configure whether this Curl instance gives verbose output to STDERR during transfers.
-
#verbose? ⇒ Boolean
Determine whether this Curl instance gives verbose output to STDERR during transfers.
- #version=(version) ⇒ Object
Class Method Details
.download(url, filename = url.split(/\?/).first.split(/\//).last, &blk) ⇒ Object
call-seq:
Curl::Easy.download(url, filename = url.split(/\?/).first.split(/\//).last) { |curl| ... }
Stream the specified url (via perform) and save the data directly to the supplied filename (defaults to the last component of the URL path, which will usually be the filename most simple urls).
If a block is supplied, it will be passed the curl instance prior to the perform call.
Note that the semantics of the on_body handler are subtly changed when using download, to account for the automatic routing of data to the specified file: The data string is passed to the handler before it is written to the file, allowing the handler to perform mutative operations where necessary. As usual, the transfer will be aborted if the on_body handler returns a size that differs from the data chunk size - in this case, the offending chunk will not be written to the file, the file will be closed, and a Curl::Err::AbortedByCallbackError will be raised.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/curb.rb', line 26 def download(url, filename = url.split(/\?/).first.split(/\//).last, &blk) curl = Curl::Easy.new(url, &blk) File.open(filename, "wb") do |output| 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 end return curl end |
.Curl::Easy.http_delete(url) {|easy| ... } ⇒ #<Curl::Easy...>
Convenience method that creates a new Curl::Easy instance with the specified URL and calls http_delete
, before returning the new instance.
If a block is supplied, the new instance will be yielded just prior to the http_delete
call.
3137 3138 3139 3140 3141 3142 |
# File 'ext/curb_easy.c', line 3137 static VALUE ruby_curl_easy_class_perform_delete(int argc, VALUE *argv, VALUE klass) { VALUE c = ruby_curl_easy_new(argc, argv, klass); ruby_curl_easy_perform_delete(c); return c; } |
.Curl::Easy.http_get(url) {|easy| ... } ⇒ #<Curl::Easy...>
Convenience method that creates a new Curl::Easy instance with the specified URL and calls http_get
, before returning the new instance.
If a block is supplied, the new instance will be yielded just prior to the http_get
call.
3120 3121 3122 3123 3124 3125 |
# File 'ext/curb_easy.c', line 3120 static VALUE ruby_curl_easy_class_perform_get(int argc, VALUE *argv, VALUE klass) { VALUE c = ruby_curl_easy_new(argc, argv, klass); ruby_curl_easy_perform_get(c); return c; } |
.Curl::Easy.http_head(url) {|easy| ... } ⇒ #<Curl::Easy...>
Convenience method that creates a new Curl::Easy instance with the specified URL and calls http_head
, before returning the new instance.
If a block is supplied, the new instance will be yielded just prior to the http_head
call.
3154 3155 3156 3157 3158 3159 3160 |
# File 'ext/curb_easy.c', line 3154 static VALUE ruby_curl_easy_class_perform_head(int argc, VALUE *argv, VALUE klass) { VALUE c = ruby_curl_easy_new(argc, argv, klass); ruby_curl_easy_perform_head(c); return c; } |
.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 .Curl::Easy.http_post(url, "some = urlencoded%20form%20data", Curl: :PostField, "and = so%20on", ...) ⇒ true .Curl::Easy.http_post(url, Curl: :PostField, Curl: :PostField..., Curl: :PostField) ⇒ true
POST the specified formdata to the currently configured URL using the current options set for this Curl::Easy instance. This method always returns true, or raises an exception (defined under Curl::Err) on error.
If you wish to use multipart form encoding, you’ll need to supply a block in order to set multipart_form_post true. See #http_post for more information.
3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 |
# File 'ext/curb_easy.c', line 3180 static VALUE ruby_curl_easy_class_perform_post(int argc, VALUE *argv, VALUE klass) { VALUE url, fields; VALUE c; rb_scan_args(argc, argv, "1*", &url, &fields); c = ruby_curl_easy_new(1, &url, klass); if (argc > 1) { ruby_curl_easy_perform_post(argc - 1, &argv[1], c); } else { ruby_curl_easy_perform_post(0, NULL, c); } return c; } |
.Curl::Easy.http_put(url, data) {|c| ... } ⇒ Object
see easy.http_put
2411 2412 2413 2414 2415 |
# File 'ext/curb_easy.c', line 2411 static VALUE ruby_curl_easy_class_perform_put(VALUE klass, VALUE url, VALUE data) { VALUE c = ruby_curl_easy_new(1, &url, klass); ruby_curl_easy_perform_put(c, data); return c; } |
.Curl::Easy.new ⇒ #<Curl::Easy...> .Curl::Easy.new(url = nil) ⇒ #<Curl::Easy...> .Curl::Easy.new(url = nil) {|self| ... } ⇒ #<Curl::Easy...>
Create a new Curl::Easy instance, optionally supplying the URL. The block form allows further configuration to be supplied before the instance is returned.
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 |
# File 'ext/curb_easy.c', line 212 static VALUE ruby_curl_easy_new(int argc, VALUE *argv, VALUE klass) { CURLcode ecode; VALUE url, blk; VALUE new_curl; ruby_curl_easy *rbce; rb_scan_args(argc, argv, "01&", &url, &blk); rbce = ALLOC(ruby_curl_easy); /* handler */ rbce->curl = curl_easy_init(); if (!rbce->curl) { rb_raise(eCurlErrFailedInit, "Failed to initialize easy handle"); } rbce->multi = Qnil; ruby_curl_easy_zero(rbce); rb_easy_set("url", url); new_curl = Data_Wrap_Struct(klass, curl_easy_mark, curl_easy_free, rbce); /* set the new_curl pointer to the curl handle */ ecode = curl_easy_setopt(rbce->curl, CURLOPT_PRIVATE, (void*)new_curl); if (ecode != CURLE_OK) { raise_curl_easy_error_exception(ecode); } if (blk != Qnil) { rb_funcall(blk, idCall, 1, new_curl); } return new_curl; } |
.Curl::Easy.perform(url) {|easy| ... } ⇒ #<Curl::Easy...>
Convenience method that creates a new Curl::Easy instance with the specified URL and calls the general perform
method, before returning the new instance. For HTTP URLs, this is equivalent to calling http_get
.
If a block is supplied, the new instance will be yielded just prior to the http_get
call.
3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 |
# File 'ext/curb_easy.c', line 3099 static VALUE ruby_curl_easy_class_perform(int argc, VALUE *argv, VALUE klass) { VALUE c = ruby_curl_easy_new(argc, argv, klass); if (rb_block_given_p()) { rb_yield(c); } ruby_curl_easy_perform(c); return c; } |
Instance Method Details
#autoreferer=(autoreferer) ⇒ Object
easy = Curl::Easy.new easy.autoreferer=true
1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 |
# File 'ext/curb_easy.c', line 1474 static VALUE ruby_curl_easy_autoreferer_set(VALUE self, VALUE autoreferer) { ruby_curl_easy *rbce; Data_Get_Struct(self, ruby_curl_easy, rbce); if (Qtrue == autoreferer) { curl_easy_setopt(rbce->curl, CURLOPT_AUTOREFERER, 1); } else { curl_easy_setopt(rbce->curl, CURLOPT_AUTOREFERER, 0); } return autoreferer; } |
#body_str ⇒ Object
Return the response body from the previous call to perform
. This is populated by the default on_body
handler - if you supply your own body handler, this string will be empty.
2427 2428 2429 |
# File 'ext/curb_easy.c', line 2427 static VALUE ruby_curl_easy_body_str_get(VALUE self) { CURB_OBJECT_HGETTER(ruby_curl_easy, body_data); } |
#cacert ⇒ String
Obtain the cacert file to use for this Curl::Easy instance.
642 643 644 |
# File 'ext/curb_easy.c', line 642 static VALUE ruby_curl_easy_cacert_get(VALUE self) { CURB_OBJECT_HGETTER(ruby_curl_easy, cacert); } |
#cacert=(string) ⇒ Object
Set a cacert bundle to use for this Curl::Easy instance. This file will be used to validate SSL certificates.
632 633 634 |
# File 'ext/curb_easy.c', line 632 static VALUE ruby_curl_easy_cacert_set(VALUE self, VALUE cacert) { CURB_OBJECT_HSETTER(ruby_curl_easy, cacert); } |
#cert ⇒ String
Obtain the cert file to use for this Curl::Easy instance.
598 599 600 |
# File 'ext/curb_easy.c', line 598 static VALUE ruby_curl_easy_cert_get(VALUE self) { CURB_OBJECT_HGETTER(ruby_curl_easy, cert); } |
#cert=(string) ⇒ Object
Set a cert file to use for this Curl::Easy instance. This file will be used to validate SSL connections.
588 589 590 591 592 593 594 595 596 597 |
# File 'ext/curb_easy.c', line 588 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 |
#cert_key ⇒ Object
Obtain the cert key file to use for this Curl::Easy instance.
620 621 622 |
# File 'ext/curb_easy.c', line 620 static VALUE ruby_curl_easy_cert_key_get(VALUE self) { CURB_OBJECT_HGETTER(ruby_curl_easy, cert_key); } |
#cert_key=(cert_key) ⇒ Object
Set a cert key to use for this Curl::Easy instance. This file will be used to validate SSL certificates.
610 611 612 |
# File 'ext/curb_easy.c', line 610 static VALUE ruby_curl_easy_cert_key_set(VALUE self, VALUE cert_key) { CURB_OBJECT_HSETTER(ruby_curl_easy, cert_key); } |
#certpassword=(string) ⇒ Object
Set a password used to open the specified cert
652 653 654 |
# File 'ext/curb_easy.c', line 652 static VALUE ruby_curl_easy_certpassword_set(VALUE self, VALUE certpassword) { CURB_OBJECT_HSETTER(ruby_curl_easy, certpassword); } |
#certtype ⇒ String
Obtain the cert type used for this Curl::Easy instance
674 675 676 |
# File 'ext/curb_easy.c', line 674 static VALUE ruby_curl_easy_certtype_get(VALUE self) { CURB_OBJECT_HGETTER(ruby_curl_easy, certtype); } |
#certtype=(certtype) ⇒ Object
Set a cert type to use for this Curl::Easy instance. Default is PEM
664 665 666 |
# File 'ext/curb_easy.c', line 664 static VALUE ruby_curl_easy_certtype_set(VALUE self, VALUE certtype) { CURB_OBJECT_HSETTER(ruby_curl_easy, certtype); } |
#clone ⇒ Object #dup ⇒ Object Also known as: dup
Clone this Curl::Easy instance, creating a new instance. This method duplicates the underlying CURL* handle.
257 258 259 260 261 262 263 264 265 266 267 268 269 |
# File 'ext/curb_easy.c', line 257 static VALUE ruby_curl_easy_clone(VALUE self) { ruby_curl_easy *rbce, *newrbce; Data_Get_Struct(self, ruby_curl_easy, rbce); newrbce = ALLOC(ruby_curl_easy); memcpy(newrbce, rbce, sizeof(ruby_curl_easy)); newrbce->curl = curl_easy_duphandle(rbce->curl); newrbce->curl_headers = NULL; newrbce->curl_ftp_commands = NULL; return Data_Wrap_Struct(cCurlEasy, curl_easy_mark, curl_easy_free, newrbce); } |
#close ⇒ nil
Close the Curl::Easy instance. Any open connections are closed The easy handle is reinitialized. If a previous multi handle was open it is set to nil and will be cleared after a GC.
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 |
# File 'ext/curb_easy.c', line 279 static VALUE ruby_curl_easy_close(VALUE self) { CURLcode ecode; ruby_curl_easy *rbce; Data_Get_Struct(self, ruby_curl_easy, rbce); ruby_curl_easy_free(rbce); /* reinit the handle */ rbce->curl = curl_easy_init(); if (!rbce->curl) { rb_raise(eCurlErrFailedInit, "Failed to initialize easy handle"); } rbce->multi = Qnil; ruby_curl_easy_zero(rbce); /* give the new curl handle a reference back to the ruby object */ ecode = curl_easy_setopt(rbce->curl, CURLOPT_PRIVATE, (void*)self); if (ecode != CURLE_OK) { raise_curl_easy_error_exception(ecode); } return Qnil; } |
#connect_time ⇒ Float
Retrieve the time, in seconds, it took from the start until the connect to the remote host (or proxy) was completed.
2605 2606 2607 2608 2609 2610 2611 2612 2613 |
# File 'ext/curb_easy.c', line 2605 static VALUE ruby_curl_easy_connect_time_get(VALUE self) { ruby_curl_easy *rbce; double time; Data_Get_Struct(self, ruby_curl_easy, rbce); curl_easy_getinfo(rbce->curl, CURLINFO_CONNECT_TIME, &time); return rb_float_new(time); } |
#connect_timeout ⇒ Fixnum?
Obtain the maximum time in seconds that you allow the connection to the server to take.
1137 1138 1139 |
# File 'ext/curb_easy.c', line 1137 static VALUE ruby_curl_easy_connect_timeout_get(VALUE self, VALUE connect_timeout) { CURB_IMMED_GETTER(ruby_curl_easy, connect_timeout, 0); } |
#connect_timeout=(fixnum) ⇒ Fixnum?
Set the maximum time in seconds that you allow the connection to the server to take. This only limits the connection phase, once it has connected, this option is of no more use.
Set to nil (or zero) to disable connection timeout (it will then only timeout on the system’s internal timeouts).
1126 1127 1128 |
# File 'ext/curb_easy.c', line 1126 static VALUE ruby_curl_easy_connect_timeout_set(VALUE self, VALUE connect_timeout) { CURB_IMMED_SETTER(ruby_curl_easy, connect_timeout, 0); } |
#content_type ⇒ nil
Retrieve the content-type of the downloaded object. This is the value read from the Content-Type: field. If you get nil
, it means that the server didn’t send a valid Content-Type header or that the protocol used doesn’t support this.
2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 |
# File 'ext/curb_easy.c', line 2869 static VALUE ruby_curl_easy_content_type_get(VALUE self) { ruby_curl_easy *rbce; char* type; Data_Get_Struct(self, ruby_curl_easy, rbce); curl_easy_getinfo(rbce->curl, CURLINFO_CONTENT_TYPE, &type); if (type && type[0]) { // curl returns empty string if none return rb_str_new2(type); } else { return Qnil; } } |
#cookiefile ⇒ String
Obtain the cookiefile file for this Curl::Easy instance.
552 553 554 |
# File 'ext/curb_easy.c', line 552 static VALUE (VALUE self) { CURB_OBJECT_HGETTER(ruby_curl_easy, ); } |
#cookiefile=(string) ⇒ String
Set a file that contains cookies to be sent in subsequent requests by this Curl::Easy instance.
Note that you must set enable_cookies true to enable the cookie engine, or this option will be ignored.
542 543 544 |
# File 'ext/curb_easy.c', line 542 static VALUE (VALUE self, VALUE ) { CURB_OBJECT_HSETTER(ruby_curl_easy, ); } |
#cookiejar ⇒ String
Obtain the cookiejar file to use for this Curl::Easy instance.
576 577 578 |
# File 'ext/curb_easy.c', line 576 static VALUE (VALUE self) { CURB_OBJECT_HGETTER(ruby_curl_easy, ); } |
#cookiejar=(string) ⇒ String
Set a cookiejar file to use for this Curl::Easy instance. Cookies from the response will be written into this file.
Note that you must set enable_cookies true to enable the cookie engine, or this option will be ignored.
566 567 568 |
# File 'ext/curb_easy.c', line 566 static VALUE (VALUE self, VALUE ) { CURB_OBJECT_HSETTER(ruby_curl_easy, ); } |
#cookies ⇒ Object
Obtain the cookies for this Curl::Easy instance.
529 530 531 |
# File 'ext/curb_easy.c', line 529 static VALUE (VALUE self) { CURB_OBJECT_HGETTER(ruby_curl_easy, ); } |
#cookies=(cookies) ⇒ Object
Set cookies to be sent by this Curl::Easy instance. The format of the string should be NAME=CONTENTS, where NAME is the cookie name and CONTENTS is what the cookie should contain. Set multiple cookies in one string like this: “name1=content1; name2=content2;” etc.
519 520 521 |
# File 'ext/curb_easy.c', line 519 static VALUE (VALUE self, VALUE ) { CURB_OBJECT_HSETTER(ruby_curl_easy, ); } |
#easy=(Curl) ⇒ Object #delete=(true) ⇒ Object #end ⇒ Object #perform ⇒ Object
2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 |
# File 'ext/curb_easy.c', line 2369 static VALUE ruby_curl_easy_set_delete_option(VALUE self, VALUE onoff) { ruby_curl_easy *rbce; Data_Get_Struct(self, ruby_curl_easy, rbce); if( onoff == Qtrue ) { curl_easy_setopt(rbce->curl, CURLOPT_CUSTOMREQUEST, "DELETE"); } else { curl_easy_setopt(rbce->curl, CURLOPT_CUSTOMREQUEST, NULL); } return onoff; } |
#dns_cache_timeout ⇒ Fixnum?
Obtain the dns cache timeout in seconds.
1160 1161 1162 |
# File 'ext/curb_easy.c', line 1160 static VALUE ruby_curl_easy_dns_cache_timeout_get(VALUE self, VALUE dns_cache_timeout) { CURB_IMMED_GETTER(ruby_curl_easy, dns_cache_timeout, -1); } |
#dns_cache_timeout=(fixnum) ⇒ Fixnum?
Set the dns cache timeout in seconds. Name resolves will be kept in memory for this number of seconds. Set to zero (0) to completely disable caching, or set to nil (or -1) to make the cached entries remain forever. By default, libcurl caches this info for 60 seconds.
1150 1151 1152 |
# File 'ext/curb_easy.c', line 1150 static VALUE ruby_curl_easy_dns_cache_timeout_set(VALUE self, VALUE dns_cache_timeout) { CURB_IMMED_SETTER(ruby_curl_easy, dns_cache_timeout, -1); } |
#download_speed ⇒ Float
Retrieve the average download speed that curl measured for the preceeding complete download.
2760 2761 2762 2763 2764 2765 2766 2767 2768 |
# File 'ext/curb_easy.c', line 2760 static VALUE ruby_curl_easy_download_speed_get(VALUE self) { ruby_curl_easy *rbce; double bytes; Data_Get_Struct(self, ruby_curl_easy, rbce); curl_easy_getinfo(rbce->curl, CURLINFO_SPEED_DOWNLOAD, &bytes); return rb_float_new(bytes); } |
#downloaded_bytes ⇒ Float
Retrieve the total amount of bytes that were downloaded in the preceeding transfer.
2726 2727 2728 2729 2730 2731 2732 2733 2734 |
# File 'ext/curb_easy.c', line 2726 static VALUE ruby_curl_easy_downloaded_bytes_get(VALUE self) { ruby_curl_easy *rbce; double bytes; Data_Get_Struct(self, ruby_curl_easy, rbce); curl_easy_getinfo(rbce->curl, CURLINFO_SIZE_DOWNLOAD, &bytes); return rb_float_new(bytes); } |
#downloaded_content_length ⇒ Float
Retrieve the content-length of the download. This is the value read from the Content-Length: field.
2834 2835 2836 2837 2838 2839 2840 2841 2842 |
# File 'ext/curb_easy.c', line 2834 static VALUE ruby_curl_easy_downloaded_content_length_get(VALUE self) { ruby_curl_easy *rbce; double bytes; Data_Get_Struct(self, ruby_curl_easy, rbce); curl_easy_getinfo(rbce->curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &bytes); return rb_float_new(bytes); } |
#enable_cookies=(boolean) ⇒ Boolean
Configure whether the libcurl cookie engine is enabled for this Curl::Easy instance.
1579 1580 1581 1582 |
# File 'ext/curb_easy.c', line 1579 static VALUE (VALUE self, VALUE ) { CURB_BOOLEAN_SETTER(ruby_curl_easy, ); } |
#enable_cookies? ⇒ Boolean
Determine whether the libcurl cookie engine is enabled for this Curl::Easy instance.
1591 1592 1593 |
# File 'ext/curb_easy.c', line 1591 static VALUE (VALUE self) { CURB_BOOLEAN_GETTER(ruby_curl_easy, ); } |
#encoding ⇒ String
Get the set encoding types
695 696 697 |
# File 'ext/curb_easy.c', line 695 static VALUE ruby_curl_easy_encoding_get(VALUE self) { CURB_OBJECT_HGETTER(ruby_curl_easy, encoding); } |
#encoding=(string) ⇒ String
Set the accepted encoding types, curl will handle all of the decompression
685 686 687 |
# File 'ext/curb_easy.c', line 685 static VALUE ruby_curl_easy_encoding_set(VALUE self, VALUE encoding) { CURB_OBJECT_HSETTER(ruby_curl_easy, encoding); } |
#escape("some text") ⇒ Object
Convert the given input string to a URL encoded string and return the result. All input characters that are not a-z, A-Z or 0-9 are converted to their “URL escaped” version (%NN where NN is a two-digit hexadecimal number).
3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 |
# File 'ext/curb_easy.c', line 3033 static VALUE ruby_curl_easy_escape(VALUE self, VALUE svalue) { ruby_curl_easy *rbce; char *result; VALUE rresult; VALUE str = svalue; Data_Get_Struct(self, ruby_curl_easy, rbce); /* NOTE: make sure the value is a string, if not call to_s */ if( rb_type(str) != T_STRING ) { str = rb_funcall(str,rb_intern("to_s"),0); } #if (LIBCURL_VERSION_NUM >= 0x070f04) result = (char*)curl_easy_escape(rbce->curl, StringValuePtr(str), RSTRING_LEN(str)); #else result = (char*)curl_escape(StringValuePtr(str), RSTRING_LEN(str)); #endif rresult = rb_str_new2(result); curl_free(result); return rresult; } |
#fetch_file_time=(boolean) ⇒ Boolean
Configure whether this Curl instance will fetch remote file times, if available.
1340 1341 1342 |
# File 'ext/curb_easy.c', line 1340 static VALUE ruby_curl_easy_fetch_file_time_set(VALUE self, VALUE fetch_file_time) { CURB_BOOLEAN_SETTER(ruby_curl_easy, fetch_file_time); } |
#fetch_file_time? ⇒ Boolean
Determine whether this Curl instance will fetch remote file times, if available.
1351 1352 1353 |
# File 'ext/curb_easy.c', line 1351 static VALUE ruby_curl_easy_fetch_file_time_q(VALUE self) { CURB_BOOLEAN_GETTER(ruby_curl_easy, fetch_file_time); } |
#file_time ⇒ Fixnum
Retrieve the remote time of the retrieved document (in number of seconds since 1 jan 1970 in the GMT/UTC time zone). If you get -1, it can be because of many reasons (unknown, the server hides it or the server doesn’t support the command that tells document time etc) and the time of the document is unknown.
Note that you must tell the server to collect this information before the transfer is made, by setting fetch_file_time?
to true, or you will unconditionally get a -1 back.
This requires libcurl 7.5 or higher - otherwise -1 is unconditionally returned.
2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 |
# File 'ext/curb_easy.c', line 2549 static VALUE ruby_curl_easy_file_time_get(VALUE self) { #ifdef HAVE_CURLINFO_FILETIME ruby_curl_easy *rbce; long time; Data_Get_Struct(self, ruby_curl_easy, rbce); curl_easy_getinfo(rbce->curl, CURLINFO_FILETIME, &time); return LONG2NUM(time); #else rb_warn("Installed libcurl is too old to support file_time"); return INT2FIX(0); #endif } |
#follow_location=(boolean) ⇒ Boolean
Configure whether this Curl instance will follow Location: headers in HTTP responses. Redirects will only be followed to the extent specified by max_redirects
.
1465 1466 1467 |
# File 'ext/curb_easy.c', line 1465 static VALUE ruby_curl_easy_follow_location_set(VALUE self, VALUE follow_location) { CURB_BOOLEAN_SETTER(ruby_curl_easy, follow_location); } |
#follow_location? ⇒ Boolean
Determine whether this Curl instance will follow Location: headers in HTTP responses.
1495 1496 1497 |
# File 'ext/curb_easy.c', line 1495 static VALUE ruby_curl_easy_follow_location_q(VALUE self) { CURB_BOOLEAN_GETTER(ruby_curl_easy, follow_location); } |
#ftp_commands ⇒ Object
call-seq
easy.ftp_commands => array or nil
864 865 866 |
# File 'ext/curb_easy.c', line 864 static VALUE ruby_curl_easy_ftp_commands_get(VALUE self) { CURB_OBJECT_HGETTER(ruby_curl_easy, ftp_commands); } |
#ftp_commands=(ftp_commands) ⇒ Object
Explicitly sets the list of commands to execute on the FTP server when calling perform
856 857 858 |
# File 'ext/curb_easy.c', line 856 static VALUE ruby_curl_easy_ftp_commands_set(VALUE self, VALUE ftp_commands) { CURB_OBJECT_HSETTER(ruby_curl_easy, ftp_commands); } |
#ftp_entry_path ⇒ nil
Retrieve the path of the entry path. That is the initial path libcurl ended up in when logging on to the remote FTP server. This returns nil
if something is wrong.
(requires libcurl 7.15.4 or higher, otherwise nil
is always returned).
2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 |
# File 'ext/curb_easy.c', line 2981 static VALUE ruby_curl_easy_ftp_entry_path_get(VALUE self) { #ifdef HAVE_CURLINFO_FTP_ENTRY_PATH ruby_curl_easy *rbce; char* path = NULL; Data_Get_Struct(self, ruby_curl_easy, rbce); curl_easy_getinfo(rbce->curl, CURLINFO_FTP_ENTRY_PATH, &path); if (path && path[0]) { // curl returns NULL or empty string if none return rb_str_new2(path); } else { return Qnil; } #else rb_warn("Installed libcurl is too old to support num_connects"); return Qnil; #endif } |
#ftp_filemethod(ftp_filemethod) ⇒ Object
call-seq
easy.ftp_filemethod => fixnum
Get the configuration for how libcurl will reach files on the server.
1307 1308 1309 |
# File 'ext/curb_easy.c', line 1307 static VALUE ruby_curl_easy_ftp_filemethod_get(VALUE self, VALUE ftp_filemethod) { CURB_IMMED_GETTER(ruby_curl_easy, ftp_filemethod, -1); } |
#ftp_filemethod=(value) ⇒ Fixnum?
Controls how libcurl reaches files on the server. Valid options are Curl::CURL_MULTICWD, Curl::CURL_NOCWD, and Curl::CURL_SINGLECWD (see libcurl docs for CURLOPT_FTP_METHOD).
1297 1298 1299 |
# File 'ext/curb_easy.c', line 1297 static VALUE ruby_curl_easy_ftp_filemethod_set(VALUE self, VALUE ftp_filemethod) { CURB_IMMED_SETTER(ruby_curl_easy, ftp_filemethod, -1); } |
#ftp_response_timeout ⇒ Fixnum?
Obtain the maximum time that libcurl will wait for FTP command responses.
1187 1188 1189 |
# File 'ext/curb_easy.c', line 1187 static VALUE ruby_curl_easy_ftp_response_timeout_get(VALUE self, VALUE ftp_response_timeout) { CURB_IMMED_GETTER(ruby_curl_easy, ftp_response_timeout, 0); } |
#ftp_response_timeout=(fixnum) ⇒ Fixnum?
Set a timeout period (in seconds) on the amount of time that the server is allowed to take in order to generate a response message for a command before the session is considered hung. While curl is waiting for a response, this value overrides timeout
. It is recommended that if used in conjunction with timeout
, you set ftp_response_timeout
to a value smaller than timeout
.
Ignored if libcurl version is < 7.10.8.
1177 1178 1179 |
# File 'ext/curb_easy.c', line 1177 static VALUE ruby_curl_easy_ftp_response_timeout_set(VALUE self, VALUE ftp_response_timeout) { CURB_IMMED_SETTER(ruby_curl_easy, ftp_response_timeout, 0); } |
#easy=(Curl) ⇒ Object #head=(true) ⇒ Object #end ⇒ Object #perform ⇒ Object
2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 |
# File 'ext/curb_easy.c', line 2314 static VALUE ruby_curl_easy_set_head_option(VALUE self, VALUE onoff) { ruby_curl_easy *rbce; Data_Get_Struct(self, ruby_curl_easy, rbce); if( onoff == Qtrue ) { curl_easy_setopt(rbce->curl, CURLOPT_NOBODY, 1); } else { curl_easy_setopt(rbce->curl, CURLOPT_NOBODY, 0); } return onoff; } |
#header_in_body=(boolean) ⇒ Boolean
Configure whether this Curl instance will return HTTP headers combined with body data. If this option is set true, both header and body data will go to body_str
(or the configured on_body
handler).
1420 1421 1422 |
# File 'ext/curb_easy.c', line 1420 static VALUE ruby_curl_easy_header_in_body_set(VALUE self, VALUE header_in_body) { CURB_BOOLEAN_SETTER(ruby_curl_easy, header_in_body); } |
#header_in_body? ⇒ Boolean
Determine whether this Curl instance will verify the SSL peer certificate.
1431 1432 1433 |
# File 'ext/curb_easy.c', line 1431 static VALUE ruby_curl_easy_header_in_body_q(VALUE self) { CURB_BOOLEAN_GETTER(ruby_curl_easy, header_in_body); } |
#header_size ⇒ Fixnum
Retrieve the total size of all the headers received in the preceeding transfer.
2777 2778 2779 2780 2781 2782 2783 2784 2785 |
# File 'ext/curb_easy.c', line 2777 static VALUE ruby_curl_easy_header_size_get(VALUE self) { ruby_curl_easy *rbce; long size; Data_Get_Struct(self, ruby_curl_easy, rbce); curl_easy_getinfo(rbce->curl, CURLINFO_HEADER_SIZE, &size); return LONG2NUM(size); } |
#header_str ⇒ Object
Return the response header from the previous call to perform
. This is populated by the default on_header
handler - if you supply your own header handler, this string will be empty.
2439 2440 2441 |
# File 'ext/curb_easy.c', line 2439 static VALUE ruby_curl_easy_header_str_get(VALUE self) { CURB_OBJECT_HGETTER(ruby_curl_easy, header_data); } |
#headers ⇒ Hash, ...
Obtain the custom HTTP headers for following requests.
433 434 435 436 437 438 439 440 |
# File 'ext/curb_easy.c', line 433 static VALUE ruby_curl_easy_headers_get(VALUE self) { ruby_curl_easy *rbce; VALUE headers; Data_Get_Struct(self, ruby_curl_easy, rbce); headers = rb_easy_get("headers");//rb_hash_aref(rbce->opts, rb_intern("headers")); if (headers == Qnil) { headers = rb_easy_set("headers", rb_hash_new()); } return headers; } |
#headers=(headers) ⇒ Object
easy.headers = => “val” …, “Header” => “val” => val”, …
easy.headers = ["Header: val" ..., "Header: val"] => ["Header: val", ...]
Set custom HTTP headers for following requests. This can be used to add custom headers, or override standard headers used by libcurl. It defaults to a Hash.
For example to set a standard or custom header:
easy.headers["MyHeader"] = "myval"
To remove a standard header (this is useful when removing libcurls default ‘Expect: 100-Continue’ header when using HTTP form posts):
easy.headers["Expect"] = ''
Anything passed to libcurl as a header will be converted to a string during the perform step.
423 424 425 |
# File 'ext/curb_easy.c', line 423 static VALUE ruby_curl_easy_headers_set(VALUE self, VALUE headers) { CURB_OBJECT_HSETTER(ruby_curl_easy, headers); } |
#http(verb) ⇒ Object
Send an HTTP request with method set to verb, using the current options set for this Curl::Easy instance. This method always returns true or raises an exception (defined under Curl::Err) on error.
2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 |
# File 'ext/curb_easy.c', line 2171 static VALUE ruby_curl_easy_perform_verb(VALUE self, VALUE verb) { VALUE str_verb; if (rb_type(verb) == T_STRING) { return ruby_curl_easy_perform_verb_str(self, RSTRING_PTR(verb)); } else if (rb_respond_to(verb,rb_intern("to_s"))) { str_verb = rb_funcall(verb, rb_intern("to_s"), 0); return ruby_curl_easy_perform_verb_str(self, RSTRING_PTR(str_verb)); } else { rb_raise(rb_eRuntimeError, "Invalid HTTP VERB, must response to 'to_s'"); } } |
#http_auth_types ⇒ Fixnum?
Obtain the HTTP authentication types that may be used for the following perform
calls.
1035 1036 1037 |
# File 'ext/curb_easy.c', line 1035 static VALUE ruby_curl_easy_http_auth_types_get(VALUE self) { CURB_IMMED_GETTER(ruby_curl_easy, http_auth_types, 0); } |
#http_auth_types=(*args) ⇒ Object
VALUE self, VALUE http_auth_types) {
996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 |
# File 'ext/curb_easy.c', line 996 static VALUE ruby_curl_easy_http_auth_types_set(int argc, VALUE *argv, VALUE self) {//VALUE self, VALUE http_auth_types) { ruby_curl_easy *rbce; VALUE args_ary; int i, len; char* node = NULL; long mask = 0x000000; rb_scan_args(argc, argv, "*", &args_ary); Data_Get_Struct(self, ruby_curl_easy, rbce); len = RARRAY_LEN(args_ary); if (len == 1 && (TYPE(rb_ary_entry(args_ary,0)) == T_FIXNUM || rb_ary_entry(args_ary,0) == Qnil)) { if (rb_ary_entry(args_ary,0) == Qnil) { rbce->http_auth_types = 0; } else { rbce->http_auth_types = NUM2INT(rb_ary_entry(args_ary,0)); } } else { // we could have multiple values, but they should be symbols node = RSTRING_PTR(rb_funcall(rb_ary_entry(args_ary,0),rb_intern("to_s"),0)); mask = CURL_HTTPAUTH_STR_TO_NUM(node); for( i = 1; i < len; ++i ) { node = RSTRING_PTR(rb_funcall(rb_ary_entry(args_ary,i),rb_intern("to_s"),0)); mask |= CURL_HTTPAUTH_STR_TO_NUM(node); } rbce->http_auth_types = mask; } return INT2NUM(rbce->http_auth_types); } |
#http_connect_code ⇒ Fixnum
Retrieve the last received proxy response code to a CONNECT request.
2522 2523 2524 2525 2526 2527 2528 2529 2530 |
# File 'ext/curb_easy.c', line 2522 static VALUE ruby_curl_easy_http_connect_code_get(VALUE self) { ruby_curl_easy *rbce; long code; Data_Get_Struct(self, ruby_curl_easy, rbce); curl_easy_getinfo(rbce->curl, CURLINFO_HTTP_CONNECTCODE, &code); return LONG2NUM(code); } |
#http_delete ⇒ Object
DELETE the currently configured URL using the current options set for this Curl::Easy instance. This method always returns true, or raises an exception (defined under Curl::Err) on error.
2160 2161 2162 |
# File 'ext/curb_easy.c', line 2160 static VALUE ruby_curl_easy_perform_delete(VALUE self) { return ruby_curl_easy_perform_verb_str(self, "DELETE"); } |
#http_get ⇒ true
GET the currently configured URL using the current options set for this Curl::Easy instance. This method always returns true, or raises an exception (defined under Curl::Err) on error.
2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 |
# File 'ext/curb_easy.c', line 2119 static VALUE ruby_curl_easy_perform_get(VALUE self) { ruby_curl_easy *rbce; CURL *curl; Data_Get_Struct(self, ruby_curl_easy, rbce); curl = rbce->curl; curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, NULL); curl_easy_setopt(curl, CURLOPT_HTTPGET, 1); return handle_perform(self,rbce); } |
#http_head ⇒ true
Request headers from the currently configured URL using the HEAD method and current options set for this Curl::Easy instance. This method always returns true, or raises an exception (defined under Curl::Err) on error.
2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 |
# File 'ext/curb_easy.c', line 2291 static VALUE ruby_curl_easy_perform_head(VALUE self) { ruby_curl_easy *rbce; CURL *curl; VALUE ret; Data_Get_Struct(self, ruby_curl_easy, rbce); curl = rbce->curl; curl_easy_setopt(curl, CURLOPT_NOBODY, 1); ret = handle_perform(self,rbce); curl_easy_setopt(curl, CURLOPT_NOBODY, 0); return ret; } |
#http_post("url = encoded%20form%20data;and=so%20on") ⇒ true #http_post("url = encoded%20form%20data", "and = so%20on", ...) ⇒ true #http_post("url = encoded%20form%20data", Curl: :PostField, "and = so%20on", ...) ⇒ true #http_post(Curl: :PostField, Curl: :PostField..., Curl: :PostField) ⇒ true
POST the specified formdata to the currently configured URL using the current options set for this Curl::Easy instance. This method always returns true, or raises an exception (defined under Curl::Err) on error.
The Content-type of the POST is determined by the current setting of multipart_form_post? , according to the following rules:
-
When false (the default): the form will be POSTed with a content-type of ‘application/x-www-form-urlencoded’, and any of the four calling forms may be used.
-
When true: the form will be POSTed with a content-type of ‘multipart/formdata’. Only the last calling form may be used, i.e. only PostField instances may be POSTed. In this mode, individual fields’ content-types are recognised, and file upload fields are supported.
2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 |
# File 'ext/curb_easy.c', line 2225 static VALUE ruby_curl_easy_perform_post(int argc, VALUE *argv, VALUE self) { ruby_curl_easy *rbce; CURL *curl; int i; VALUE args_ary; rb_scan_args(argc, argv, "*", &args_ary); Data_Get_Struct(self, ruby_curl_easy, rbce); curl = rbce->curl; curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, NULL); if (rbce->multipart_form_post) { VALUE ret; struct curl_httppost *first = NULL, *last = NULL; // Make the multipart form for (i = 0; i < argc; i++) { if (rb_obj_is_instance_of(argv[i], cCurlPostField)) { append_to_form(argv[i], &first, &last); } else { rb_raise(eCurlErrInvalidPostField, "You must use PostFields only with multipart form posts"); return Qnil; } } curl_easy_setopt(curl, CURLOPT_POST, 0); curl_easy_setopt(curl, CURLOPT_HTTPPOST, first); ret = handle_perform(self,rbce); curl_formfree(first); return ret; } else { VALUE post_body = Qnil; /* TODO: check for PostField.file and raise error before to_s fails */ if ((post_body = rb_funcall(args_ary, idJoin, 1, rbstrAmp)) == Qnil) { rb_raise(eCurlErrError, "Failed to join arguments"); return Qnil; } else { /* if the function call above returns an empty string because no additional arguments were passed this makes sure a previously set easy.post_body = "arg=foo&bar=bin" will be honored */ if( post_body != Qnil && rb_type(post_body) == T_STRING && RSTRING_LEN(post_body) > 0 ) { ruby_curl_easy_post_body_set(self, post_body); } /* if post body is not defined, set it so we enable POST header, even though the request body is empty */ if( rb_easy_nil("postdata_buffer") ) { ruby_curl_easy_post_body_set(self, post_body); } return handle_perform(self,rbce); } } } |
#http_put(data) ⇒ true
PUT the supplied data to the currently configured URL using the current options set for this Curl::Easy instance. This method always returns true, or raises an exception (defined under Curl::Err) on error.
2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 |
# File 'ext/curb_easy.c', line 2392 static VALUE ruby_curl_easy_perform_put(VALUE self, VALUE data) { ruby_curl_easy *rbce; CURL *curl; Data_Get_Struct(self, ruby_curl_easy, rbce); curl = rbce->curl; curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, NULL); ruby_curl_easy_put_data_set(self, data); return handle_perform(self, rbce); } |
#inspect ⇒ "#<Curl::Easy http://google.com/>"
3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 |
# File 'ext/curb_easy.c', line 3004 static VALUE ruby_curl_easy_inspect(VALUE self) { char buf[64]; ruby_curl_easy *rbce; Data_Get_Struct(self, ruby_curl_easy, rbce); /* if we don't have a url set... we'll crash... */ if( !rb_easy_nil("url") && rb_easy_type_check("url", T_STRING)) { VALUE url = rb_easy_get("url"); size_t len = 13+((RSTRING_LEN(url) > 50) ? 50 : RSTRING_LEN(url)); /* "#<Net::HTTP http://www.google.com/:80 open=false>" */ memcpy(buf,"#<Curl::Easy ", 13); memcpy(buf+13,RSTRING_PTR(url), (len - 13)); buf[len++] = '>'; return rb_str_new(buf,len); } return rb_str_new2("#<Curl::Easy>"); } |
#interface ⇒ String
Obtain the interface name that is used as the outgoing network interface. The name can be an interface name, an IP address or a host name.
460 461 462 |
# File 'ext/curb_easy.c', line 460 static VALUE ruby_curl_easy_interface_get(VALUE self) { CURB_OBJECT_HGETTER(ruby_curl_easy, interface_hm); } |
#interface=(string) ⇒ String
Set the interface name to use as the outgoing network interface. The name can be an interface name, an IP address or a host name.
449 450 451 |
# File 'ext/curb_easy.c', line 449 static VALUE ruby_curl_easy_interface_set(VALUE self, VALUE interface_hm) { CURB_OBJECT_HSETTER(ruby_curl_easy, interface_hm); } |
#last_effective_url ⇒ nil
Retrieve the last effective URL used by this instance. This is the URL used in the last perform
call, and may differ from the value of easy.url.
2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 |
# File 'ext/curb_easy.c', line 2454 static VALUE ruby_curl_easy_last_effective_url_get(VALUE self) { ruby_curl_easy *rbce; char* url; Data_Get_Struct(self, ruby_curl_easy, rbce); curl_easy_getinfo(rbce->curl, CURLINFO_EFFECTIVE_URL, &url); if (url && url[0]) { // curl returns empty string if none return rb_str_new2(url); } else { return Qnil; } } |
#local_port ⇒ Fixnum?
Obtain the local port that will be used for the following perform
calls.
This option is ignored if compiled against libcurl < 7.15.2.
893 894 895 |
# File 'ext/curb_easy.c', line 893 static VALUE ruby_curl_easy_local_port_get(VALUE self) { CURB_IMMED_PORT_GETTER(ruby_curl_easy, local_port); } |
#local_port=(fixnum) ⇒ Fixnum?
Set the local port that will be used for the following perform
calls.
Passing nil
will return to the default behaviour (no local port preference).
This option is ignored if compiled against libcurl < 7.15.2.
881 882 883 |
# File 'ext/curb_easy.c', line 881 static VALUE ruby_curl_easy_local_port_set(VALUE self, VALUE local_port) { CURB_IMMED_PORT_SETTER(ruby_curl_easy, local_port, "port"); } |
#local_port_range ⇒ Fixnum?
Obtain the local port range that will be used for the following perform
calls.
This option is ignored if compiled against libcurl < 7.15.2.
924 925 926 |
# File 'ext/curb_easy.c', line 924 static VALUE ruby_curl_easy_local_port_range_get(VALUE self) { CURB_IMMED_PORT_GETTER(ruby_curl_easy, local_port_range); } |
#local_port_range=(fixnum) ⇒ Fixnum?
Set the local port range that will be used for the following perform
calls. This is a number (between 0 and 65535) that determines how far libcurl may deviate from the supplied local_port
in order to find an available port.
If you set local_port
it’s also recommended that you set this, since it is fairly likely that your specified port will be unavailable.
This option is ignored if compiled against libcurl < 7.15.2.
911 912 913 |
# File 'ext/curb_easy.c', line 911 static VALUE ruby_curl_easy_local_port_range_set(VALUE self, VALUE local_port_range) { CURB_IMMED_PORT_SETTER(ruby_curl_easy, local_port_range, "port range"); } |
#max_redirects ⇒ Fixnum?
Obtain the maximum number of redirections to follow in the following perform
calls.
1084 1085 1086 |
# File 'ext/curb_easy.c', line 1084 static VALUE ruby_curl_easy_max_redirects_get(VALUE self) { CURB_IMMED_GETTER(ruby_curl_easy, max_redirs, -1); } |
#max_redirects=(fixnum) ⇒ Fixnum?
Set the maximum number of redirections to follow in the following perform
calls. Set to nil or -1 allow an infinite number (the default). Setting this option only makes sense if follow_location
is also set true.
With libcurl >= 7.15.1, setting this to 0 will cause libcurl to refuse any redirect.
1073 1074 1075 |
# File 'ext/curb_easy.c', line 1073 static VALUE ruby_curl_easy_max_redirects_set(VALUE self, VALUE max_redirs) { CURB_IMMED_SETTER(ruby_curl_easy, max_redirs, -1); } |
#multipart_form_post=(boolean) ⇒ Boolean
Configure whether this Curl instance uses multipart/formdata content type for HTTP POST requests. If this is false (the default), then the application/x-www-form-urlencoded content type is used for the form data.
If this is set true, you must pass one or more PostField instances to the http_post method - no support for posting multipart forms from a string is provided.
1556 1557 1558 1559 |
# File 'ext/curb_easy.c', line 1556 static VALUE ruby_curl_easy_multipart_form_post_set(VALUE self, VALUE multipart_form_post) { CURB_BOOLEAN_SETTER(ruby_curl_easy, multipart_form_post); } |
#multipart_form_post? ⇒ Boolean
Determine whether this Curl instance uses multipart/formdata content type for HTTP POST requests.
1568 1569 1570 |
# File 'ext/curb_easy.c', line 1568 static VALUE ruby_curl_easy_multipart_form_post_q(VALUE self) { CURB_BOOLEAN_GETTER(ruby_curl_easy, multipart_form_post); } |
#name_lookup_time ⇒ Float
Retrieve the time, in seconds, it took from the start until the name resolving was completed.
2588 2589 2590 2591 2592 2593 2594 2595 2596 |
# File 'ext/curb_easy.c', line 2588 static VALUE ruby_curl_easy_name_lookup_time_get(VALUE self) { ruby_curl_easy *rbce; double time; Data_Get_Struct(self, ruby_curl_easy, rbce); curl_easy_getinfo(rbce->curl, CURLINFO_NAMELOOKUP_TIME, &time); return rb_float_new(time); } |
#native_cert= ⇒ Object
Allow the incoming cert string to be file:password but be careful to not use a colon from a windows file path as the split point. Mimic what curl’s main does
46 |
# File 'lib/curb.rb', line 46 alias_method :native_cert=, :cert= |
#nosignal=(onoff) ⇒ Object
easy = Curl::Easy.new easy.nosignal = true
2353 2354 2355 2356 2357 2358 2359 2360 2361 |
# File 'ext/curb_easy.c', line 2353 static VALUE ruby_curl_easy_set_nosignal(VALUE self, VALUE onoff) { ruby_curl_easy *rbce; Data_Get_Struct(self, ruby_curl_easy, rbce); curl_easy_setopt(rbce->curl, CURLOPT_NOSIGNAL, (Qtrue == onoff) ? 1 : 0); return onoff; } |
#num_connects ⇒ Integer
Retrieve the number of new connections libcurl had to create to achieve the previous transfer (only the successful connects are counted). Combined with redirect_count
you are able to know how many times libcurl successfully reused existing connection(s) or not.
See the Connection Options of curl_easy_setopt(3) to see how libcurl tries to make persistent connections to save time.
(requires libcurl 7.12.3 or higher, otherwise -1 is always returned).
2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 |
# File 'ext/curb_easy.c', line 2940 static VALUE ruby_curl_easy_num_connects_get(VALUE self) { #ifdef HAVE_CURLINFO_NUM_CONNECTS ruby_curl_easy *rbce; long result; Data_Get_Struct(self, ruby_curl_easy, rbce); curl_easy_getinfo(rbce->curl, CURLINFO_NUM_CONNECTS, &result); return LONG2NUM(result); #else rb_warn("Installed libcurl is too old to support num_connects"); return INT2FIX(-1); #endif } |
#on_body {|body_data| ... } ⇒ Object
Assign or remove the on_body
handler for this Curl::Easy instance. To remove a previously-supplied handler, call this method with no attached block.
The on_body
handler is called for each chunk of response body passed back by libcurl during perform
. It should perform any processing necessary, and return the actual number of bytes handled. Normally, this will equal the length of the data string, and CURL will continue processing. If the returned length does not equal the input length, CURL will abort the processing with a Curl::Err::AbortedByCallbackError.
1612 1613 1614 |
# File 'ext/curb_easy.c', line 1612 static VALUE ruby_curl_easy_on_body_set(int argc, VALUE *argv, VALUE self) { CURB_HANDLER_PROC_HSETTER(ruby_curl_easy, body_proc); } |
#on_complete {|easy| ... } ⇒ Object
Assign or remove the on_complete
handler for this Curl::Easy instance. To remove a previously-supplied handler, call this method with no attached block.
The on_complete
handler is called when the request is finished.
1656 1657 1658 |
# File 'ext/curb_easy.c', line 1656 static VALUE ruby_curl_easy_on_complete_set(int argc, VALUE *argv, VALUE self) { CURB_HANDLER_PROC_HSETTER(ruby_curl_easy, complete_proc); } |
#on_debug {|type, data| ... } ⇒ Object
Assign or remove the on_debug
handler for this Curl::Easy instance. To remove a previously-supplied handler, call this method with no attached block.
The on_debug
handler, if configured, will receive detailed information from libcurl during the perform call. This can be useful for debugging. Setting a debug handler overrides libcurl’s internal handler, disabling any output from verbose
, if set.
The type argument will match one of the Curl::Easy::CURLINFO_XXXX constants, and specifies the kind of information contained in the data. The data is passed as a String.
1714 1715 1716 |
# File 'ext/curb_easy.c', line 1714 static VALUE ruby_curl_easy_on_debug_set(int argc, VALUE *argv, VALUE self) { CURB_HANDLER_PROC_HSETTER(ruby_curl_easy, debug_proc); } |
#on_failure {|easy, code| ... } ⇒ Object
Assign or remove the on_failure
handler for this Curl::Easy instance. To remove a previously-supplied handler, call this method with no attached block.
The on_failure
handler is called when the request is finished with a status of 50x
1642 1643 1644 |
# File 'ext/curb_easy.c', line 1642 static VALUE ruby_curl_easy_on_failure_set(int argc, VALUE *argv, VALUE self) { CURB_HANDLER_PROC_HSETTER(ruby_curl_easy, failure_proc); } |
#on_header {|header_data| ... } ⇒ Object
Assign or remove the on_header
handler for this Curl::Easy instance. To remove a previously-supplied handler, call this method with no attached block.
The on_header
handler is called for each chunk of response header passed back by libcurl during perform
. The semantics are the same as for the block supplied to on_body
.
1672 1673 1674 |
# File 'ext/curb_easy.c', line 1672 static VALUE ruby_curl_easy_on_header_set(int argc, VALUE *argv, VALUE self) { CURB_HANDLER_PROC_HSETTER(ruby_curl_easy, header_proc); } |
#on_progress {|dl_total, dl_now, ul_total, ul_now| ... } ⇒ Object
Assign or remove the on_progress
handler for this Curl::Easy instance. To remove a previously-supplied handler, call this method with no attached block.
The on_progress
handler is called regularly by libcurl (approximately once per second) during transfers to allow the application to receive progress information. There is no guarantee that the reported progress will change between calls.
The result of the block call determines whether libcurl continues the transfer. Returning a non-true value (i.e. nil or false) will cause the transfer to abort, throwing a Curl::Err::AbortedByCallbackError.
1693 1694 1695 |
# File 'ext/curb_easy.c', line 1693 static VALUE ruby_curl_easy_on_progress_set(int argc, VALUE *argv, VALUE self) { CURB_HANDLER_PROC_HSETTER(ruby_curl_easy, progress_proc); } |
#on_success {|easy| ... } ⇒ Object
Assign or remove the on_success
handler for this Curl::Easy instance. To remove a previously-supplied handler, call this method with no attached block.
The on_success
handler is called when the request is finished with a status of 20x
1627 1628 1629 |
# File 'ext/curb_easy.c', line 1627 static VALUE ruby_curl_easy_on_success_set(int argc, VALUE *argv, VALUE self) { CURB_HANDLER_PROC_HSETTER(ruby_curl_easy, success_proc); } |
#os_errno ⇒ Integer
Retrieve the errno variable from a connect failure (requires libcurl 7.12.2 or higher, otherwise 0 is always returned).
2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 |
# File 'ext/curb_easy.c', line 2911 static VALUE ruby_curl_easy_os_errno_get(VALUE self) { #ifdef HAVE_CURLINFO_OS_ERRNO ruby_curl_easy *rbce; long result; Data_Get_Struct(self, ruby_curl_easy, rbce); curl_easy_getinfo(rbce->curl, CURLINFO_OS_ERRNO, &result); return LONG2NUM(result); #else rb_warn("Installed libcurl is too old to support os_errno"); return INT2FIX(0); #endif } |
#password ⇒ String
Get the current password
1239 1240 1241 1242 1243 1244 1245 |
# File 'ext/curb_easy.c', line 1239 static VALUE ruby_curl_easy_password_get(VALUE self, VALUE password) { #if HAVE_CURLOPT_PASSWORD CURB_OBJECT_HGETTER(ruby_curl_easy, password); #else return Qnil; #endif } |
#password=(string) ⇒ String
Set the HTTP Authentication password.
1225 1226 1227 1228 1229 1230 1231 |
# File 'ext/curb_easy.c', line 1225 static VALUE ruby_curl_easy_password_set(VALUE self, VALUE password) { #if HAVE_CURLOPT_PASSWORD CURB_OBJECT_HSETTER(ruby_curl_easy, password); #else return Qnil; #endif } |
#perform ⇒ true
Transfer the currently configured URL using the options set for this Curl::Easy instance. If this is an HTTP URL, it will be transferred via the GET or HEAD request method.
2193 2194 2195 2196 2197 2198 2199 |
# File 'ext/curb_easy.c', line 2193 static VALUE ruby_curl_easy_perform(VALUE self) { ruby_curl_easy *rbce; Data_Get_Struct(self, ruby_curl_easy, rbce); return handle_perform(self,rbce); } |
#post_body ⇒ String?
Obtain the POST body used in this Curl::Easy instance.
770 771 772 |
# File 'ext/curb_easy.c', line 770 static VALUE ruby_curl_easy_post_body_get(VALUE self) { CURB_OBJECT_HGETTER(ruby_curl_easy, postdata_buffer); } |
#post_body=(post_body) ⇒ Object
Sets the POST body of this Curl::Easy instance. This is expected to be URL encoded; no additional processing or encoding is done on the string. The content-type header will be set to application/x-www-form-urlencoded.
This is handy if you want to perform a POST against a Curl::Multi instance.
730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 |
# File 'ext/curb_easy.c', line 730 static VALUE ruby_curl_easy_post_body_set(VALUE self, VALUE post_body) { ruby_curl_easy *rbce; CURL *curl; char *data; long len; Data_Get_Struct(self, ruby_curl_easy, rbce); curl = rbce->curl; if ( post_body == Qnil ) { //rbce->postdata_buffer = Qnil; rb_easy_del("postdata_buffer"); } else { data = StringValuePtr(post_body); len = RSTRING_LEN(post_body); // Store the string, since it has to hang around for the duration of the // request. See CURLOPT_POSTFIELDS in the libcurl docs. //rbce->postdata_buffer = post_body; rb_easy_set("postdata_buffer", post_body); curl_easy_setopt(curl, CURLOPT_POST, 1); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data); curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, len); return post_body; } return Qnil; } |
#pre_transfer_time ⇒ Float
Retrieve the time, in seconds, it took from the start until the file transfer is just about to begin. This includes all pre-transfer commands and negotiations that are specific to the particular protocol(s) involved.
2624 2625 2626 2627 2628 2629 2630 2631 2632 |
# File 'ext/curb_easy.c', line 2624 static VALUE ruby_curl_easy_pre_transfer_time_get(VALUE self) { ruby_curl_easy *rbce; double time; Data_Get_Struct(self, ruby_curl_easy, rbce); curl_easy_getinfo(rbce->curl, CURLINFO_PRETRANSFER_TIME, &time); return rb_float_new(time); } |
#primary_ip ⇒ nil
Retrieve the resolved IP of the most recent connection
done with this curl handle. This string may be IPv6 if
that's enabled. This feature requires curl 7.19.x and above
2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 |
# File 'ext/curb_easy.c', line 2501 static VALUE ruby_curl_easy_primary_ip_get(VALUE self) { ruby_curl_easy *rbce; char* ip; Data_Get_Struct(self, ruby_curl_easy, rbce); curl_easy_getinfo(rbce->curl, CURLINFO_PRIMARY_IP, &ip); if (ip && ip[0]) { // curl returns empty string if none return rb_str_new2(ip); } else { return Qnil; } } |
#proxy_auth_types ⇒ Fixnum?
Obtain the proxy authentication types that may be used for the following perform
calls.
1058 1059 1060 |
# File 'ext/curb_easy.c', line 1058 static VALUE ruby_curl_easy_proxy_auth_types_get(VALUE self) { CURB_IMMED_GETTER(ruby_curl_easy, proxy_auth_types, 0); } |
#proxy_auth_types=(fixnum) ⇒ Fixnum?
Set the proxy authentication types that may be used for the following perform
calls. This is a bitmap made by ORing together the Curl::CURLAUTH constants.
1047 1048 1049 |
# File 'ext/curb_easy.c', line 1047 static VALUE ruby_curl_easy_proxy_auth_types_set(VALUE self, VALUE proxy_auth_types) { CURB_IMMED_SETTER(ruby_curl_easy, proxy_auth_types, 0); } |
#proxy_port ⇒ Fixnum?
Obtain the proxy port that will be used for the following perform
calls.
944 945 946 |
# File 'ext/curb_easy.c', line 944 static VALUE ruby_curl_easy_proxy_port_get(VALUE self) { CURB_IMMED_PORT_GETTER(ruby_curl_easy, proxy_port); } |
#proxy_port=(fixnum) ⇒ Fixnum?
Set the proxy port that will be used for the following perform
calls.
934 935 936 |
# File 'ext/curb_easy.c', line 934 static VALUE ruby_curl_easy_proxy_port_set(VALUE self, VALUE proxy_port) { CURB_IMMED_PORT_SETTER(ruby_curl_easy, proxy_port, "port"); } |
#proxy_tunnel=(boolean) ⇒ Boolean
Configure whether this Curl instance will use proxy tunneling.
1319 1320 1321 |
# File 'ext/curb_easy.c', line 1319 static VALUE ruby_curl_easy_proxy_tunnel_set(VALUE self, VALUE proxy_tunnel) { CURB_BOOLEAN_SETTER(ruby_curl_easy, proxy_tunnel); } |
#proxy_tunnel? ⇒ Boolean
Determine whether this Curl instance will use proxy tunneling.
1329 1330 1331 |
# File 'ext/curb_easy.c', line 1329 static VALUE ruby_curl_easy_proxy_tunnel_q(VALUE self) { CURB_BOOLEAN_GETTER(ruby_curl_easy, proxy_tunnel); } |
#proxy_type ⇒ Fixnum?
Obtain the proxy type that will be used for the following perform
calls.
965 966 967 |
# File 'ext/curb_easy.c', line 965 static VALUE ruby_curl_easy_proxy_type_get(VALUE self) { CURB_IMMED_GETTER(ruby_curl_easy, proxy_type, -1); } |
#proxy_type=(fixnum) ⇒ Fixnum?
Set the proxy type that will be used for the following perform
calls. This should be one of the Curl::CURLPROXY constants.
955 956 957 |
# File 'ext/curb_easy.c', line 955 static VALUE ruby_curl_easy_proxy_type_set(VALUE self, VALUE proxy_type) { CURB_IMMED_SETTER(ruby_curl_easy, proxy_type, -1); } |
#proxy_url ⇒ String
Obtain the HTTP Proxy URL that will be used by subsequent calls to perform
.
397 398 399 |
# File 'ext/curb_easy.c', line 397 static VALUE ruby_curl_easy_proxy_url_get(VALUE self) { CURB_OBJECT_HGETTER(ruby_curl_easy, proxy_url); } |
#proxy_url=(string) ⇒ String
Set the URL of the HTTP proxy to use for subsequent calls to perform
. The URL should specify the the host name or dotted IP address. To specify port number in this string, append :[port] to the end of the host name. The proxy string may be prefixed with [protocol]:// since any such prefix will be ignored. The proxy’s port number may optionally be specified with the separate option proxy_port .
When you tell the library to use an HTTP proxy, libcurl will transparently convert operations to HTTP even if you specify an FTP URL etc. This may have an impact on what other features of the library you can use, such as FTP specifics that don’t work unless you tunnel through the HTTP proxy. Such tunneling is activated with proxy_tunnel = true.
libcurl respects the environment variables http_proxy, ftp_proxy, all_proxy etc, if any of those is set. The proxy_url option does however override any possibly set environment variables.
Starting with libcurl 7.14.1, the proxy host string given in environment variables can be specified the exact same way as the proxy can be set with proxy_url, including protocol prefix (http://) and embedded user + password.
387 388 389 |
# File 'ext/curb_easy.c', line 387 static VALUE ruby_curl_easy_proxy_url_set(VALUE self, VALUE proxy_url) { CURB_OBJECT_HSETTER(ruby_curl_easy, proxy_url); } |
#proxypwd ⇒ String
Obtain the username/password string that will be used for proxy connection during subsequent calls to perform
. The supplied string should have the form “username:password”
506 507 508 |
# File 'ext/curb_easy.c', line 506 static VALUE ruby_curl_easy_proxypwd_get(VALUE self) { CURB_OBJECT_HGETTER(ruby_curl_easy, proxypwd); } |
#proxypwd=(string) ⇒ String
Set the username/password string to use for proxy connection during subsequent calls to perform
. The supplied string should have the form “username:password”
494 495 496 |
# File 'ext/curb_easy.c', line 494 static VALUE ruby_curl_easy_proxypwd_set(VALUE self, VALUE proxypwd) { CURB_OBJECT_HSETTER(ruby_curl_easy, proxypwd); } |
#put_data=(data) ⇒ Object
Points this Curl::Easy instance to data to be uploaded via PUT. This sets the request to a PUT type request - useful if you want to PUT via a multi handle.
782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 |
# File 'ext/curb_easy.c', line 782 static VALUE ruby_curl_easy_put_data_set(VALUE self, VALUE data) { ruby_curl_easy *rbce; CURL *curl; VALUE upload; VALUE headers; Data_Get_Struct(self, ruby_curl_easy, rbce); upload = ruby_curl_upload_new(cCurlUpload); ruby_curl_upload_stream_set(upload,data); curl = rbce->curl; rb_easy_set("upload", upload); /* keep the upload object alive as long as the easy handle is active or until the upload is complete or terminated... */ curl_easy_setopt(curl, CURLOPT_NOBODY,0); curl_easy_setopt(curl, CURLOPT_UPLOAD, 1); curl_easy_setopt(curl, CURLOPT_READFUNCTION, (curl_read_callback)read_data_handler); curl_easy_setopt(curl, CURLOPT_READDATA, rbce); /* * we need to set specific headers for the PUT to work... so * convert the internal headers structure to a HASH if one is set */ if (!rb_easy_nil("headers")) { if (rb_easy_type_check("headers", T_ARRAY) || rb_easy_type_check("headers", T_STRING)) { rb_raise(rb_eRuntimeError, "Must set headers as a HASH to modify the headers in an PUT request"); } } // exit fast if the payload is empty if (NIL_P(data)) { return data; } headers = rb_easy_get("headers"); if( headers == Qnil ) { headers = rb_hash_new(); } if (rb_respond_to(data, rb_intern("read"))) { VALUE stat = rb_funcall(data, rb_intern("stat"), 0); if( stat ) { VALUE size; if( rb_hash_aref(headers, rb_str_new2("Expect")) == Qnil ) { rb_hash_aset(headers, rb_str_new2("Expect"), rb_str_new2("")); } size = rb_funcall(stat, rb_intern("size"), 0); curl_easy_setopt(curl, CURLOPT_INFILESIZE, FIX2INT(size)); } else if( rb_hash_aref(headers, rb_str_new2("Transfer-Encoding")) == Qnil ) { rb_hash_aset(headers, rb_str_new2("Transfer-Encoding"), rb_str_new2("chunked")); } } else if (rb_respond_to(data, rb_intern("to_s"))) { curl_easy_setopt(curl, CURLOPT_INFILESIZE, RSTRING_LEN(data)); if( rb_hash_aref(headers, rb_str_new2("Expect")) == Qnil ) { rb_hash_aset(headers, rb_str_new2("Expect"), rb_str_new2("")); } } else { rb_raise(rb_eRuntimeError, "PUT data must respond to read or to_s"); } rb_easy_set("headers",headers); // if we made it this far, all should be well. return data; } |
#redirect_count ⇒ Integer
Retrieve the total number of redirections that were actually followed.
Requires libcurl 7.9.7 or higher, otherwise -1 is always returned.
2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 |
# File 'ext/curb_easy.c', line 2686 static VALUE ruby_curl_easy_redirect_count_get(VALUE self) { #ifdef HAVE_CURLINFO_REDIRECT_COUNT ruby_curl_easy *rbce; long count; Data_Get_Struct(self, ruby_curl_easy, rbce); curl_easy_getinfo(rbce->curl, CURLINFO_REDIRECT_COUNT, &count); return LONG2NUM(count); #else rb_warn("Installed libcurl is too old to support redirect_count"); return INT2FIX(-1); #endif } |
#redirect_time ⇒ Float
Retrieve the total time, in seconds, it took for all redirection steps include name lookup, connect, pretransfer and transfer before final transaction was started. redirect_time
contains the complete execution time for multiple redirections.
Requires libcurl 7.9.7 or higher, otherwise -1 is always returned.
2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 |
# File 'ext/curb_easy.c', line 2663 static VALUE ruby_curl_easy_redirect_time_get(VALUE self) { #ifdef HAVE_CURLINFO_REDIRECT_TIME ruby_curl_easy *rbce; double time; Data_Get_Struct(self, ruby_curl_easy, rbce); curl_easy_getinfo(rbce->curl, CURLINFO_REDIRECT_TIME, &time); return rb_float_new(time); #else rb_warn("Installed libcurl is too old to support redirect_time"); return rb_float_new(-1); #endif } |
#request_size ⇒ Fixnum
Retrieve the total size of the issued requests. This is so far only for HTTP requests. Note that this may be more than one request if follow_location?
is true.
2795 2796 2797 2798 2799 2800 2801 2802 2803 |
# File 'ext/curb_easy.c', line 2795 static VALUE ruby_curl_easy_request_size_get(VALUE self) { ruby_curl_easy *rbce; long size; Data_Get_Struct(self, ruby_curl_easy, rbce); curl_easy_getinfo(rbce->curl, CURLINFO_REQUEST_SIZE, &size); return LONG2NUM(size); } |
#reset ⇒ Hash
Reset the Curl::Easy instance, clears out all settings.
from curl.haxx.se/libcurl/c/curl_easy_reset.html Re-initializes all options previously set on a specified CURL handle to the default values. This puts back the handle to the same state as it was in when it was just created with curl_easy_init(3). It does not change the following information kept in the handle: live connections, the Session ID cache, the DNS cache, the cookies and shares.
The return value contains all settings stored.
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 |
# File 'ext/curb_easy.c', line 318 static VALUE ruby_curl_easy_reset(VALUE self) { CURLcode ecode; ruby_curl_easy *rbce; VALUE opts_dup; Data_Get_Struct(self, ruby_curl_easy, rbce); opts_dup = rb_funcall(rbce->opts, rb_intern("dup"), 0); curl_easy_reset(rbce->curl); ruby_curl_easy_zero(rbce); /* rest clobbers the private setting, so reset it to self */ ecode = curl_easy_setopt(rbce->curl, CURLOPT_PRIVATE, (void*)self); if (ecode != CURLE_OK) { raise_curl_easy_error_exception(ecode); } return opts_dup; } |
#response_code ⇒ Fixnum
Retrieve the last received HTTP or FTP code. This will be zero if no server response code has been received. Note that a proxy’s CONNECT response should be read with http_connect_code
and not this method.
2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 |
# File 'ext/curb_easy.c', line 2477 static VALUE ruby_curl_easy_response_code_get(VALUE self) { ruby_curl_easy *rbce; long code; Data_Get_Struct(self, ruby_curl_easy, rbce); #ifdef HAVE_CURLINFO_RESPONSE_CODE curl_easy_getinfo(rbce->curl, CURLINFO_RESPONSE_CODE, &code); #else // old libcurl curl_easy_getinfo(rbce->curl, CURLINFO_HTTP_CODE, &code); #endif return LONG2NUM(code); } |
#ssl_verify_host=(boolean) ⇒ Boolean
Configure whether this Curl instance will verify that the server cert is for the server it is known as. When true (the default) the server certificate must indicate that the server is the server to which you meant to connect, or the connection fails. When false, the connection will succeed regardless of the names in the certificate.
this option controls is of the identity that the server claims. The server could be lying. To control lying, see ssl_verify_peer? .
1397 1398 1399 |
# File 'ext/curb_easy.c', line 1397 static VALUE ruby_curl_easy_ssl_verify_host_set(VALUE self, VALUE ssl_verify_host) { CURB_BOOLEAN_SETTER(ruby_curl_easy, ssl_verify_host); } |
#ssl_verify_host? ⇒ Boolean
Determine whether this Curl instance will verify that the server cert is for the server it is known as.
1408 1409 1410 |
# File 'ext/curb_easy.c', line 1408 static VALUE ruby_curl_easy_ssl_verify_host_q(VALUE self) { CURB_BOOLEAN_GETTER(ruby_curl_easy, ssl_verify_host); } |
#ssl_verify_peer=(boolean) ⇒ Boolean
Configure whether this Curl instance will verify the SSL peer certificate. When true (the default), and the verification fails to prove that the certificate is authentic, the connection fails. When false, the connection succeeds regardless.
Authenticating the certificate is not by itself very useful. You typically want to ensure that the server, as authentically identified by its certificate, is the server you mean to be talking to. The ssl_verify_host? options controls that.
1369 1370 1371 |
# File 'ext/curb_easy.c', line 1369 static VALUE ruby_curl_easy_ssl_verify_peer_set(VALUE self, VALUE ssl_verify_peer) { CURB_BOOLEAN_SETTER(ruby_curl_easy, ssl_verify_peer); } |
#ssl_verify_peer? ⇒ Boolean
Determine whether this Curl instance will verify the SSL peer certificate.
1380 1381 1382 |
# File 'ext/curb_easy.c', line 1380 static VALUE ruby_curl_easy_ssl_verify_peer_q(VALUE self) { CURB_BOOLEAN_GETTER(ruby_curl_easy, ssl_verify_peer); } |
#ssl_verify_result ⇒ Integer
Retrieve the result of the certification verification that was requested (by setting ssl_verify_peer?
to true
).
2812 2813 2814 2815 2816 2817 2818 2819 2820 |
# File 'ext/curb_easy.c', line 2812 static VALUE ruby_curl_easy_ssl_verify_result_get(VALUE self) { ruby_curl_easy *rbce; long result; Data_Get_Struct(self, ruby_curl_easy, rbce); curl_easy_getinfo(rbce->curl, CURLINFO_SSL_VERIFYRESULT, &result); return LONG2NUM(result); } |
#ssl_version ⇒ Fixnum
Get the version of SSL/TLS that libcurl will attempt to use.
1265 1266 1267 |
# File 'ext/curb_easy.c', line 1265 static VALUE ruby_curl_easy_ssl_version_get(VALUE self, VALUE ssl_version) { CURB_IMMED_GETTER(ruby_curl_easy, ssl_version, -1); } |
#ssl_version=(value) ⇒ Fixnum?
Sets the version of SSL/TLS that libcurl will attempt to use. Valid options are Curl::CURL_SSLVERSION_TLSv1, Curl::CURL_SSLVERSION::SSLv2, Curl::CURL_SSLVERSION_SSLv3 and Curl::CURL_SSLVERSION_DEFAULT
1255 1256 1257 |
# File 'ext/curb_easy.c', line 1255 static VALUE ruby_curl_easy_ssl_version_set(VALUE self, VALUE ssl_version) { CURB_IMMED_SETTER(ruby_curl_easy, ssl_version, -1); } |
#start_transfer_time ⇒ Float
Retrieve the time, in seconds, it took from the start until the first byte is just about to be transferred. This includes the pre_transfer_time
and also the time the server needs to calculate the result.
2642 2643 2644 2645 2646 2647 2648 2649 2650 |
# File 'ext/curb_easy.c', line 2642 static VALUE ruby_curl_easy_start_transfer_time_get(VALUE self) { ruby_curl_easy *rbce; double time; Data_Get_Struct(self, ruby_curl_easy, rbce); curl_easy_getinfo(rbce->curl, CURLINFO_STARTTRANSFER_TIME, &time); return rb_float_new(time); } |
#timeout ⇒ Fixnum?
Obtain the maximum time in seconds that you allow the libcurl transfer operation to take.
1111 1112 1113 |
# File 'ext/curb_easy.c', line 1111 static VALUE ruby_curl_easy_timeout_get(VALUE self, VALUE timeout) { CURB_IMMED_GETTER(ruby_curl_easy, timeout, 0); } |
#timeout=(fixnum) ⇒ Fixnum?
Set the maximum time in seconds that you allow the libcurl transfer operation to take. Normally, name lookups can take a considerable time and limiting operations to less than a few minutes risk aborting perfectly normal operations.
Set to nil (or zero) to disable timeout (it will then only timeout on the system’s internal timeouts).
1100 1101 1102 |
# File 'ext/curb_easy.c', line 1100 static VALUE ruby_curl_easy_timeout_set(VALUE self, VALUE timeout) { CURB_IMMED_SETTER(ruby_curl_easy, timeout, 0); } |
#total_time ⇒ Float
Retrieve the total time in seconds for the previous transfer, including name resolving, TCP connect etc.
2571 2572 2573 2574 2575 2576 2577 2578 2579 |
# File 'ext/curb_easy.c', line 2571 static VALUE ruby_curl_easy_total_time_get(VALUE self) { ruby_curl_easy *rbce; double time; Data_Get_Struct(self, ruby_curl_easy, rbce); curl_easy_getinfo(rbce->curl, CURLINFO_TOTAL_TIME, &time); return rb_float_new(time); } |
#unescape("some%20text") ⇒ Object
Convert the given URL encoded input string to a “plain string” and return the result. All input characters that are URL encoded (%XX where XX is a two-digit hexadecimal number) are converted to their binary versions.
3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 |
# File 'ext/curb_easy.c', line 3064 static VALUE ruby_curl_easy_unescape(VALUE self, VALUE str) { ruby_curl_easy *rbce; int rlen; char *result; VALUE rresult; Data_Get_Struct(self, ruby_curl_easy, rbce); #if (LIBCURL_VERSION_NUM >= 0x070f04) result = (char*)curl_easy_unescape(rbce->curl, StringValuePtr(str), RSTRING_LEN(str), &rlen); #else result = (char*)curl_unescape(StringValuePtr(str), RSTRING_LEN(str)); rlen = strlen(result); #endif rresult = rb_str_new(result, rlen); curl_free(result); return rresult; } |
#unrestricted_auth=(boolean) ⇒ Boolean
Configure whether this Curl instance may use any HTTP authentication method available when necessary.
1506 1507 1508 |
# File 'ext/curb_easy.c', line 1506 static VALUE ruby_curl_easy_unrestricted_auth_set(VALUE self, VALUE unrestricted_auth) { CURB_BOOLEAN_SETTER(ruby_curl_easy, unrestricted_auth); } |
#unrestricted_auth? ⇒ Boolean
Determine whether this Curl instance may use any HTTP authentication method available when necessary.
1517 1518 1519 |
# File 'ext/curb_easy.c', line 1517 static VALUE ruby_curl_easy_unrestricted_auth_q(VALUE self) { CURB_BOOLEAN_GETTER(ruby_curl_easy, unrestricted_auth); } |
#upload_speed ⇒ Float
Retrieve the average upload speed that curl measured for the preceeding complete upload.
2743 2744 2745 2746 2747 2748 2749 2750 2751 |
# File 'ext/curb_easy.c', line 2743 static VALUE ruby_curl_easy_upload_speed_get(VALUE self) { ruby_curl_easy *rbce; double bytes; Data_Get_Struct(self, ruby_curl_easy, rbce); curl_easy_getinfo(rbce->curl, CURLINFO_SPEED_UPLOAD, &bytes); return rb_float_new(bytes); } |
#uploaded_bytes ⇒ Float
Retrieve the total amount of bytes that were uploaded in the preceeding transfer.
2709 2710 2711 2712 2713 2714 2715 2716 2717 |
# File 'ext/curb_easy.c', line 2709 static VALUE ruby_curl_easy_uploaded_bytes_get(VALUE self) { ruby_curl_easy *rbce; double bytes; Data_Get_Struct(self, ruby_curl_easy, rbce); curl_easy_getinfo(rbce->curl, CURLINFO_SIZE_UPLOAD, &bytes); return rb_float_new(bytes); } |
#uploaded_content_length ⇒ Float
Retrieve the content-length of the upload.
2850 2851 2852 2853 2854 2855 2856 2857 2858 |
# File 'ext/curb_easy.c', line 2850 static VALUE ruby_curl_easy_uploaded_content_length_get(VALUE self) { ruby_curl_easy *rbce; double bytes; Data_Get_Struct(self, ruby_curl_easy, rbce); curl_easy_getinfo(rbce->curl, CURLINFO_CONTENT_LENGTH_UPLOAD, &bytes); return rb_float_new(bytes); } |
#url ⇒ String
Obtain the URL that will be used by subsequent calls to perform
.
358 359 360 |
# File 'ext/curb_easy.c', line 358 static VALUE ruby_curl_easy_url_get(VALUE self) { CURB_OBJECT_HGETTER(ruby_curl_easy, url); } |
#url=(url) ⇒ Object
Set the URL for subsequent calls to perform
. It is acceptable (and even recommended) to reuse Curl::Easy instances by reassigning the URL between calls to perform
.
348 349 350 |
# File 'ext/curb_easy.c', line 348 static VALUE ruby_curl_easy_url_set(VALUE self, VALUE url) { CURB_OBJECT_HSETTER(ruby_curl_easy, url); } |
#use_netrc=(boolean) ⇒ Boolean
Configure whether this Curl instance will use data from the user’s .netrc file for FTP connections.
1442 1443 1444 |
# File 'ext/curb_easy.c', line 1442 static VALUE ruby_curl_easy_use_netrc_set(VALUE self, VALUE use_netrc) { CURB_BOOLEAN_SETTER(ruby_curl_easy, use_netrc); } |
#use_netrc? ⇒ Boolean
Determine whether this Curl instance will use data from the user’s .netrc file for FTP connections.
1453 1454 1455 |
# File 'ext/curb_easy.c', line 1453 static VALUE ruby_curl_easy_use_netrc_q(VALUE self) { CURB_BOOLEAN_GETTER(ruby_curl_easy, use_netrc); } |
#use_ssl ⇒ Fixnum
Get the desired level for using SSL on FTP connections.
1286 1287 1288 |
# File 'ext/curb_easy.c', line 1286 static VALUE ruby_curl_easy_use_ssl_get(VALUE self, VALUE use_ssl) { CURB_IMMED_GETTER(ruby_curl_easy, use_ssl, -1); } |
#use_ssl=(value) ⇒ Fixnum?
Ensure libcurl uses SSL for FTP connections. Valid options are Curl::CURL_USESSL_NONE, Curl::CURL_USESSL_TRY, Curl::CURL_USESSL_CONTROL, and Curl::CURL_USESSL_ALL.
1276 1277 1278 |
# File 'ext/curb_easy.c', line 1276 static VALUE ruby_curl_easy_use_ssl_set(VALUE self, VALUE use_ssl) { CURB_IMMED_SETTER(ruby_curl_easy, use_ssl, -1); } |
#useragent ⇒ "Ruby/Curb"
Obtain the user agent string used for this Curl::Easy instance
716 717 718 |
# File 'ext/curb_easy.c', line 716 static VALUE ruby_curl_easy_useragent_get(VALUE self) { CURB_OBJECT_HGETTER(ruby_curl_easy, useragent); } |
#useragent=(useragent) ⇒ Object
Set the user agent string for this Curl::Easy instance
706 707 708 |
# File 'ext/curb_easy.c', line 706 static VALUE ruby_curl_easy_useragent_set(VALUE self, VALUE useragent) { CURB_OBJECT_HSETTER(ruby_curl_easy, useragent); } |
#username ⇒ String
Get the current username
1211 1212 1213 1214 1215 1216 1217 |
# File 'ext/curb_easy.c', line 1211 static VALUE ruby_curl_easy_username_get(VALUE self, VALUE username) { #if HAVE_CURLOPT_USERNAME CURB_OBJECT_HGETTER(ruby_curl_easy, username); #else return Qnil; #endif } |
#username=(string) ⇒ String
Set the HTTP Authentication username.
1197 1198 1199 1200 1201 1202 1203 |
# File 'ext/curb_easy.c', line 1197 static VALUE ruby_curl_easy_username_set(VALUE self, VALUE username) { #if HAVE_CURLOPT_USERNAME CURB_OBJECT_HSETTER(ruby_curl_easy, username); #else return Qnil; #endif } |
#userpwd ⇒ String
Obtain the username/password string that will be used for subsequent calls to perform
.
482 483 484 |
# File 'ext/curb_easy.c', line 482 static VALUE ruby_curl_easy_userpwd_get(VALUE self) { CURB_OBJECT_HGETTER(ruby_curl_easy, userpwd); } |
#userpwd=(string) ⇒ String
Set the username/password string to use for subsequent calls to perform
. The supplied string should have the form “username:password”
471 472 473 |
# File 'ext/curb_easy.c', line 471 static VALUE ruby_curl_easy_userpwd_set(VALUE self, VALUE userpwd) { CURB_OBJECT_HSETTER(ruby_curl_easy, userpwd); } |
#verbose=(boolean) ⇒ Boolean
Configure whether this Curl instance gives verbose output to STDERR during transfers. Ignored if this instance has an on_debug handler.
1528 1529 1530 |
# File 'ext/curb_easy.c', line 1528 static VALUE ruby_curl_easy_verbose_set(VALUE self, VALUE verbose) { CURB_BOOLEAN_SETTER(ruby_curl_easy, verbose); } |
#verbose? ⇒ Boolean
Determine whether this Curl instance gives verbose output to STDERR during transfers.
1539 1540 1541 |
# File 'ext/curb_easy.c', line 1539 static VALUE ruby_curl_easy_verbose_q(VALUE self) { CURB_BOOLEAN_GETTER(ruby_curl_easy, verbose); } |
#easy=(Curl) ⇒ Object #version=(Curl) ⇒ Object #version=(Curl) ⇒ Object #version=(Curl) ⇒ Object
2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 |
# File 'ext/curb_easy.c', line 2337 static VALUE ruby_curl_easy_set_version(VALUE self, VALUE version) { ruby_curl_easy *rbce; //fprintf(stderr,"CURL_HTTP_VERSION_1_1: %d, CURL_HTTP_VERSION_1_0: %d, CURL_HTTP_VERSION_NONE: %d\n", CURL_HTTP_VERSION_1_1, CURL_HTTP_VERSION_1_0, CURL_HTTP_VERSION_NONE); Data_Get_Struct(self, ruby_curl_easy, rbce); curl_easy_setopt(rbce->curl, CURLOPT_HTTP_VERSION, FIX2INT(version)); return version; } |