Class: Curl::Easy
- Inherits:
-
Object
- Object
- Curl::Easy
- Defined in:
- lib/curl/easy.rb,
ext/curb_easy.c
Defined Under Namespace
Classes: Error
Class Method Summary collapse
- .defer_multi_close(multi, easy, owner: Thread.current) ⇒ Object
- .deferred_multi_close_mutex ⇒ Object
- .deferred_multi_closes ⇒ Object
-
.download(url, filename = nil, download_options = {}, &blk) ⇒ Object
call-seq: Curl::Easy.download(url, filename = nil, options = {}) { |curl| … }.
-
.Curl::Easy.error(code) ⇒ Array, String
translate an internal libcurl error to ruby error class.
- .flush_deferred_multi_closes(all_threads: false) ⇒ Object
-
.http_delete(*args) {|c| ... } ⇒ Object
call-seq: Curl::Easy.http_delete(url) { |easy| … } => #<Curl::Easy…>.
-
.http_get(*args) {|c| ... } ⇒ Object
call-seq: Curl::Easy.http_get(url) { |easy| … } => #<Curl::Easy…>.
-
.http_head(*args) {|c| ... } ⇒ Object
call-seq: Curl::Easy.http_head(url) { |easy| … } => #<Curl::Easy…>.
-
.http_patch(*args) {|c| ... } ⇒ Object
call-seq: Curl::Easy.http_patch(url, data) {|c| … } Curl::Easy.http_patch(url, “some=urlencoded%20form%20data&and=so%20on”) => true Curl::Easy.http_patch(url, “some=urlencoded%20form%20data”, “and=so%20on”, …) => true Curl::Easy.http_patch(url, “some=urlencoded%20form%20data”, Curl::PostField, “and=so%20on”, …) => true Curl::Easy.http_patch(url, Curl::PostField, Curl::PostField …, Curl::PostField) => true.
-
.http_post(*args) {|c| ... } ⇒ Object
call-seq: 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.
-
.http_put(*args) {|c| ... } ⇒ Object
call-seq: Curl::Easy.http_put(url, data) {|c| … } Curl::Easy.http_put(url, “some=urlencoded%20form%20data&and=so%20on”) => true Curl::Easy.http_put(url, “some=urlencoded%20form%20data”, “and=so%20on”, …) => true Curl::Easy.http_put(url, “some=urlencoded%20form%20data”, Curl::PostField, “and=so%20on”, …) => true Curl::Easy.http_put(url, Curl::PostField, Curl::PostField …, Curl::PostField) => true.
-
.perform(*args) {|c| ... } ⇒ Object
call-seq: Curl::Easy.perform(url) { |easy| … } => #<Curl::Easy…>.
- .release_deferred_multi_close(multi, easy) ⇒ Object
Instance Method Summary collapse
- #_curb_native_close ⇒ Object
- #_curb_native_multi_set ⇒ Object
- #_curb_native_reset ⇒ Object
- #allowed_cidrs ⇒ Array?
-
#allowed_cidrs=(cidrs) ⇒ Object
Set resolved-peer CIDR ranges that are allowed when network_policy is :public.
- #allowed_hosts ⇒ Array?
-
#allowed_hosts=(hosts) ⇒ Object
Set URL hosts allowed for this handle.
- #allowed_protocols=(protocols) ⇒ Object
- #allowed_redirect_protocols=(protocols) ⇒ Object
- #app_connect_time ⇒ Object
-
#autoreferer=(autoreferer) ⇒ Object
easy = Curl::Easy.new easy.autoreferer=true.
-
#body_str ⇒ Object
(also: #body)
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.
-
#response_code ⇒ Fixnum
Retrieve the last received HTTP or FTP code.
-
#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.
-
#connect_timeout_ms ⇒ Fixnum?
Obtain the maximum time in milliseconds that you allow the connection to the server to take.
-
#connect_timeout_ms=(fixnum) ⇒ Fixnum?
Set the maximum time in milliseconds that you allow the connection to the server to take.
- #connect_to ⇒ Array?
-
#connect_to=(connect_to) ⇒ Object
Set the connect-to list to redirect matching request host/port pairs to alternate connection host/port pairs.
-
#content_type ⇒ nil
Retrieve the content-type of the downloaded object.
-
#cookiefile ⇒ String
Obtain the cookiefile path for this Curl::Easy instance (used to load cookies when the cookie engine is enabled).
-
#cookiefile=(value) ⇒ Object
call-seq: easy.cookiefile = string => string.
-
#cookiejar ⇒ String
Obtain the cookiejar path for this Curl::Easy instance (used to persist cookies when the cookie engine is enabled).
-
#cookiejar=(value) ⇒ Object
call-seq: easy.cookiejar = string => string.
-
#cookielist ⇒ Array<String>, ...
Retrieves the cookies curl knows in an array of strings.
-
#cookielist=(value) ⇒ Object
call-seq: easy.cookielist = string => string.
-
#cookies ⇒ Object
Obtain the manually set Cookie header string for this Curl::Easy instance.
-
#cookies=(value) ⇒ Object
call-seq: easy.cookies = “name1=content1; name2=content2;” => string.
-
#delete ⇒ Object
call-seq: easy.http_delete.
-
#delete=(onoff) ⇒ Object
call-seq: easy = Curl::Easy.new(“url”) do|c| c.delete = true end easy.perform.
-
#dns_cache_timeout ⇒ Fixnum?
Obtain the dns cache timeout in seconds.
-
#dns_cache_timeout=(fixnum) ⇒ Fixnum?
Set the dns cache timeout in seconds.
- #dns_servers ⇒ String?
- #doh_url ⇒ String?
-
#doh_url=(doh_url) ⇒ Object
Set the DNS-over-HTTPS URL to use for resolving hostnames.
-
#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=(onoff) ⇒ Object
call-seq: easy.follow_location = boolean => boolean.
-
#follow_location? ⇒ Boolean
Determine whether this Curl instance will follow Location: headers in HTTP responses.
- #ftp_commands ⇒ Array?
-
#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 ⇒ Fixnum
Get the configuration for how libcurl will reach files on the server.
-
#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.
-
#get ⇒ Object
call-seq: easy.http_get => true.
-
#getinfo(opt) ⇒ nil
Iniital access to libcurl curl_easy_getinfo, remember getinfo doesn’t return the same values as setopt.
-
#head=(onoff) ⇒ Object
call-seq: easy = Curl::Easy.new(“url”) do|c| c.head = true end easy.perform.
-
#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 return HTTP headers combined with body data.
-
#header_size ⇒ Fixnum
Retrieve the total size of all the headers received in the preceeding transfer.
-
#header_str ⇒ Object
(also: #head)
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
performcalls. -
#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
call-seq: easy.http_delete.
-
#http_get ⇒ Object
call-seq: easy.http_get => true.
-
#http_head ⇒ Object
call-seq: easy.http_head => true.
-
#http_patch(*args) ⇒ Object
PATCH the specified formdata to the currently configured URL using the 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.
-
#http_version ⇒ Integer
Returns the HTTP protocol version currently configured.
-
#http_version=(Curl) ⇒ Curl::HTTP_1_1
Force libcurl to use a specific HTTP protocol version.
-
#ignore_content_length=(boolean) ⇒ Object
Configure whether this Curl::Easy instance should ignore the content length header.
-
#ignore_content_length? ⇒ Boolean
Determine whether this Curl::Easy instance ignores the content length header.
-
#initialize(*args) ⇒ Object
constructor
Initialize a new Curl::Easy instance, optionally supplying the URL.
- #inspect ⇒ "#<Curl::Easy http://google.com/>"
-
#interface ⇒ String
Obtain the interface name that is used as the outgoing network interface.
-
#interface=(value) ⇒ Object
call-seq: easy.interface = string => string.
-
#last_effective_url ⇒ nil
Retrieve the last effective URL used by this instance.
- #last_error ⇒ "Error details"?
- #last_result ⇒ 0
-
#local_port ⇒ Fixnum?
Obtain the local port that will be used for the following
performcalls. -
#local_port=(fixnum) ⇒ Fixnum?
Set the local port that will be used for the following
performcalls. -
#local_port_range ⇒ Fixnum?
Obtain the local port range that will be used for the following
performcalls. -
#local_port_range=(fixnum) ⇒ Fixnum?
Set the local port range that will be used for the following
performcalls. -
#low_speed_limit ⇒ Fixnum?
Obtain the minimum transfer speed over low_speedtime+ below which the transfer will be aborted.
-
#low_speed_limit=(fixnum) ⇒ Fixnum?
Set the transfer speed (in bytes per second) that the transfer should be below during
low_speed_timeseconds for the library to consider it too slow and abort. -
#low_speed_time ⇒ Fixnum?
Obtain the time that the transfer should be below
low_speed_limitfor the library to abort it. -
#low_speed_time=(fixnum) ⇒ Fixnum?
Set the time (in seconds) that the transfer should be below the
low_speed_limitfor the library to consider it too slow and abort. - #max_body_bytes ⇒ Object
-
#max_body_bytes=(bytes_or_nil) ⇒ Object
Set an application-level cap for bytes accepted by the body write callback.
-
#max_recv_speed_large=(fixnum) ⇒ Fixnum?
Get the maximal receiving transfer speed (in bytes per second).
-
#max_recv_speed_large=(fixnum) ⇒ Fixnum?
Set the maximal receiving transfer speed (in bytes per second).
-
#max_redirects ⇒ Fixnum?
Obtain the maximum number of redirections to follow in the following
performcalls. -
#max_redirects=(fixnum) ⇒ Fixnum?
Set the maximum number of redirections to follow in the following
performcalls. -
#max_send_speed_large=(fixnum) ⇒ Fixnum?
Get the maximal sending transfer speed (in bytes per second).
-
#max_send_speed_large=(fixnum) ⇒ Fixnum?
Set the maximal sending transfer speed (in bytes per second).
- #multi ⇒ "#<Curl::Multi>"
- #multi= ⇒ "#<Curl::Multi>"
-
#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
-
#network_policy ⇒ Object
Determine which native network policy will be enforced when libcurl opens sockets for this handle.
-
#network_policy=(symbol) ⇒ Object
Supported values: [:none] disables native destination checks.
-
#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_bodyhandler for this Curl::Easy instance. -
#on_complete {|easy| ... } ⇒ Object
Assign or remove the
on_completehandler for this Curl::Easy instance. -
#on_debug {|type, data| ... } ⇒ Object
Assign or remove the
on_debughandler for this Curl::Easy instance. -
#on_failure {|easy, code| ... } ⇒ Object
Assign or remove the
on_failurehandler for this Curl::Easy instance. -
#on_header {|header_data| ... } ⇒ Object
Assign or remove the
on_headerhandler for this Curl::Easy instance. -
#on_missing {|easy, code| ... } ⇒ Object
Assign or remove the on_missing handler for this Curl::Easy instance.
-
#on_progress {|dl_total, dl_now, ul_total, ul_now| ... } ⇒ Object
Assign or remove the
on_progresshandler for this Curl::Easy instance. -
#on_redirect {|easy, code| ... } ⇒ Object
Assign or remove the on_redirect handler for this Curl::Easy instance.
-
#on_success {|easy| ... } ⇒ Object
Assign or remove the
on_successhandler 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 ⇒ Object
call-seq: easy.perform => true.
- #post ⇒ Object
-
#post_body ⇒ String?
Obtain the POST body used in this Curl::Easy instance.
- #post_body=(post_body) ⇒ Object
-
#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
performcalls. -
#proxy_auth_types=(fixnum) ⇒ Fixnum?
Set the proxy authentication types that may be used for the following
performcalls. -
#proxy_headers ⇒ Hash, ...
Obtain the custom HTTP proxy_headers for following requests.
- #proxy_headers=(proxy_headers) ⇒ Object
-
#proxy_port ⇒ Fixnum?
Obtain the proxy port that will be used for the following
performcalls. -
#proxy_port=(fixnum) ⇒ Fixnum?
Set the proxy port that will be used for the following
performcalls. -
#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
performcalls. -
#proxy_type=(fixnum) ⇒ Fixnum?
Set the proxy type that will be used for the following
performcalls. -
#proxy_url ⇒ String
Obtain the HTTP Proxy URL that will be used by subsequent calls to
perform. -
#proxy_url=(url) ⇒ Object
call-seq: easy.proxy_url = string => string.
-
#proxypwd ⇒ String
Obtain the username/password string that will be used for proxy connection during subsequent calls to
perform. -
#proxypwd=(value) ⇒ Object
call-seq: easy.proxypwd = string => string.
- #put ⇒ Object
-
#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.
-
#redirect_url ⇒ nil
Retrieve the URL a redirect would take you to if you would enable CURLOPT_FOLLOWLOCATION.
-
#request_size ⇒ Fixnum
Retrieve the total size of the issued requests.
-
#request_target=(value) ⇒ Object
call-seq: easy.request_target = string => string.
-
#reset ⇒ Hash
Reset the Curl::Easy instance, clears out all settings.
- #resolve ⇒ Array?
-
#resolve=(resolve) ⇒ Object
Set the resolve list to statically resolve hostnames to IP addresses, bypassing DNS for matching hostname/port combinations.
-
#resolve_mode ⇒ Object
Determines what type of IP address this Curl::Easy instance resolves DNS names to.
-
#resolve_mode=(symbol) ⇒ Object
Configures what type of IP address this Curl::Easy instance resolves DNS names to.
-
#response_code ⇒ Fixnum
Retrieve the last received HTTP or FTP code.
- #safe_http! ⇒ Object
-
#set(opt, val) ⇒ Object
call-seq: easy.set :sym|Fixnum, value.
-
#setopt(opt, val) ⇒ Object
Initial access to libcurl curl_easy_setopt.
-
#ssl_verify_host ⇒ Numeric
Determine whether this Curl instance will verify that the server cert is for the server it is known as.
- #ssl_verify_host=(value) ⇒ Object
-
#ssl_verify_host? ⇒ Boolean
call-seq: easy.ssl_verify_host? => boolean.
-
#ssl_verify_host_integer=(ssl_verify_host) ⇒ Object
Configure 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.
-
#status ⇒ Object
call-seq: easy.status => String.
-
#sym2curl(opt) ⇒ Object
call-seq: easy.sym2curl :symbol => Fixnum.
-
#timeout ⇒ Numeric
Obtain the maximum time in seconds that you allow the libcurl transfer operation to take.
-
#timeout=(float) ⇒ Numeric
Set the maximum time in seconds that you allow the libcurl transfer operation to take.
-
#timeout_ms ⇒ Fixnum?
Obtain the maximum time in milliseconds that you allow the libcurl transfer operation to take.
-
#timeout_ms=(fixnum) ⇒ Fixnum?
Set the maximum time in milliseconds 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.
-
#unix_socket_path ⇒ String?
Return the configured Unix socket path, if set through CURLOPT_UNIX_SOCKET_PATH.
-
#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.
-
#unsafe_destination_error ⇒ String?
Return the native network policy block reason from the most recent transfer.
-
#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=(u) ⇒ Object
-
#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=(value) ⇒ Object
call-seq: easy.userpwd = string => string.
-
#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 ⇒ Object
-
#version=(http_version) ⇒ Object
call-seq:.
Constructor Details
#Curl::Easy.new ⇒ #<Curl::Easy... #Curl::Easy.new(url = nil) ⇒ #<Curl::Easy... #Curl::Easy.new(url = nil) {|self| ... } ⇒ #<Curl::Easy...
Initialize a new Curl::Easy instance, optionally supplying the URL. The block form allows further configuration to be supplied before the instance is returned.
1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 |
# File 'ext/curb_easy.c', line 1482
static VALUE ruby_curl_easy_initialize(int argc, VALUE *argv, VALUE self) {
CURLcode ecode;
VALUE url, blk;
ruby_curl_easy *rbce;
rb_scan_args(argc, argv, "01&", &url, &blk);
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, rbce);
/* handler */
rbce->curl = curl_easy_init();
if (!rbce->curl) {
rb_raise(eCurlErrFailedInit, "Failed to initialize easy handle");
}
rbce->multi = Qnil;
rbce->opts = Qnil;
ruby_curl_easy_zero(rbce);
rbce->self = self;
curl_easy_setopt(rbce->curl, CURLOPT_ERRORBUFFER, &rbce->err_buf);
rb_easy_set("url", url);
/* set the pointer to the curl handle */
ecode = curl_easy_setopt(rbce->curl, CURLOPT_PRIVATE, (void*)rbce);
if (ecode != CURLE_OK) {
raise_curl_easy_error_exception(ecode);
}
if (blk != Qnil) {
rb_funcall(blk, idCall, 1, self);
}
return self;
}
|
Class Method Details
.defer_multi_close(multi, easy, owner: Thread.current) ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/curl/easy.rb', line 36 def defer_multi_close(multi, easy, owner: Thread.current) deferred_multi_close_mutex.synchronize do @deferred_multi_closes ||= [] return if @deferred_multi_closes.any? { |entry| entry[:multi].equal?(multi) } multi.instance_variable_set(:@deferred_close, true) @deferred_multi_closes << { multi: multi, easy: easy, owner: owner } end end |
.deferred_multi_close_mutex ⇒ Object
6 7 8 |
# File 'lib/curl/easy.rb', line 6 def deferred_multi_close_mutex @deferred_multi_close_mutex ||= Mutex.new end |
.deferred_multi_closes ⇒ Object
10 11 12 13 14 |
# File 'lib/curl/easy.rb', line 10 def deferred_multi_closes deferred_multi_close_mutex.synchronize do (@deferred_multi_closes ||= []).dup end end |
.download(url, filename = nil, download_options = {}, &blk) ⇒ Object
call-seq:
Curl::Easy.download(url, filename = nil, options = {}) { |curl| ... }
Stream the specified url (via perform) and save the data directly to the supplied filename. The destination is written through a temporary file and existing files are not overwritten unless :overwrite => true is passed. When filename is omitted, the destination is safely derived from the last URL path component in the current directory. Pass :download_dir to treat the filename as a basename inside a trusted directory and reject absolute, parent-directory, dotfile, and nested names.
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.
761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 |
# File 'lib/curl/easy.rb', line 761 def download(url, filename = nil, = {}, &blk) curl = Curl::Easy.new(url, &blk) _download_path, output, safe_output = Curl.prepare_download_output(url, filename, ) performed = false 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 performed = true ensure if safe_output output.close(performed) else output.close rescue IOError end end return curl end |
.Curl::Easy.error(code) ⇒ Array, String
translate an internal libcurl error to ruby error class
6066 6067 6068 |
# File 'ext/curb_easy.c', line 6066
static VALUE ruby_curl_easy_error_message(VALUE klass, VALUE code) {
return rb_curl_easy_error(NUM2INT(code));
}
|
.flush_deferred_multi_closes(all_threads: false) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/curl/easy.rb', line 46 def flush_deferred_multi_closes(all_threads: false) pending = deferred_multi_close_mutex.synchronize do @deferred_multi_closes ||= [] if all_threads @deferred_multi_closes.shift(@deferred_multi_closes.length) else owner = Thread.current remaining = [] current = [] @deferred_multi_closes.each do |entry| if entry[:owner].equal?(owner) current << entry else remaining << entry end end @deferred_multi_closes = remaining current end end pending.each do |entry| multi = entry[:multi] easy = entry[:easy] unless release_deferred_multi_close(multi, easy) defer_multi_close(multi, easy, owner: entry[:owner]) end end end |
.http_delete(*args) {|c| ... } ⇒ Object
call-seq:
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.
732 733 734 735 736 737 |
# File 'lib/curl/easy.rb', line 732 def http_delete(*args) c = Curl::Easy.new(*args) yield c if block_given? c.http_delete c end |
.http_get(*args) {|c| ... } ⇒ Object
call-seq:
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.
638 639 640 641 642 643 |
# File 'lib/curl/easy.rb', line 638 def http_get(*args) c = Curl::Easy.new(*args) yield c if block_given? c.http_get c end |
.http_head(*args) {|c| ... } ⇒ Object
call-seq:
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.
655 656 657 658 659 660 |
# File 'lib/curl/easy.rb', line 655 def http_head(*args) c = Curl::Easy.new(*args) yield c if block_given? c.http_head c end |
.http_patch(*args) {|c| ... } ⇒ Object
call-seq:
Curl::Easy.http_patch(url, data) {|c| ... }
Curl::Easy.http_patch(url, "some=urlencoded%20form%20data&and=so%20on") => true
Curl::Easy.http_patch(url, "some=urlencoded%20form%20data", "and=so%20on", ...) => true
Curl::Easy.http_patch(url, "some=urlencoded%20form%20data", Curl::PostField, "and=so%20on", ...) => true
Curl::Easy.http_patch(url, Curl::PostField, Curl::PostField ..., Curl::PostField) => true
see easy.http_patch
690 691 692 693 694 695 696 |
# File 'lib/curl/easy.rb', line 690 def http_patch(*args) url = args.shift c = Curl::Easy.new(url) yield c if block_given? c.http_patch(*args) c end |
.http_post(*args) {|c| ... } ⇒ Object
call-seq:
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.
714 715 716 717 718 719 720 |
# File 'lib/curl/easy.rb', line 714 def http_post(*args) url = args.shift c = Curl::Easy.new url yield c if block_given? c.http_post(*args) c end |
.http_put(*args) {|c| ... } ⇒ Object
call-seq:
Curl::Easy.http_put(url, data) {|c| ... }
Curl::Easy.http_put(url, "some=urlencoded%20form%20data&and=so%20on") => true
Curl::Easy.http_put(url, "some=urlencoded%20form%20data", "and=so%20on", ...) => true
Curl::Easy.http_put(url, "some=urlencoded%20form%20data", Curl::PostField, "and=so%20on", ...) => true
Curl::Easy.http_put(url, Curl::PostField, Curl::PostField ..., Curl::PostField) => true
see easy.http_put
672 673 674 675 676 677 678 |
# File 'lib/curl/easy.rb', line 672 def http_put(*args) url = args.shift c = Curl::Easy.new(url) yield c if block_given? c.http_put(*args) c end |
.perform(*args) {|c| ... } ⇒ Object
call-seq:
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.
621 622 623 624 625 626 |
# File 'lib/curl/easy.rb', line 621 def perform(*args) c = Curl::Easy.new(*args) yield c if block_given? c.perform c end |
.release_deferred_multi_close(multi, easy) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/curl/easy.rb', line 16 def release_deferred_multi_close(multi, easy) if easy && multi.requests[easy.object_id] begin multi.remove(easy) rescue StandardError # Deferred cleanup only applies to implicit single-easy multis, so # clear any stale Ruby bookkeeping and continue closing the handle. multi.instance_variable_set(:@requests, {}) end else multi.instance_variable_set(:@requests, {}) end multi.instance_variable_set(:@deferred_close, false) multi._close true rescue StandardError false end |
Instance Method Details
#_curb_native_close ⇒ Object
85 |
# File 'lib/curl/easy.rb', line 85 alias_method :_curb_native_close, :close |
#_curb_native_multi_set ⇒ Object
86 |
# File 'lib/curl/easy.rb', line 86 alias_method :_curb_native_multi_set, :multi= |
#_curb_native_reset ⇒ Object
87 |
# File 'lib/curl/easy.rb', line 87 alias_method :_curb_native_reset, :reset |
#allowed_cidrs ⇒ Array?
2389 2390 2391 2392 2393 2394 2395 2396 2397 |
# File 'ext/curb_easy.c', line 2389
static VALUE ruby_curl_easy_allowed_cidrs_get(VALUE self) {
ruby_curl_easy *rbce;
VALUE cidrs;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, rbce);
cidrs = rb_hash_aref(rbce->opts, rb_easy_hkey("allowed_cidrs"));
return curb_dup_string_array(cidrs);
}
|
#allowed_cidrs=(cidrs) ⇒ Object
Set resolved-peer CIDR ranges that are allowed when network_policy is :public. Private/local unsafe ranges are still blocked before this allowlist is evaluated.
2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 |
# File 'ext/curb_easy.c', line 2367
static VALUE ruby_curl_easy_allowed_cidrs_set(VALUE self, VALUE cidrs) {
ruby_curl_easy *rbce;
VALUE normalized;
VALUE stored;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, rbce);
normalized = curb_normalize_cidr_list(cidrs);
stored = curb_dup_string_array(normalized);
rb_hash_aset(rbce->opts, rb_easy_hkey("allowed_cidrs"), stored);
if (rbce->network_policy == CURB_NETWORK_POLICY_PUBLIC) {
curb_prepare_network_allowed_cidr_rules(rbce);
} else {
curb_clear_network_allowed_cidr_rules(rbce);
}
return curb_dup_string_array(stored);
}
|
#allowed_hosts ⇒ Array?
2425 2426 2427 2428 2429 2430 2431 2432 2433 |
# File 'ext/curb_easy.c', line 2425
static VALUE ruby_curl_easy_allowed_hosts_get(VALUE self) {
ruby_curl_easy *rbce;
VALUE hosts;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, rbce);
hosts = rb_hash_aref(rbce->opts, rb_easy_hkey("allowed_hosts"));
return curb_dup_string_array(hosts);
}
|
#allowed_hosts=(hosts) ⇒ Object
Set URL hosts allowed for this handle. When libcurl supports CURLOPT_PREREQFUNCTION, this is checked before each request, including followed redirects.
2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 |
# File 'ext/curb_easy.c', line 2407
static VALUE ruby_curl_easy_allowed_hosts_set(VALUE self, VALUE hosts) {
ruby_curl_easy *rbce;
VALUE normalized;
VALUE stored;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, rbce);
normalized = curb_normalize_host_list(hosts);
stored = curb_dup_string_array(normalized);
rb_hash_aset(rbce->opts, rb_easy_hkey("allowed_hosts"), stored);
curb_prepare_network_allowed_hosts(rbce);
return curb_dup_string_array(stored);
}
|
#allowed_protocols=(protocols) ⇒ Object
170 171 172 |
# File 'lib/curl/easy.rb', line 170 def allowed_protocols=(protocols) set_protocol_allowlist('CURLOPT_PROTOCOLS_STR', 'CURLOPT_PROTOCOLS', protocols) end |
#allowed_redirect_protocols=(protocols) ⇒ Object
174 175 176 |
# File 'lib/curl/easy.rb', line 174 def allowed_redirect_protocols=(protocols) set_protocol_allowlist('CURLOPT_REDIR_PROTOCOLS_STR', 'CURLOPT_REDIR_PROTOCOLS', protocols) end |
#app_connect_time ⇒ Object
5008 5009 5010 5011 5012 5013 5014 5015 5016 |
# File 'ext/curb_easy.c', line 5008
static VALUE ruby_curl_easy_app_connect_time_get(VALUE self) {
ruby_curl_easy *rbce;
double time;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, rbce);
curl_easy_getinfo(rbce->curl, CURLINFO_APPCONNECT_TIME, &time);
return rb_float_new(time);
}
|
#autoreferer=(autoreferer) ⇒ Object
easy = Curl::Easy.new easy.autoreferer=true
3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 |
# File 'ext/curb_easy.c', line 3208
static VALUE ruby_curl_easy_autoreferer_set(VALUE self, VALUE autoreferer) {
ruby_curl_easy *rbce;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, 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 Also known as: body
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.
4764 4765 4766 4767 4768 4769 4770 |
# File 'ext/curb_easy.c', line 4764
static VALUE ruby_curl_easy_body_str_get(VALUE self) {
/*
TODO: can we force_encoding on the return here if we see charset=utf-8 in the content-type header?
Content-Type: application/json; charset=utf-8
*/
CURB_OBJECT_HGETTER(ruby_curl_easy, body_data);
}
|
#cacert ⇒ String
Obtain the cacert file to use for this Curl::Easy instance.
1956 1957 1958 |
# File 'ext/curb_easy.c', line 1956 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.
1946 1947 1948 |
# File 'ext/curb_easy.c', line 1946
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.
1912 1913 1914 |
# File 'ext/curb_easy.c', line 1912 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.
1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 |
# File 'ext/curb_easy.c', line 1902 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.
1934 1935 1936 |
# File 'ext/curb_easy.c', line 1934 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.
1924 1925 1926 |
# File 'ext/curb_easy.c', line 1924
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
1966 1967 1968 |
# File 'ext/curb_easy.c', line 1966
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
1988 1989 1990 |
# File 'ext/curb_easy.c', line 1988 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
1978 1979 1980 |
# File 'ext/curb_easy.c', line 1978
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.
1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 |
# File 'ext/curb_easy.c', line 1562
static VALUE ruby_curl_easy_clone(VALUE self) {
ruby_curl_easy *rbce, *newrbce;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, rbce);
newrbce = ALLOC(ruby_curl_easy);
if (!newrbce) {
rb_raise(rb_eNoMemError, "Failed to allocate memory for Curl::Easy clone");
}
/* shallow copy */
memcpy(newrbce, rbce, sizeof(ruby_curl_easy));
/* now deep copy */
newrbce->curl = curl_easy_duphandle(rbce->curl);
if (!newrbce->curl) {
free(newrbce);
rb_raise(rb_eNoMemError, "Failed to duplicate Curl::Easy handle");
}
newrbce->curl_headers = (rbce->curl_headers) ? duplicate_curl_slist(rbce->curl_headers) : NULL;
newrbce->curl_proxy_headers = (rbce->curl_proxy_headers) ? duplicate_curl_slist(rbce->curl_proxy_headers) : NULL;
newrbce->curl_ftp_commands = (rbce->curl_ftp_commands) ? duplicate_curl_slist(rbce->curl_ftp_commands) : NULL;
newrbce->curl_resolve = (rbce->curl_resolve) ? duplicate_curl_slist(rbce->curl_resolve) : NULL;
newrbce->curl_connect_to = (rbce->curl_connect_to) ? duplicate_curl_slist(rbce->curl_connect_to) : NULL;
newrbce->network_allowed_cidr_rules = NULL;
newrbce->network_allowed_cidr_rule_count = 0;
newrbce->network_allowed_hosts = NULL;
newrbce->network_allowed_host_count = 0;
/* A cloned easy should not retain ownership reference to the original multi. */
newrbce->multi = Qnil;
newrbce->callback_error = Qnil;
newrbce->unsafe_destination_blocked = 0;
memset(newrbce->unsafe_destination_error, 0, CURL_ERROR_SIZE);
newrbce->native_active = 0;
if (rbce->opts != Qnil) {
newrbce->opts = rb_funcall(rbce->opts, rb_intern("dup"), 0);
}
/* Set the error buffer on the new curl handle using the new err_buf */
curl_easy_setopt(newrbce->curl, CURLOPT_ERRORBUFFER, newrbce->err_buf);
if (newrbce->opts != Qnil) {
VALUE upload = rb_hash_aref(newrbce->opts, rb_easy_hkey("upload"));
if (!NIL_P(upload)) {
rb_hash_aset(newrbce->opts, rb_easy_hkey("upload"), duplicate_upload(upload));
curl_easy_setopt(newrbce->curl, CURLOPT_READFUNCTION, (curl_read_callback)read_data_handler);
curl_easy_setopt(newrbce->curl, CURLOPT_READDATA, newrbce);
#ifdef HAVE_CURLOPT_SEEKFUNCTION
curl_easy_setopt(newrbce->curl, CURLOPT_SEEKFUNCTION, (curl_seek_callback)seek_data_handler);
#endif
#ifdef HAVE_CURLOPT_SEEKDATA
curl_easy_setopt(newrbce->curl, CURLOPT_SEEKDATA, newrbce);
#endif
}
}
VALUE clone = TypedData_Wrap_Struct(cCurlEasy, &ruby_curl_easy_data_type, newrbce);
newrbce->self = clone;
curl_easy_setopt(newrbce->curl, CURLOPT_PRIVATE, (void*)newrbce);
return clone;
}
|
#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.
1634 1635 1636 1637 1638 1639 1640 |
# File 'ext/curb_easy.c', line 1634 def close previous_multi = self.multi result = _curb_native_close __curb_clear_safety_override! previous_multi.__send__(:__unregister_idle_easy_reference, self) if previous_multi result end |
#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.
4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 |
# File 'ext/curb_easy.c', line 4859
static VALUE ruby_curl_easy_response_code_get(VALUE self) {
ruby_curl_easy *rbce;
long code;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, 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);
}
|
#connect_time ⇒ Float
Retrieve the time, in seconds, it took from the start until the connect to the remote host (or proxy) was completed.
4987 4988 4989 4990 4991 4992 4993 4994 4995 |
# File 'ext/curb_easy.c', line 4987
static VALUE ruby_curl_easy_connect_time_get(VALUE self) {
ruby_curl_easy *rbce;
double time;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, 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.
2763 2764 2765 |
# File 'ext/curb_easy.c', line 2763 static VALUE ruby_curl_easy_connect_timeout_get(VALUE self) { 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).
2752 2753 2754 |
# File 'ext/curb_easy.c', line 2752
static VALUE ruby_curl_easy_connect_timeout_set(VALUE self, VALUE connect_timeout) {
CURB_IMMED_SETTER(ruby_curl_easy, connect_timeout, 0);
}
|
#connect_timeout_ms ⇒ Fixnum?
Obtain the maximum time in milliseconds that you allow the connection to the server to take.
2789 2790 2791 |
# File 'ext/curb_easy.c', line 2789 static VALUE ruby_curl_easy_connect_timeout_ms_get(VALUE self) { CURB_IMMED_GETTER(ruby_curl_easy, connect_timeout_ms, 0); } |
#connect_timeout_ms=(fixnum) ⇒ Fixnum?
Set the maximum time in milliseconds 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).
2778 2779 2780 |
# File 'ext/curb_easy.c', line 2778
static VALUE ruby_curl_easy_connect_timeout_ms_set(VALUE self, VALUE connect_timeout_ms) {
CURB_IMMED_SETTER(ruby_curl_easy, connect_timeout_ms, 0);
}
|
#connect_to ⇒ Array?
2309 2310 2311 |
# File 'ext/curb_easy.c', line 2309 static VALUE ruby_curl_easy_connect_to_get(VALUE self) { CURB_OBJECT_HGETTER(ruby_curl_easy, connect_to); } |
#connect_to=(connect_to) ⇒ Object
Set the connect-to list to redirect matching request host/port pairs to alternate connection host/port pairs.
2301 2302 2303 |
# File 'ext/curb_easy.c', line 2301
static VALUE ruby_curl_easy_connect_to_set(VALUE self, VALUE connect_to) {
CURB_OBJECT_HSETTER(ruby_curl_easy, connect_to);
}
|
#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.
5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 |
# File 'ext/curb_easy.c', line 5337
static VALUE ruby_curl_easy_content_type_get(VALUE self) {
ruby_curl_easy *rbce;
char* type;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, 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 path for this Curl::Easy instance (used to load cookies when the cookie engine is enabled).
1879 1880 1881 |
# File 'ext/curb_easy.c', line 1879 static VALUE (VALUE self) { CURB_OBJECT_HGETTER(ruby_curl_easy, ); } |
#cookiefile=(value) ⇒ Object
call-seq:
easy. = 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.
Note: assigning nil has no effect; pass a path string to use a cookie file.
500 501 502 |
# File 'lib/curl/easy.rb', line 500 def (value) set :cookiefile, value end |
#cookiejar ⇒ String
Obtain the cookiejar path for this Curl::Easy instance (used to persist cookies when the cookie engine is enabled).
1890 1891 1892 |
# File 'ext/curb_easy.c', line 1890 static VALUE (VALUE self) { CURB_OBJECT_HGETTER(ruby_curl_easy, ); } |
#cookiejar=(value) ⇒ Object
call-seq:
easy. = 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.
Note: assigning nil has no effect; pass a path string to persist cookies to a file.
516 517 518 |
# File 'lib/curl/easy.rb', line 516 def (value) set :cookiejar, value end |
#cookielist ⇒ Array<String>, ...
requires libcurl 7.14.1 or higher, otherwise -1 is always returned
Retrieves the cookies curl knows in an array of strings. Returned strings are in Netscape cookiejar format or in Set-Cookie format. Since 7.43.0 cookies in the Set-Cookie format without a domain name are not exported.
To modify the cookie engine (add/replace/remove), use easy.cookielist= string or easy.set(:cookielist, string) with one of the following accepted inputs:
-
A Set-Cookie style header string: “Set-Cookie: name=value; Domain=example.com; Path=/; Expires=…”
-
One or more lines in Netscape cookie file format (tab-separated fields)
-
Special commands: “ALL” (clear all), “SESS” (remove session cookies), “FLUSH” (write to jar), “RELOAD” (reload from file)
5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 5455 5456 5457 5458 5459 5460 5461 5462 5463 5464 |
# File 'ext/curb_easy.c', line 5443
static VALUE ruby_curl_easy_cookielist_get(VALUE self) {
#ifdef HAVE_CURLINFO_COOKIELIST
ruby_curl_easy *rbce;
struct curl_slist *cookies;
struct curl_slist *cookie;
VALUE rb_cookies;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, rbce);
curl_easy_getinfo(rbce->curl, CURLINFO_COOKIELIST, &cookies);
if (!cookies)
return Qnil;
rb_cookies = rb_ary_new();
for (cookie = cookies; cookie; cookie = cookie->next)
rb_ary_push(rb_cookies, rb_str_new2(cookie->data));
curl_slist_free_all(cookies);
return rb_cookies;
#else
rb_warn("Installed libcurl is too old to support cookielist");
return INT2FIX(-1);
#endif
}
|
#cookielist=(value) ⇒ Object
call-seq:
easy. = string => string
Modify cookies in libcurl’s internal cookie engine (CURLOPT_COOKIELIST). Accepts a Set-Cookie style string, one or more lines in Netscape cookie file format, or one of the special commands: “ALL” (clear), “SESS” (remove session cookies), “FLUSH” (write to jar), “RELOAD” (reload from file).
Examples:
easy. = "Set-Cookie: session=42; Domain=example.com; Path=/;"
easy. = [
['.example.com', 'TRUE', '/', 'FALSE', 0, 'c1', 'v1'].join("\t"),
['.example.com', 'TRUE', '/', 'FALSE', 0, 'c2', 'v2'].join("\t"),
''
].join("\n")
easy. = 'ALL' # clear all cookies in the engine
538 539 540 |
# File 'lib/curl/easy.rb', line 538 def (value) set :cookielist, value end |
#cookies ⇒ Object
Obtain the manually set Cookie header string for this Curl::Easy instance.
Notes:
-
This corresponds to libcurl’s CURLOPT_COOKIE and only affects the outgoing Cookie request header. It does NOT modify the internal libcurl cookie engine that stores cookies received via Set-Cookie.
-
To inspect or modify cookies stored in the cookie engine, use
easy.cookielist(getter) andeasy.cookielist=or easy.set(:cookielist, …) (setter). -
To clear a previously set manual Cookie header, assign an empty string. Assigning
nilcurrently has no effect.
1868 1869 1870 |
# File 'ext/curb_easy.c', line 1868 static VALUE (VALUE self) { CURB_OBJECT_HGETTER(ruby_curl_easy, ); } |
#cookies=(value) ⇒ Object
call-seq:
easy. = "name1=content1; name2=content2;" => string
Set the manual Cookie request header for 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;”.
Notes:
-
This only affects the outgoing Cookie header (libcurl CURLOPT_COOKIE) and does NOT alter the internal libcurl cookie engine (which stores cookies from Set-Cookie).
-
To change cookies stored in the engine, use #cookielist / #cookielist= or #set with :cookielist.
-
To clear a previously set manual Cookie header, assign an empty string (”). Assigning
nilhas no effect in current curb versions.
485 486 487 |
# File 'lib/curl/easy.rb', line 485 def (value) set :cookie, value end |
#delete ⇒ Object
call-seq:
easy.http_delete
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.
606 607 608 |
# File 'lib/curl/easy.rb', line 606 def http_delete self.http :DELETE end |
#delete=(onoff) ⇒ Object
336 337 338 339 |
# File 'lib/curl/easy.rb', line 336 def delete=(onoff) set :customrequest, onoff ? 'DELETE' : nil onoff end |
#dns_cache_timeout ⇒ Fixnum?
Obtain the dns cache timeout in seconds.
2812 2813 2814 |
# File 'ext/curb_easy.c', line 2812 static VALUE ruby_curl_easy_dns_cache_timeout_get(VALUE self) { 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.
2802 2803 2804 |
# File 'ext/curb_easy.c', line 2802
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);
}
|
#dns_servers ⇒ String?
2336 2337 2338 |
# File 'ext/curb_easy.c', line 2336 static VALUE ruby_curl_easy_dns_servers_get(VALUE self) { CURB_OBJECT_HGETTER(ruby_curl_easy, dns_servers); } |
#doh_url ⇒ String?
2327 2328 2329 |
# File 'ext/curb_easy.c', line 2327 static VALUE ruby_curl_easy_doh_url_get(VALUE self) { CURB_OBJECT_HGETTER(ruby_curl_easy, doh_url); } |
#doh_url=(doh_url) ⇒ Object
Set the DNS-over-HTTPS URL to use for resolving hostnames.
2319 2320 2321 |
# File 'ext/curb_easy.c', line 2319
static VALUE ruby_curl_easy_doh_url_set(VALUE self, VALUE doh_url) {
CURB_OBJECT_HSETTER(ruby_curl_easy, doh_url);
}
|
#download_speed ⇒ Float
Retrieve the average download speed that curl measured for the preceeding complete download.
5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 |
# File 'ext/curb_easy.c', line 5210
static VALUE ruby_curl_easy_download_speed_get(VALUE self) {
ruby_curl_easy *rbce;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, rbce);
#ifdef HAVE_CURLINFO_SPEED_DOWNLOAD_T
curl_off_t bytes;
curl_easy_getinfo(rbce->curl, CURLINFO_SPEED_DOWNLOAD_T, &bytes);
return LL2NUM(bytes);
#else
double bytes;
curl_easy_getinfo(rbce->curl, CURLINFO_SPEED_DOWNLOAD, &bytes);
return rb_float_new(bytes);
#endif
}
|
#downloaded_bytes ⇒ Float
Retrieve the total amount of bytes that were downloaded in the preceeding transfer.
5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 |
# File 'ext/curb_easy.c', line 5166
static VALUE ruby_curl_easy_downloaded_bytes_get(VALUE self) {
ruby_curl_easy *rbce;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, rbce);
#ifdef HAVE_CURLINFO_SIZE_DOWNLOAD_T
curl_off_t bytes;
curl_easy_getinfo(rbce->curl, CURLINFO_SIZE_DOWNLOAD_T, &bytes);
return LL2NUM(bytes);
#else
double bytes;
curl_easy_getinfo(rbce->curl, CURLINFO_SIZE_DOWNLOAD, &bytes);
return rb_float_new(bytes);
#endif
}
|
#downloaded_content_length ⇒ Float
Retrieve the content-length of the download. This is the value read from the Content-Length: field.
5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 |
# File 'ext/curb_easy.c', line 5292
static VALUE ruby_curl_easy_downloaded_content_length_get(VALUE self) {
ruby_curl_easy *rbce;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, rbce);
#ifdef HAVE_CURLINFO_CONTENT_LENGTH_DOWNLOAD_T
curl_off_t bytes;
curl_easy_getinfo(rbce->curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD_T, &bytes);
return LL2NUM(bytes);
#else
double bytes;
curl_easy_getinfo(rbce->curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &bytes);
return rb_float_new(bytes);
#endif
}
|
#enable_cookies=(boolean) ⇒ Boolean
Configure whether the libcurl cookie engine is enabled for this Curl::Easy instance. When enabled, cookies received via Set-Cookie are stored by libcurl and automatically sent on subsequent matching requests. Use easy.cookiefile to load cookies and easy.cookiejar to persist them.
This setting is independent from the manual Cookie header set via easy.cookies. The manual header is additive and can be cleared by assigning an empty string.
3318 3319 3320 3321 |
# File 'ext/curb_easy.c', line 3318
static VALUE ruby_curl_easy_enable_cookies_set(VALUE self, VALUE enable_cookies)
{
CURB_BOOLEAN_SETTER(ruby_curl_easy, enable_cookies);
}
|
#enable_cookies? ⇒ Boolean
Determine whether the libcurl cookie engine is enabled for this Curl::Easy instance.
3330 3331 3332 |
# File 'ext/curb_easy.c', line 3330 static VALUE (VALUE self) { CURB_BOOLEAN_GETTER(ruby_curl_easy, ); } |
#encoding ⇒ String
Get the set encoding types
2009 2010 2011 |
# File 'ext/curb_easy.c', line 2009 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
1999 2000 2001 |
# File 'ext/curb_easy.c', line 1999
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).
6005 6006 6007 6008 6009 6010 6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 |
# File 'ext/curb_easy.c', line 6005
static VALUE ruby_curl_easy_escape(VALUE self, VALUE svalue) {
ruby_curl_easy *rbce;
char *result;
VALUE rresult;
VALUE str = svalue;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, 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), (int)RSTRING_LEN(str));
#else
result = (char*)curl_escape(StringValuePtr(str), (int)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.
3085 3086 3087 |
# File 'ext/curb_easy.c', line 3085
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.
3096 3097 3098 |
# File 'ext/curb_easy.c', line 3096 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.
4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 |
# File 'ext/curb_easy.c', line 4931
static VALUE ruby_curl_easy_file_time_get(VALUE self) {
#ifdef HAVE_CURLINFO_FILETIME
ruby_curl_easy *rbce;
long time;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, 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 LONG2NUM(0);
#endif
}
|
#follow_location=(onoff) ⇒ Object
call-seq:
easy.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.
561 562 563 |
# File 'lib/curl/easy.rb', line 561 def follow_location=(onoff) set :followlocation, onoff end |
#follow_location? ⇒ Boolean
Determine whether this Curl instance will follow Location: headers in HTTP responses.
3229 3230 3231 |
# File 'ext/curb_easy.c', line 3229 static VALUE ruby_curl_easy_follow_location_q(VALUE self) { CURB_BOOLEAN_GETTER(ruby_curl_easy, follow_location); } |
#ftp_commands ⇒ Array?
2271 2272 2273 |
# File 'ext/curb_easy.c', line 2271 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.
NOTE:
-
This maps to libcurl CURLOPT_QUOTE; it sends commands on the control connection.
-
Do not include data-transfer commands like LIST/NLST/RETR/STOR here. libcurl does not parse PASV/EPSV replies from QUOTE commands and will not establish the required data connection. For directory listings, set CURLOPT_DIRLISTONLY (via ‘easy.set(:dirlistonly, true)`) and request an FTP directory URL (e.g. “host/path/”) so libcurl manages PASV/EPSV and the data connection for you.
2263 2264 2265 |
# File 'ext/curb_easy.c', line 2263
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).
5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 |
# File 'ext/curb_easy.c', line 5485
static VALUE ruby_curl_easy_ftp_entry_path_get(VALUE self) {
#ifdef HAVE_CURLINFO_FTP_ENTRY_PATH
ruby_curl_easy *rbce;
char* path = NULL;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, 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 ftp_entry_path");
return Qnil;
#endif
}
|
#ftp_filemethod ⇒ Fixnum
Get the configuration for how libcurl will reach files on the server.
3052 3053 3054 |
# File 'ext/curb_easy.c', line 3052 static VALUE ruby_curl_easy_ftp_filemethod_get(VALUE self) { 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).
3042 3043 3044 |
# File 'ext/curb_easy.c', line 3042
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.
2839 2840 2841 |
# File 'ext/curb_easy.c', line 2839 static VALUE ruby_curl_easy_ftp_response_timeout_get(VALUE self) { 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.
2829 2830 2831 |
# File 'ext/curb_easy.c', line 2829
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);
}
|
#get ⇒ Object
call-seq:
easy.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.
593 594 595 596 |
# File 'lib/curl/easy.rb', line 593 def http_get set :httpget, true http :GET end |
#getinfo(opt) ⇒ nil
This method is not implemented yet.
Iniital access to libcurl curl_easy_getinfo, remember getinfo doesn’t return the same values as setopt
5968 5969 5970 |
# File 'ext/curb_easy.c', line 5968
static VALUE ruby_curl_easy_get_opt(VALUE self, VALUE opt) {
return Qnil;
}
|
#head=(onoff) ⇒ Object
549 550 551 |
# File 'lib/curl/easy.rb', line 549 def head=(onoff) set :nobody, onoff end |
#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).
3165 3166 3167 |
# File 'ext/curb_easy.c', line 3165
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 return HTTP headers combined with body data.
3176 3177 3178 |
# File 'ext/curb_easy.c', line 3176 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.
5232 5233 5234 5235 5236 5237 5238 5239 5240 |
# File 'ext/curb_easy.c', line 5232
static VALUE ruby_curl_easy_header_size_get(VALUE self) {
ruby_curl_easy *rbce;
long size;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, rbce);
curl_easy_getinfo(rbce->curl, CURLINFO_HEADER_SIZE, &size);
return LONG2NUM(size);
}
|
#header_str ⇒ Object Also known as: head
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.
4821 4822 4823 |
# File 'ext/curb_easy.c', line 4821 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.
1775 1776 1777 1778 1779 1780 1781 1782 |
# File 'ext/curb_easy.c', line 1775
static VALUE ruby_curl_easy_headers_get(VALUE self) {
ruby_curl_easy *rbce;
VALUE headers;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, 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.
1761 1762 1763 |
# File 'ext/curb_easy.c', line 1761
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.
4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 |
# File 'ext/curb_easy.c', line 4476
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, StringValueCStr(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, StringValueCStr(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.
2604 2605 2606 |
# File 'ext/curb_easy.c', line 2604 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) {
2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 |
# File 'ext/curb_easy.c', line 2563
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;
long i, len;
char* node = NULL;
long mask = 0;
rb_scan_args(argc, argv, "*", &args_ary);
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, rbce);
len = RARRAY_LEN(args_ary);
if (len == 1 && (rb_ary_entry(args_ary,0) == Qnil || TYPE(rb_ary_entry(args_ary,0)) == T_FIXNUM ||
TYPE(rb_ary_entry(args_ary,0)) == T_BIGNUM)) {
if (rb_ary_entry(args_ary,0) == Qnil) {
rbce->http_auth_types = 0;
}
else {
rbce->http_auth_types = NUM2LONG(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 LONG2NUM(rbce->http_auth_types);
}
|
#http_connect_code ⇒ Fixnum
Retrieve the last received proxy response code to a CONNECT request.
4904 4905 4906 4907 4908 4909 4910 4911 4912 |
# File 'ext/curb_easy.c', line 4904
static VALUE ruby_curl_easy_http_connect_code_get(VALUE self) {
ruby_curl_easy *rbce;
long code;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, rbce);
curl_easy_getinfo(rbce->curl, CURLINFO_HTTP_CONNECTCODE, &code);
return LONG2NUM(code);
}
|
#http_delete ⇒ Object
call-seq:
easy.http_delete
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.
603 604 605 |
# File 'lib/curl/easy.rb', line 603 def http_delete self.http :DELETE end |
#http_get ⇒ Object
call-seq:
easy.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.
589 590 591 592 |
# File 'lib/curl/easy.rb', line 589 def http_get set :httpget, true http :GET end |
#http_head ⇒ Object
call-seq:
easy.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.
574 575 576 577 578 579 |
# File 'lib/curl/easy.rb', line 574 def http_head set :nobody, true ret = self.perform set :nobody, false ret end |
#http_patch("url = encoded%20form%20data;and=so%20on") ⇒ true #http_patch("url = encoded%20form%20data", "and = so%20on", ...) ⇒ true #http_patch("url = encoded%20form%20data", Curl: :PostField, "and = so%20on", ...) ⇒ true #http_patch(Curl: :PostField, Curl: :PostField..., Curl: :PostField) ⇒ true
PATCH 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.
When multipart_form_post is true the multipart logic is used; otherwise, the arguments are joined into a raw PATCH body.
4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 |
# File 'ext/curb_easy.c', line 4661
static VALUE ruby_curl_easy_perform_patch(int argc, VALUE *argv, VALUE self) {
ruby_curl_easy *rbce;
CURL *curl;
VALUE args_ary;
rb_scan_args(argc, argv, "*", &args_ary);
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, rbce);
curl = rbce->curl;
/* Clear the error buffer */
memset(rbce->err_buf, 0, CURL_ERROR_SIZE);
/* Set the custom HTTP method to PATCH */
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "PATCH");
if (rbce->multipart_form_post) {
VALUE ret;
struct easy_form_perform_args perform_args = { self, curl, argc, argv, NULL, NULL, 1, 0 };
ret = rb_ensure(build_and_perform_multipart_form, (VALUE)&perform_args, ensure_free_form_post, (VALUE)&perform_args);
return ret;
} else {
/* Join arguments into a raw PATCH body */
VALUE patch_body = join_easy_arguments(rbce, args_ary);
if (patch_body == Qnil) {
rb_raise(eCurlErrError, "Failed to join arguments");
return Qnil;
} else {
if (rb_type(patch_body) == T_STRING && RSTRING_LEN(patch_body) > 0) {
ruby_curl_easy_post_body_set(self, patch_body);
}
/* If postdata_buffer is still nil, set it so that the PATCH header is enabled */
if (rb_easy_nil("postdata_buffer")) {
ruby_curl_easy_post_body_set(self, patch_body);
}
struct easy_perform_request_restore_args restore_args = { self, curl, rbce, 1, 0, 1 };
return rb_ensure(perform_with_request_restore_body, (VALUE)&restore_args,
perform_with_request_restore_ensure, (VALUE)&restore_args);
}
}
}
|
#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.
4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 |
# File 'ext/curb_easy.c', line 4601
static VALUE ruby_curl_easy_perform_post(int argc, VALUE *argv, VALUE self) {
ruby_curl_easy *rbce;
CURL *curl;
VALUE args_ary;
rb_scan_args(argc, argv, "*", &args_ary);
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, rbce);
curl = rbce->curl;
memset(rbce->err_buf, 0, CURL_ERROR_SIZE);
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, NULL);
if (rbce->multipart_form_post) {
VALUE ret;
struct easy_form_perform_args perform_args = { self, curl, argc, argv, NULL, NULL, 0, 0 };
ret = rb_ensure(build_and_perform_multipart_form, (VALUE)&perform_args, ensure_free_form_post, (VALUE)&perform_args);
return ret;
} else {
VALUE post_body = Qnil;
/* TODO: check for PostField.file and raise error before to_s fails */
if ((post_body = join_easy_arguments(rbce, args_ary)) == 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);
}
struct easy_perform_request_restore_args restore_args = { self, curl, rbce, 1, 0, 0 };
return rb_ensure(perform_with_request_restore_body, (VALUE)&restore_args,
perform_with_request_restore_ensure, (VALUE)&restore_args);
}
}
}
|
#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.
4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 |
# File 'ext/curb_easy.c', line 4710
static VALUE ruby_curl_easy_perform_put(int argc, VALUE *argv, VALUE self) {
ruby_curl_easy *rbce;
CURL *curl;
VALUE args_ary;
rb_scan_args(argc, argv, "*", &args_ary);
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, rbce);
curl = rbce->curl;
memset(rbce->err_buf, 0, CURL_ERROR_SIZE);
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "PUT");
/* New: if no arguments were provided, treat as an empty PUT */
if (RARRAY_LEN(args_ary) == 0) {
/* Option 1: explicitly set an empty body */
ruby_curl_easy_put_data_set(self, rb_str_new2(""));
}
/* If a single argument is given and it is a String or responds to read, use legacy behavior */
else if (RARRAY_LEN(args_ary) == 1 &&
(rb_type(rb_ary_entry(args_ary, 0)) == T_STRING ||
rb_respond_to(rb_ary_entry(args_ary, 0), rb_intern("read")))) {
ruby_curl_easy_put_data_set(self, rb_ary_entry(args_ary, 0));
}
/* Otherwise, if multipart_form_post is true, use multipart logic */
else if (rbce->multipart_form_post) {
VALUE ret;
struct easy_form_perform_args perform_args = { self, curl, argc, argv, NULL, NULL, 1, 0 };
ret = rb_ensure(build_and_perform_multipart_form, (VALUE)&perform_args, ensure_free_form_post, (VALUE)&perform_args);
return ret;
}
/* Fallback: join all arguments */
else {
VALUE post_body = join_easy_arguments(rbce, args_ary);
if (post_body != Qnil && rb_type(post_body) == T_STRING &&
RSTRING_LEN(post_body) > 0) {
ruby_curl_easy_put_data_set(self, post_body);
}
}
struct easy_perform_request_restore_args restore_args = { self, curl, rbce, 1, 0, 0 };
return rb_ensure(perform_with_request_restore_body, (VALUE)&restore_args,
perform_with_request_restore_ensure, (VALUE)&restore_args);
}
|
#http_version ⇒ Integer
Returns the HTTP protocol version currently configured.
3546 3547 3548 3549 3550 3551 3552 |
# File 'ext/curb_easy.c', line 3546
static VALUE ruby_curl_easy_http_version_get(VALUE self) {
ruby_curl_easy *rbce;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, rbce);
return LONG2NUM(rbce->http_version);
}
|
#http_version=(Curl) ⇒ Curl::HTTP_1_1
Force libcurl to use a specific HTTP protocol version. By default libcurl negotiates the highest version supported by both peers. Supported constants include Curl::HTTP_NONE, Curl::HTTP_1_0, Curl::HTTP_1_1, Curl::HTTP_2_0, Curl::HTTP_2TLS, and Curl::HTTP_2_PRIOR_KNOWLEDGE (when provided by libcurl).
3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 |
# File 'ext/curb_easy.c', line 3523
static VALUE ruby_curl_easy_http_version_set(VALUE self, VALUE version) {
ruby_curl_easy *rbce;
long http_version;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, rbce);
if (NIL_P(version)) {
http_version = CURL_HTTP_VERSION_NONE;
} else {
http_version = NUM2LONG(version);
}
rbce->http_version = http_version;
return version;
}
|
#ignore_content_length=(boolean) ⇒ Object
Configure whether this Curl::Easy instance should ignore the content length header.
3341 3342 3343 3344 |
# File 'ext/curb_easy.c', line 3341
static VALUE ruby_curl_easy_ignore_content_length_set(VALUE self, VALUE ignore_content_length)
{
CURB_BOOLEAN_SETTER(ruby_curl_easy, ignore_content_length);
}
|
#ignore_content_length? ⇒ Boolean
Determine whether this Curl::Easy instance ignores the content length header.
3353 3354 3355 |
# File 'ext/curb_easy.c', line 3353 static VALUE ruby_curl_easy_ignore_content_length_q(VALUE self) { CURB_BOOLEAN_GETTER(ruby_curl_easy, ignore_content_length); } |
#inspect ⇒ "#<Curl::Easy http://google.com/>"
5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989 5990 5991 |
# File 'ext/curb_easy.c', line 5976
static VALUE ruby_curl_easy_inspect(VALUE self) {
char buf[64];
ruby_curl_easy *rbce;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, 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,StringValueCStr(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.
1826 1827 1828 |
# File 'ext/curb_easy.c', line 1826 static VALUE ruby_curl_easy_interface_get(VALUE self) { CURB_OBJECT_HGETTER(ruby_curl_easy, interface_hm); } |
#interface=(value) ⇒ Object
call-seq:
easy.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.
441 442 443 |
# File 'lib/curl/easy.rb', line 441 def interface=(value) set :interface, value end |
#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.
4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 |
# File 'ext/curb_easy.c', line 4836
static VALUE ruby_curl_easy_last_effective_url_get(VALUE self) {
ruby_curl_easy *rbce;
char* url;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, 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;
}
}
|
#last_error ⇒ "Error details"?
5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 |
# File 'ext/curb_easy.c', line 5560
static VALUE ruby_curl_easy_last_error(VALUE self) {
ruby_curl_easy *rbce;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, rbce);
if (rbce->err_buf[0]) { // curl returns NULL or empty string if none
return rb_str_new2(rbce->err_buf);
} else {
return Qnil;
}
}
|
#last_result ⇒ 0
5550 5551 5552 5553 5554 |
# File 'ext/curb_easy.c', line 5550
static VALUE ruby_curl_easy_last_result(VALUE self) {
ruby_curl_easy *rbce;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, rbce);
return LONG2NUM(rbce->last_result);
}
|
#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.
2460 2461 2462 |
# File 'ext/curb_easy.c', line 2460 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.
2448 2449 2450 |
# File 'ext/curb_easy.c', line 2448
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.
2491 2492 2493 |
# File 'ext/curb_easy.c', line 2491 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.
2478 2479 2480 |
# File 'ext/curb_easy.c', line 2478
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");
}
|
#low_speed_limit ⇒ Fixnum?
Obtain the minimum transfer speed over low_speedtime+ below which the transfer will be aborted.
2862 2863 2864 |
# File 'ext/curb_easy.c', line 2862 static VALUE ruby_curl_easy_low_speed_limit_get(VALUE self) { CURB_IMMED_GETTER(ruby_curl_easy, low_speed_limit, 0); } |
#low_speed_limit=(fixnum) ⇒ Fixnum?
Set the transfer speed (in bytes per second) that the transfer should be below during low_speed_time seconds for the library to consider it too slow and abort.
2851 2852 2853 |
# File 'ext/curb_easy.c', line 2851
static VALUE ruby_curl_easy_low_speed_limit_set(VALUE self, VALUE low_speed_limit) {
CURB_IMMED_SETTER(ruby_curl_easy, low_speed_limit, 0);
}
|
#low_speed_time ⇒ Fixnum?
Obtain the time that the transfer should be below low_speed_limit for the library to abort it.
2884 2885 2886 |
# File 'ext/curb_easy.c', line 2884 static VALUE ruby_curl_easy_low_speed_time_get(VALUE self) { CURB_IMMED_GETTER(ruby_curl_easy, low_speed_time, 0); } |
#low_speed_time=(fixnum) ⇒ Fixnum?
Set the time (in seconds) that the transfer should be below the low_speed_limit for the library to consider it too slow and abort.
2873 2874 2875 |
# File 'ext/curb_easy.c', line 2873
static VALUE ruby_curl_easy_low_speed_time_set(VALUE self, VALUE low_speed_time) {
CURB_IMMED_SETTER(ruby_curl_easy, low_speed_time, 0);
}
|
#max_body_bytes ⇒ Object
4809 4810 4811 |
# File 'ext/curb_easy.c', line 4809 static VALUE ruby_curl_easy_max_body_bytes_get(VALUE self) { CURB_OBJECT_HGETTER(ruby_curl_easy, max_body_bytes); } |
#max_body_bytes=(bytes_or_nil) ⇒ Object
Set an application-level cap for bytes accepted by the body write callback. nil or 0 clears the cap.
4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 |
# File 'ext/curb_easy.c', line 4779
static VALUE ruby_curl_easy_max_body_bytes_set(VALUE self, VALUE val) {
ruby_curl_easy *rbce;
long long limit;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, rbce);
if (NIL_P(val)) {
rb_hash_delete(rbce->opts, rb_easy_hkey("max_body_bytes"));
return Qnil;
}
limit = NUM2LL(val);
if (limit < 0) {
rb_raise(rb_eArgError, "max_body_bytes must be greater than or equal to zero");
}
if (limit == 0) {
rb_hash_delete(rbce->opts, rb_easy_hkey("max_body_bytes"));
} else {
val = LL2NUM(limit);
rb_hash_aset(rbce->opts, rb_easy_hkey("max_body_bytes"), val);
}
return val;
}
|
#max_recv_speed_large=(fixnum) ⇒ Fixnum?
Get the maximal receiving transfer speed (in bytes per second)
2924 2925 2926 |
# File 'ext/curb_easy.c', line 2924 static VALUE ruby_curl_easy_max_recv_speed_large_get(VALUE self) { CURB_IMMED_GETTER(ruby_curl_easy, max_recv_speed_large, 0); } |
#max_recv_speed_large=(fixnum) ⇒ Fixnum?
Set the maximal receiving transfer speed (in bytes per second)
2914 2915 2916 |
# File 'ext/curb_easy.c', line 2914
static VALUE ruby_curl_easy_max_recv_speed_large_set(VALUE self, VALUE max_recv_speed_large) {
CURB_IMMED_SETTER(ruby_curl_easy, max_recv_speed_large, 0);
}
|
#max_redirects ⇒ Fixnum?
Obtain the maximum number of redirections to follow in the following perform calls.
2653 2654 2655 |
# File 'ext/curb_easy.c', line 2653 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.
2642 2643 2644 |
# File 'ext/curb_easy.c', line 2642
static VALUE ruby_curl_easy_max_redirects_set(VALUE self, VALUE max_redirs) {
CURB_IMMED_SETTER(ruby_curl_easy, max_redirs, -1);
}
|
#max_send_speed_large=(fixnum) ⇒ Fixnum?
Get the maximal sending transfer speed (in bytes per second)
2904 2905 2906 |
# File 'ext/curb_easy.c', line 2904 static VALUE ruby_curl_easy_max_send_speed_large_get(VALUE self) { CURB_IMMED_GETTER(ruby_curl_easy, max_send_speed_large, 0); } |
#max_send_speed_large=(fixnum) ⇒ Fixnum?
Set the maximal sending transfer speed (in bytes per second)
2894 2895 2896 |
# File 'ext/curb_easy.c', line 2894
static VALUE ruby_curl_easy_max_send_speed_large_set(VALUE self, VALUE max_send_speed_large) {
CURB_IMMED_SETTER(ruby_curl_easy, max_send_speed_large, 0);
}
|
#multi ⇒ "#<Curl::Multi>"
5508 5509 5510 5511 5512 |
# File 'ext/curb_easy.c', line 5508
static VALUE ruby_curl_easy_multi_get(VALUE self) {
ruby_curl_easy *rbce;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, rbce);
return rbce->multi;
}
|
#multi= ⇒ "#<Curl::Multi>"
5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 |
# File 'ext/curb_easy.c', line 5518 def multi=(multi) previous_multi = self.multi return multi if previous_multi.equal?(multi) if previous_multi && previous_multi.requests[self.object_id] previous_multi.remove(self) end result = _curb_native_multi_set(multi) previous_multi.__send__(:__unregister_idle_easy_reference, self) if previous_multi multi.__send__(:__register_idle_easy_reference, self) if multi result end |
#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.
3290 3291 3292 3293 |
# File 'ext/curb_easy.c', line 3290
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.
3302 3303 3304 |
# File 'ext/curb_easy.c', line 3302 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.
4970 4971 4972 4973 4974 4975 4976 4977 4978 |
# File 'ext/curb_easy.c', line 4970
static VALUE ruby_curl_easy_name_lookup_time_get(VALUE self) {
ruby_curl_easy *rbce;
double time;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, rbce);
curl_easy_getinfo(rbce->curl, CURLINFO_NAMELOOKUP_TIME, &time);
return rb_float_new(time);
}
|
#native_cert= ⇒ Object
790 |
# File 'lib/curl/easy.rb', line 790 alias_method :native_cert=, :cert= |
#network_policy ⇒ Object
Determine which native network policy will be enforced when libcurl opens sockets for this handle.
3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 |
# File 'ext/curb_easy.c', line 3426
static VALUE ruby_curl_easy_network_policy_get(VALUE self) {
ruby_curl_easy *rbce;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, rbce);
switch (rbce->network_policy) {
case CURB_NETWORK_POLICY_PUBLIC:
return ID2SYM(idNetworkPolicyPublic);
case CURB_NETWORK_POLICY_NONE:
default:
return ID2SYM(idNetworkPolicyNone);
}
}
|
#network_policy=(symbol) ⇒ Object
Supported values:
- :none
-
disables native destination checks.
- :public
-
blocks loopback, private, link-local, multicast, unspecified, metadata, and other non-public addresses.
3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 |
# File 'ext/curb_easy.c', line 3448
static VALUE ruby_curl_easy_network_policy_set(VALUE self, VALUE network_policy) {
ruby_curl_easy *rbce;
ID network_policy_id;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, rbce);
if (NIL_P(network_policy)) {
rbce->network_policy = CURB_NETWORK_POLICY_NONE;
return ID2SYM(idNetworkPolicyNone);
}
if (TYPE(network_policy) != T_SYMBOL) {
rb_raise(rb_eTypeError, "network_policy must be a Symbol");
}
network_policy_id = rb_to_id(network_policy);
if (network_policy_id == idNetworkPolicyNone) {
rbce->network_policy = CURB_NETWORK_POLICY_NONE;
rbce->allow_proxy = 0;
return network_policy;
} else if (network_policy_id == idNetworkPolicyPublic) {
#ifndef CURB_HAVE_OPENSOCKET_NETWORK_POLICY
rb_raise(rb_eNotImpError, "network_policy=:public requires CURLOPT_OPENSOCKETFUNCTION support");
#else
rbce->network_policy = CURB_NETWORK_POLICY_PUBLIC;
rbce->allow_proxy = 0;
return network_policy;
#endif
}
rb_raise(rb_eArgError, "network_policy must be one of :none, :public");
}
|
#nosignal=(onoff) ⇒ Object
easy = Curl::Easy.new easy.nosignal = true
325 326 327 |
# File 'lib/curl/easy.rb', line 325 def nosignal=(onoff) set :nosignal, !!onoff end |
#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).
5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 5421 |
# File 'ext/curb_easy.c', line 5408
static VALUE ruby_curl_easy_num_connects_get(VALUE self) {
#ifdef HAVE_CURLINFO_NUM_CONNECTS
ruby_curl_easy *rbce;
long result;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, 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 LONG2NUM(-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.
3572 3573 3574 |
# File 'ext/curb_easy.c', line 3572
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.
3646 3647 3648 |
# File 'ext/curb_easy.c', line 3646
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.
3704 3705 3706 |
# File 'ext/curb_easy.c', line 3704
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
3602 3603 3604 |
# File 'ext/curb_easy.c', line 3602
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.
3662 3663 3664 |
# File 'ext/curb_easy.c', line 3662
static VALUE ruby_curl_easy_on_header_set(int argc, VALUE *argv, VALUE self) {
CURB_HANDLER_PROC_HSETTER(ruby_curl_easy, header_proc);
}
|
#on_missing {|easy, code| ... } ⇒ Object
Assign or remove the on_missing handler for this Curl::Easy instance.
To remove a previously-supplied handler, call this method with no attached
block.
The +on_missing+ handler is called when request is finished with a
status of 40x
3617 3618 3619 |
# File 'ext/curb_easy.c', line 3617
static VALUE ruby_curl_easy_on_missing_set(int argc, VALUE *argv, VALUE self) {
CURB_HANDLER_PROC_HSETTER(ruby_curl_easy, missing_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.
3683 3684 3685 |
# File 'ext/curb_easy.c', line 3683
static VALUE ruby_curl_easy_on_progress_set(int argc, VALUE *argv, VALUE self) {
CURB_HANDLER_PROC_HSETTER(ruby_curl_easy, progress_proc);
}
|
#on_redirect {|easy, code| ... } ⇒ Object
Assign or remove the on_redirect handler for this Curl::Easy instance.
To remove a previously-supplied handler, call this method with no attached
block.
The +on_redirect+ handler is called when request is finished with a
status of 30x
3632 3633 3634 |
# File 'ext/curb_easy.c', line 3632
static VALUE ruby_curl_easy_on_redirect_set(int argc, VALUE *argv, VALUE self) {
CURB_HANDLER_PROC_HSETTER(ruby_curl_easy, redirect_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
3587 3588 3589 |
# File 'ext/curb_easy.c', line 3587
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).
5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 |
# File 'ext/curb_easy.c', line 5379
static VALUE ruby_curl_easy_os_errno_get(VALUE self) {
#ifdef HAVE_CURLINFO_OS_ERRNO
ruby_curl_easy *rbce;
long result;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, 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 LONG2NUM(0);
#endif
}
|
#password ⇒ String
Get the current password
2976 2977 2978 2979 2980 2981 2982 |
# File 'ext/curb_easy.c', line 2976 static VALUE ruby_curl_easy_password_get(VALUE self) { #ifdef HAVE_CURLOPT_PASSWORD CURB_OBJECT_HGETTER(ruby_curl_easy, password); #else return Qnil; #endif } |
#password=(string) ⇒ String
Set the HTTP Authentication password.
2962 2963 2964 2965 2966 2967 2968 |
# File 'ext/curb_easy.c', line 2962
static VALUE ruby_curl_easy_password_set(VALUE self, VALUE password) {
#ifdef HAVE_CURLOPT_PASSWORD
CURB_OBJECT_HSETTER(ruby_curl_easy, password);
#else
return Qnil;
#endif
}
|
#perform ⇒ Object
call-seq:
easy.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 configured HTTP Verb.
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 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 305 306 307 308 309 310 311 312 313 314 315 316 |
# File 'lib/curl/easy.rb', line 256 def perform Curl.__send__(:apply_safety!, self) if Curl.respond_to?(:apply_safety!, true) self.class.flush_deferred_multi_closes if Curl.scheduler_active? && self.multi.nil? ret = Curl.perform_with_scheduler(self) else multi = self.multi created_multi = multi.nil? raised = false if created_multi multi = Curl::Multi.new self.multi = multi end begin multi.add(self) ret = multi.perform multi.remove(self) if self.multi == multi rescue Exception raised = true raise ensure if created_multi if raised unless self.class.release_deferred_multi_close(multi, self) self.class.defer_multi_close(multi, self) end self.multi = nil if self.multi == multi elsif Curl::Multi.autoclose multi.__send__(:_autoclose) self.multi = nil if self.multi == multi else self.multi = multi end elsif Curl::Multi.autoclose multi.__send__(:_autoclose) self.multi = nil if self.multi == multi else self.multi = multi end end end if (callback_error = _take_callback_error) raise callback_error end if respond_to?(:unsafe_destination_error) && (unsafe_destination_error = self.unsafe_destination_error) raise Curl::Err::UnsafeDestinationError, unsafe_destination_error 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 |
#post ⇒ Object
117 |
# File 'lib/curl/easy.rb', line 117 alias post http_post |
#post_body ⇒ String?
Obtain the POST body used in this Curl::Easy instance.
2139 2140 2141 |
# File 'ext/curb_easy.c', line 2139 static VALUE ruby_curl_easy_post_body_get(VALUE self) { CURB_OBJECT_HGETTER(ruby_curl_easy, postdata_buffer); } |
#post_body=(post_body) ⇒ Object
2129 2130 2131 |
# File 'ext/curb_easy.c', line 2129
static VALUE ruby_curl_easy_post_body_set(VALUE self, VALUE post_body) {
return ruby_curl_easy_post_body_set_with_mode(self, post_body, 1);
}
|
#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.
5029 5030 5031 5032 5033 5034 5035 5036 5037 |
# File 'ext/curb_easy.c', line 5029
static VALUE ruby_curl_easy_pre_transfer_time_get(VALUE self) {
ruby_curl_easy *rbce;
double time;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, 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
4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 |
# File 'ext/curb_easy.c', line 4883
static VALUE ruby_curl_easy_primary_ip_get(VALUE self) {
ruby_curl_easy *rbce;
char* ip;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, 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.
2627 2628 2629 |
# File 'ext/curb_easy.c', line 2627 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.
2616 2617 2618 |
# File 'ext/curb_easy.c', line 2616
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_headers ⇒ Hash, ...
Obtain the custom HTTP proxy_headers for following requests.
1810 1811 1812 1813 1814 1815 1816 1817 |
# File 'ext/curb_easy.c', line 1810
static VALUE ruby_curl_easy_proxy_headers_get(VALUE self) {
ruby_curl_easy *rbce;
VALUE proxy_headers;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, rbce);
proxy_headers = rb_easy_get("proxy_headers");//rb_hash_aref(rbce->opts, rb_intern("proxy_headers"));
if (proxy_headers == Qnil) { proxy_headers = rb_easy_set("proxy_headers", rb_hash_new()); }
return proxy_headers;
}
|
#proxy_headers=(proxy_headers) ⇒ Object
1765 1766 1767 |
# File 'ext/curb_easy.c', line 1765
static VALUE ruby_curl_easy_proxy_headers_set(VALUE self, VALUE proxy_headers) {
CURB_OBJECT_HSETTER(ruby_curl_easy, proxy_headers);
}
|
#proxy_port ⇒ Fixnum?
Obtain the proxy port that will be used for the following perform calls.
2511 2512 2513 |
# File 'ext/curb_easy.c', line 2511 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.
2501 2502 2503 |
# File 'ext/curb_easy.c', line 2501
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.
3064 3065 3066 |
# File 'ext/curb_easy.c', line 3064
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.
3074 3075 3076 |
# File 'ext/curb_easy.c', line 3074 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.
2532 2533 2534 |
# File 'ext/curb_easy.c', line 2532 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.
2522 2523 2524 |
# File 'ext/curb_easy.c', line 2522
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.
1735 1736 1737 |
# File 'ext/curb_easy.c', line 1735 static VALUE ruby_curl_easy_proxy_url_get(VALUE self) { CURB_OBJECT_HGETTER(ruby_curl_easy, proxy_url); } |
#proxy_url=(url) ⇒ Object
call-seq:
easy.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.
394 395 396 |
# File 'lib/curl/easy.rb', line 394 def proxy_url=(url) set :proxy, url end |
#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”
1849 1850 1851 |
# File 'ext/curb_easy.c', line 1849 static VALUE ruby_curl_easy_proxypwd_get(VALUE self) { CURB_OBJECT_HGETTER(ruby_curl_easy, proxypwd); } |
#proxypwd=(value) ⇒ Object
call-seq:
easy.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”
464 465 466 |
# File 'lib/curl/easy.rb', line 464 def proxypwd=(value) set :proxyuserpwd, value end |
#put ⇒ Object
118 |
# File 'lib/curl/easy.rb', line 118 alias put http_put |
#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.
2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 |
# File 'ext/curb_easy.c', line 2151
static VALUE ruby_curl_easy_put_data_set(VALUE self, VALUE data) {
ruby_curl_easy *rbce;
CURL *curl;
VALUE upload;
VALUE upload_stream = data;
VALUE headers;
VALUE infile_size = Qnil;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, rbce);
/*
* Validate and prepare Ruby-visible state before mutating the CURL handle.
* Several branches below can raise (header type, stat, size, to_s).
*/
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");
}
}
if (!NIL_P(data) && !rb_respond_to(data, rb_intern("read"))) {
if (rb_respond_to(data, rb_intern("to_s"))) {
upload_stream = rb_obj_as_string(data);
} else {
rb_raise(rb_eRuntimeError, "PUT data must respond to read or to_s");
}
}
headers = rb_easy_get("headers");
if( headers == Qnil ) {
headers = rb_hash_new();
}
if (!NIL_P(data) && rb_respond_to(data, rb_intern("read"))) {
VALUE stat = Qnil;
if (rb_respond_to(data, rb_intern("stat"))) {
stat = rb_funcall(data, rb_intern("stat"), 0);
}
if(!NIL_P(stat) && stat != Qfalse && rb_hash_aref(headers, rb_str_new2("Content-Length")) == Qnil) {
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);
infile_size = size;
}
else if( rb_hash_aref(headers, rb_str_new2("Content-Length")) == Qnil && 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_hash_aref(headers, rb_str_new2("Content-Length")) ) {
VALUE size = rb_funcall(rb_hash_aref(headers, rb_str_new2("Content-Length")), rb_intern("to_i"), 0);
infile_size = size;
}
}
else if (!NIL_P(data) && rb_respond_to(data, rb_intern("to_s"))) {
infile_size = LONG2NUM(RSTRING_LEN(upload_stream));
if( rb_hash_aref(headers, rb_str_new2("Expect")) == Qnil ) {
rb_hash_aset(headers, rb_str_new2("Expect"), rb_str_new2(""));
}
}
else if (NIL_P(data)) {
/* Preserve legacy nil handling: configure an upload with no payload. */
}
else {
rb_raise(rb_eRuntimeError, "PUT data must respond to read or to_s");
}
rb_easy_set("headers",headers);
upload = ruby_curl_upload_new(cCurlUpload);
ruby_curl_upload_stream_set(upload, upload_stream);
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_POST, 0);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, NULL);
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, 0);
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1);
curl_easy_setopt(curl, CURLOPT_READFUNCTION, (curl_read_callback)read_data_handler);
#ifdef HAVE_CURLOPT_SEEKFUNCTION
curl_easy_setopt(curl, CURLOPT_SEEKFUNCTION, (curl_seek_callback)seek_data_handler);
#endif
curl_easy_setopt(curl, CURLOPT_READDATA, rbce);
#ifdef HAVE_CURLOPT_SEEKDATA
curl_easy_setopt(curl, CURLOPT_SEEKDATA, rbce);
#endif
if (!NIL_P(infile_size)) {
curl_easy_setopt(curl, CURLOPT_INFILESIZE, NUM2LONG(infile_size));
}
// 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.
5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 |
# File 'ext/curb_easy.c', line 5091
static VALUE ruby_curl_easy_redirect_count_get(VALUE self) {
#ifdef HAVE_CURLINFO_REDIRECT_COUNT
ruby_curl_easy *rbce;
long count;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, 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 LONG2NUM(-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.
5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 |
# File 'ext/curb_easy.c', line 5068
static VALUE ruby_curl_easy_redirect_time_get(VALUE self) {
#ifdef HAVE_CURLINFO_REDIRECT_TIME
ruby_curl_easy *rbce;
double time;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, 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
}
|
#redirect_url ⇒ nil
Retrieve the URL a redirect would take you to if you would enable CURLOPT_FOLLOWLOCATION.
Requires libcurl 7.18.2 or higher, otherwise -1 is always returned.
5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 |
# File 'ext/curb_easy.c', line 5116
static VALUE ruby_curl_easy_redirect_url_get(VALUE self) {
#ifdef HAVE_CURLINFO_REDIRECT_URL
ruby_curl_easy *rbce;
char* url;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, rbce);
curl_easy_getinfo(rbce->curl, CURLINFO_REDIRECT_URL, &url);
if (url && url[0]) { // curl returns empty string if none
return rb_str_new2(url);
} else {
return Qnil;
}
#else
rb_warn("Installed libcurl is too old to support redirect_url");
return LONG2NUM(-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.
5250 5251 5252 5253 5254 5255 5256 5257 5258 |
# File 'ext/curb_easy.c', line 5250
static VALUE ruby_curl_easy_request_size_get(VALUE self) {
ruby_curl_easy *rbce;
long size;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, rbce);
curl_easy_getinfo(rbce->curl, CURLINFO_REQUEST_SIZE, &size);
return LONG2NUM(size);
}
|
#request_target=(value) ⇒ Object
call-seq:
easy.request_target = string => string
Set the request-target used in the HTTP request line (libcurl CURLOPT_REQUEST_TARGET). Useful for absolute-form request targets (e.g., when speaking to proxies) or special targets like “*” (OPTIONS *). Requires libcurl with CURLOPT_REQUEST_TARGET support.
406 407 408 409 410 411 412 |
# File 'lib/curl/easy.rb', line 406 def request_target=(value) if Curl.const_defined?(:CURLOPT_REQUEST_TARGET) set :request_target, value else raise NotImplementedError, "CURLOPT_REQUEST_TARGET is not supported by this libcurl" end end |
#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.
1684 1685 1686 1687 1688 |
# File 'ext/curb_easy.c', line 1684 def reset result = _curb_native_reset __curb_clear_safety_override! result end |
#resolve ⇒ Array?
2290 2291 2292 |
# File 'ext/curb_easy.c', line 2290 static VALUE ruby_curl_easy_resolve_get(VALUE self) { CURB_OBJECT_HGETTER(ruby_curl_easy, resolve); } |
#resolve=(resolve) ⇒ Object
Set the resolve list to statically resolve hostnames to IP addresses, bypassing DNS for matching hostname/port combinations.
2282 2283 2284 |
# File 'ext/curb_easy.c', line 2282
static VALUE ruby_curl_easy_resolve_set(VALUE self, VALUE resolve) {
CURB_OBJECT_HSETTER(ruby_curl_easy, resolve);
}
|
#resolve_mode ⇒ Object
Determines what type of IP address this Curl::Easy instance resolves DNS names to.
3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 |
# File 'ext/curb_easy.c', line 3364
static VALUE ruby_curl_easy_resolve_mode(VALUE self) {
ruby_curl_easy *rbce;
unsigned short rm;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, rbce);
rm = rbce->resolve_mode;
switch(rm) {
case CURL_IPRESOLVE_V4:
return rb_easy_sym("ipv4");
case CURL_IPRESOLVE_V6:
return rb_easy_sym("ipv6");
default:
return rb_easy_sym("auto");
}
}
|
#resolve_mode=(symbol) ⇒ Object
Configures what type of IP address this Curl::Easy instance resolves DNS names to. Valid options are:
- :auto
-
resolves DNS names to all IP versions your system allows
- :ipv4
-
resolves DNS names to IPv4 only
- :ipv6
-
resolves DNS names to IPv6 only
3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 |
# File 'ext/curb_easy.c', line 3392
static VALUE ruby_curl_easy_resolve_mode_set(VALUE self, VALUE resolve_mode) {
if (TYPE(resolve_mode) != T_SYMBOL) {
rb_raise(rb_eTypeError, "Must pass a symbol");
return Qnil;
} else {
ruby_curl_easy *rbce;
ID resolve_mode_id;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, rbce);
resolve_mode_id = rb_to_id(resolve_mode);
if (resolve_mode_id == rb_intern("auto")) {
rbce->resolve_mode = CURL_IPRESOLVE_WHATEVER;
return resolve_mode;
} else if (resolve_mode_id == rb_intern("ipv4")) {
rbce->resolve_mode = CURL_IPRESOLVE_V4;
return resolve_mode;
} else if (resolve_mode_id == rb_intern("ipv6")) {
rbce->resolve_mode = CURL_IPRESOLVE_V6;
return resolve_mode;
} else {
rb_raise(rb_eArgError, "Must set to one of :auto, :ipv4, :ipv6");
return Qnil;
}
}
}
|
#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.
4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 |
# File 'ext/curb_easy.c', line 4859
static VALUE ruby_curl_easy_response_code_get(VALUE self) {
ruby_curl_easy *rbce;
long code;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, 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);
}
|
#safe_http! ⇒ Object
178 179 180 181 182 183 |
# File 'lib/curl/easy.rb', line 178 def safe_http! __curb_set_safety_override!( :protocols => [:http, :https], :redirect_protocols => [:http, :https] ) end |
#set(opt, val) ⇒ Object
call-seq:
easy.set :sym|Fixnum, value
set options on the curl easy handle see curl.haxx.se/libcurl/c/curl_easy_setopt.html
146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/curl/easy.rb', line 146 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 |
#setopt(opt, val) ⇒ Object
Some options - like url or cookie - aren’t set directly throught curl_easy_setopt, but stored in the Ruby object state.
When curl_easy_setopt is called, return value is not checked here.
Initial access to libcurl curl_easy_setopt
5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733 5734 5735 5736 5737 5738 5739 5740 5741 5742 5743 5744 5745 5746 5747 5748 5749 5750 5751 5752 5753 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 5788 5789 5790 5791 5792 5793 5794 5795 5796 5797 5798 5799 5800 5801 5802 5803 5804 5805 5806 5807 5808 5809 5810 5811 5812 5813 5814 5815 5816 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 5841 5842 5843 5844 5845 5846 5847 5848 5849 5850 5851 5852 5853 5854 5855 5856 5857 5858 5859 5860 5861 5862 5863 5864 5865 5866 5867 5868 5869 5870 5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931 5932 5933 5934 5935 5936 5937 5938 5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 |
# File 'ext/curb_easy.c', line 5584
static VALUE ruby_curl_easy_set_opt(VALUE self, VALUE opt, VALUE val) {
ruby_curl_easy *rbce;
long option = NUM2LONG(opt);
rb_io_t *open_f_ptr;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, rbce);
switch (option) {
/* BEHAVIOR OPTIONS */
case CURLOPT_VERBOSE: {
VALUE verbose = val;
CURB_BOOLEAN_SETTER(ruby_curl_easy, verbose);
} break;
case CURLOPT_FOLLOWLOCATION: {
VALUE follow_location = val;
CURB_BOOLEAN_SETTER(ruby_curl_easy, follow_location);
} break;
/* TODO: CALLBACK OPTIONS */
/* TODO: ERROR OPTIONS */
/* NETWORK OPTIONS */
case CURLOPT_URL: {
VALUE url = val;
CURB_OBJECT_HSETTER(ruby_curl_easy, url);
} break;
case CURLOPT_CUSTOMREQUEST:
curl_easy_setopt(rbce->curl, CURLOPT_CUSTOMREQUEST, NIL_P(val) ? NULL : StringValueCStr(val));
break;
case CURLOPT_HTTP_VERSION: {
long http_version = NIL_P(val) ? CURL_HTTP_VERSION_NONE : NUM2LONG(val);
rbce->http_version = http_version;
curl_easy_setopt(rbce->curl, CURLOPT_HTTP_VERSION, http_version);
} break;
case CURLOPT_PROXY: {
VALUE proxy_url = val;
CURB_OBJECT_HSETTER(ruby_curl_easy, proxy_url);
} break;
case CURLOPT_INTERFACE: {
VALUE interface_hm = val;
CURB_OBJECT_HSETTER(ruby_curl_easy, interface_hm);
} break;
case CURLOPT_HEADER:
case CURLOPT_NOPROGRESS:
case CURLOPT_NOSIGNAL:
#ifdef HAVE_CURLOPT_PATH_AS_IS
case CURLOPT_PATH_AS_IS:
#endif
#ifdef HAVE_CURLOPT_PIPEWAIT
case CURLOPT_PIPEWAIT:
#endif
case CURLOPT_HTTPGET:
case CURLOPT_NOBODY: {
int type = rb_type(val);
VALUE value;
if (type == T_TRUE) {
value = rb_int_new(1);
} else if (type == T_FALSE) {
value = rb_int_new(0);
} else {
value = rb_funcall(val, rb_intern("to_i"), 0);
}
curl_easy_setopt(rbce->curl, option, NUM2LONG(value));
} break;
case CURLOPT_POST: {
curl_easy_setopt(rbce->curl, CURLOPT_POST, rb_type(val) == T_TRUE);
} break;
case CURLOPT_MAXCONNECTS: {
curl_easy_setopt(rbce->curl, CURLOPT_MAXCONNECTS, NUM2LONG(val));
} break;
case CURLOPT_POSTFIELDS: {
ruby_curl_easy_post_body_set_with_mode(self, val, 0);
} break;
case CURLOPT_USERPWD: {
VALUE userpwd = val;
CURB_OBJECT_HSETTER(ruby_curl_easy, userpwd);
} break;
case CURLOPT_PROXYUSERPWD: {
VALUE proxypwd = val;
CURB_OBJECT_HSETTER(ruby_curl_easy, proxypwd);
} break;
#ifdef HAVE_CURLOPT_NOPROXY
case CURLOPT_NOPROXY: {
VALUE noproxy = val;
CURB_OBJECT_HSETTER(ruby_curl_easy, noproxy);
} break;
#endif
case CURLOPT_COOKIE: {
VALUE cookies = val;
CURB_OBJECT_HSETTER(ruby_curl_easy, cookies);
} break;
case CURLOPT_COOKIEFILE: {
VALUE cookiefile = val;
CURB_OBJECT_HSETTER(ruby_curl_easy, cookiefile);
} break;
case CURLOPT_COOKIEJAR: {
VALUE cookiejar = val;
CURB_OBJECT_HSETTER(ruby_curl_easy, cookiejar);
} break;
#ifdef HAVE_CURLOPT_REQUEST_TARGET
case CURLOPT_REQUEST_TARGET: {
/* Forward request-target directly to libcurl as a string. */
curl_easy_setopt(rbce->curl, CURLOPT_REQUEST_TARGET, NIL_P(val) ? NULL : StringValueCStr(val));
} break;
#endif
#ifdef HAVE_CURLOPT_DOH_URL
case CURLOPT_DOH_URL: {
rb_hash_aset(rbce->opts, rb_easy_hkey("doh_url"), val);
curl_easy_setopt(rbce->curl, CURLOPT_DOH_URL, NIL_P(val) ? NULL : StringValueCStr(val));
} break;
#endif
case CURLOPT_TCP_NODELAY: {
curl_easy_setopt(rbce->curl, CURLOPT_TCP_NODELAY, NUM2LONG(val));
} break;
/* FTP-specific toggles */
#ifdef HAVE_CURLOPT_DIRLISTONLY
case CURLOPT_DIRLISTONLY: {
int type = rb_type(val);
VALUE value;
if (type == T_TRUE) {
value = rb_int_new(1);
} else if (type == T_FALSE) {
value = rb_int_new(0);
} else {
value = rb_funcall(val, rb_intern("to_i"), 0);
}
curl_easy_setopt(rbce->curl, CURLOPT_DIRLISTONLY, NUM2LONG(value));
} break;
#endif
#ifdef HAVE_CURLOPT_FTP_USE_EPSV
case CURLOPT_FTP_USE_EPSV: {
int type = rb_type(val);
VALUE value;
if (type == T_TRUE) {
value = rb_int_new(1);
} else if (type == T_FALSE) {
value = rb_int_new(0);
} else {
value = rb_funcall(val, rb_intern("to_i"), 0);
}
curl_easy_setopt(rbce->curl, CURLOPT_FTP_USE_EPSV, NUM2LONG(value));
} break;
#endif
#ifdef HAVE_CURLOPT_FTP_USE_EPRT
case CURLOPT_FTP_USE_EPRT: {
int type = rb_type(val);
VALUE value;
if (type == T_TRUE) {
value = rb_int_new(1);
} else if (type == T_FALSE) {
value = rb_int_new(0);
} else {
value = rb_funcall(val, rb_intern("to_i"), 0);
}
curl_easy_setopt(rbce->curl, CURLOPT_FTP_USE_EPRT, NUM2LONG(value));
} break;
#endif
#ifdef HAVE_CURLOPT_FTP_SKIP_PASV_IP
case CURLOPT_FTP_SKIP_PASV_IP: {
int type = rb_type(val);
VALUE value;
if (type == T_TRUE) {
value = rb_int_new(1);
} else if (type == T_FALSE) {
value = rb_int_new(0);
} else {
value = rb_funcall(val, rb_intern("to_i"), 0);
}
curl_easy_setopt(rbce->curl, CURLOPT_FTP_SKIP_PASV_IP, NUM2LONG(value));
} break;
#endif
case CURLOPT_RANGE: {
curl_easy_setopt(rbce->curl, CURLOPT_RANGE, StringValueCStr(val));
} break;
case CURLOPT_RESUME_FROM: {
curl_easy_setopt(rbce->curl, CURLOPT_RESUME_FROM, NUM2LONG(val));
} break;
case CURLOPT_FAILONERROR: {
curl_easy_setopt(rbce->curl, CURLOPT_FAILONERROR, NUM2LONG(val));
} break;
case CURLOPT_SSL_CIPHER_LIST: {
curl_easy_setopt(rbce->curl, CURLOPT_SSL_CIPHER_LIST, StringValueCStr(val));
} break;
case CURLOPT_FORBID_REUSE: {
rbce->forbid_reuse = NUM2LONG(val);
rbce->forbid_reuse_set = 1;
curl_easy_setopt(rbce->curl, CURLOPT_FORBID_REUSE, rbce->forbid_reuse);
} break;
#ifdef HAVE_CURLOPT_GSSAPI_DELEGATION
case CURLOPT_GSSAPI_DELEGATION: {
curl_easy_setopt(rbce->curl, CURLOPT_GSSAPI_DELEGATION, NUM2LONG(val));
} break;
#endif
#ifdef HAVE_CURLOPT_UNIX_SOCKET_PATH
case CURLOPT_UNIX_SOCKET_PATH: {
rb_hash_aset(rbce->opts, rb_easy_hkey("unix_socket_path"), val);
curl_easy_setopt(rbce->curl, CURLOPT_UNIX_SOCKET_PATH, NIL_P(val) ? NULL : StringValueCStr(val));
} break;
#endif
#ifdef HAVE_CURLOPT_DNS_SERVERS
case CURLOPT_DNS_SERVERS: {
rb_hash_aset(rbce->opts, rb_easy_hkey("dns_servers"), val);
curl_easy_setopt(rbce->curl, CURLOPT_DNS_SERVERS, NIL_P(val) ? NULL : StringValueCStr(val));
} break;
#endif
#ifdef HAVE_CURLOPT_MAX_SEND_SPEED_LARGE
case CURLOPT_MAX_SEND_SPEED_LARGE: {
curl_easy_setopt(rbce->curl, CURLOPT_MAX_SEND_SPEED_LARGE, (curl_off_t) NUM2LL(val));
} break;
#endif
#ifdef HAVE_CURLOPT_MAX_RECV_SPEED_LARGE
case CURLOPT_MAX_RECV_SPEED_LARGE: {
curl_easy_setopt(rbce->curl, CURLOPT_MAX_RECV_SPEED_LARGE, (curl_off_t) NUM2LL(val));
} break;
#endif
#ifdef HAVE_CURLOPT_MAXFILESIZE
case CURLOPT_MAXFILESIZE:
curl_easy_setopt(rbce->curl, CURLOPT_MAXFILESIZE, NUM2LONG(val));
break;
#endif
#ifdef HAVE_CURLOPT_MAXFILESIZE_LARGE
case CURLOPT_MAXFILESIZE_LARGE:
curl_easy_setopt(rbce->curl, CURLOPT_MAXFILESIZE_LARGE, (curl_off_t)NUM2LL(val));
break;
#endif
#ifdef HAVE_CURLOPT_TCP_KEEPALIVE
case CURLOPT_TCP_KEEPALIVE:
curl_easy_setopt(rbce->curl, CURLOPT_TCP_KEEPALIVE, NUM2LONG(val));
break;
case CURLOPT_TCP_KEEPIDLE:
curl_easy_setopt(rbce->curl, CURLOPT_TCP_KEEPIDLE, NUM2LONG(val));
break;
case CURLOPT_TCP_KEEPINTVL:
curl_easy_setopt(rbce->curl, CURLOPT_TCP_KEEPINTVL, NUM2LONG(val));
break;
#endif
#ifdef HAVE_CURLOPT_HAPROXYPROTOCOL
case CURLOPT_HAPROXYPROTOCOL:
curl_easy_setopt(rbce->curl, CURLOPT_HAPROXYPROTOCOL, NUM2LONG(val));
break;
#endif
case CURLOPT_STDERR:
// libcurl requires raw FILE pointer and this should be IO object in Ruby.
// Tempfile or StringIO won't work.
Check_Type(val, T_FILE);
GetOpenFile(val, open_f_ptr);
curl_easy_setopt(rbce->curl, CURLOPT_STDERR, rb_io_stdio_file(open_f_ptr));
/* Retain a Ruby reference to the IO to prevent GC/finalization
* while libcurl still holds and writes to the underlying FILE*. */
rb_easy_set("stderr_io", val);
break;
case CURLOPT_PROTOCOLS:
case CURLOPT_REDIR_PROTOCOLS:
curl_easy_setopt(rbce->curl, option, NUM2LONG(val));
break;
#ifdef HAVE_CURLOPT_PROTOCOLS_STR
case CURLOPT_PROTOCOLS_STR:
curl_easy_setopt(rbce->curl, CURLOPT_PROTOCOLS_STR, NIL_P(val) ? NULL : StringValueCStr(val));
break;
#endif
#ifdef HAVE_CURLOPT_REDIR_PROTOCOLS_STR
case CURLOPT_REDIR_PROTOCOLS_STR:
curl_easy_setopt(rbce->curl, CURLOPT_REDIR_PROTOCOLS_STR, NIL_P(val) ? NULL : StringValueCStr(val));
break;
#endif
#ifdef HAVE_CURLOPT_SSL_SESSIONID_CACHE
case CURLOPT_SSL_SESSIONID_CACHE:
curl_easy_setopt(rbce->curl, CURLOPT_SSL_SESSIONID_CACHE, NUM2LONG(val));
break;
#endif
#ifdef HAVE_CURLOPT_COOKIELIST
case CURLOPT_COOKIELIST: {
/* Forward to libcurl */
curl_easy_setopt(rbce->curl, CURLOPT_COOKIELIST, StringValueCStr(val));
/* Track whether the cookie engine should be enabled for requests.
* According to libcurl docs, CURLOPT_COOKIELIST also enables the cookie engine
* when provided with a non-command string. Some environments may still require
* an explicit "enable" via CURLOPT_COOKIEFILE="" to send cookies on requests.
* We do that in the perform setup when this flag is set.
*/
if (RB_TYPE_P(val, T_STRING)) {
const char *s = StringValueCStr(val);
if (!(strcmp(s, "ALL") == 0 || strcmp(s, "SESS") == 0 || strcmp(s, "FLUSH") == 0 || strcmp(s, "RELOAD") == 0)) {
rbce->cookielist_engine_enabled = 1;
}
} else {
/* Non-string values are unexpected; be conservative and do not enable. */
}
} break;
#endif
#ifdef HAVE_CURLOPT_PROXY_SSL_VERIFYHOST
case CURLOPT_PROXY_SSL_VERIFYHOST:
curl_easy_setopt(rbce->curl, CURLOPT_PROXY_SSL_VERIFYHOST, NUM2LONG(val));
break;
#endif
#ifdef HAVE_CURLOPT_DOH_SSL_VERIFYPEER
case CURLOPT_DOH_SSL_VERIFYPEER:
curl_easy_setopt(rbce->curl, CURLOPT_DOH_SSL_VERIFYPEER, NUM2LONG(val));
break;
#endif
#ifdef HAVE_CURLOPT_DOH_SSL_VERIFYHOST
case CURLOPT_DOH_SSL_VERIFYHOST:
curl_easy_setopt(rbce->curl, CURLOPT_DOH_SSL_VERIFYHOST, NUM2LONG(val));
break;
#endif
#ifdef HAVE_CURLOPT_DOH_SSL_VERIFYSTATUS
case CURLOPT_DOH_SSL_VERIFYSTATUS:
curl_easy_setopt(rbce->curl, CURLOPT_DOH_SSL_VERIFYSTATUS, NUM2LONG(val));
break;
#endif
#ifdef HAVE_CURLOPT_RESOLVE
case CURLOPT_RESOLVE: {
struct curl_slist *list = NULL;
ruby_curl_easy_clear_resolve_list(rbce);
if (NIL_P(val)) {
/* When nil is passed, we clear any previous resolve list */
list = NULL;
} else if (TYPE(val) == T_ARRAY) {
long i, len = RARRAY_LEN(val);
for (i = 0; i < len; i++) {
VALUE item = rb_ary_entry(val, i);
struct curl_slist *new_list = curl_slist_append(list, StringValueCStr(item));
if (!new_list) {
curl_slist_free_all(list);
rb_raise(rb_eNoMemError, "Failed to append to resolve list");
}
list = new_list;
}
} else {
/* If a single string is passed, use it directly */
list = curl_slist_append(NULL, StringValueCStr(val));
if (!list) {
rb_raise(rb_eNoMemError, "Failed to create resolve list");
}
}
/* Save the list pointer in the ruby_curl_easy structure for cleanup later */
rbce->curl_resolve = list;
rb_hash_aset(rbce->opts, rb_easy_hkey("resolve"), val);
curl_easy_setopt(rbce->curl, CURLOPT_RESOLVE, list);
} break;
#endif
#ifdef HAVE_CURLOPT_CONNECT_TO
case CURLOPT_CONNECT_TO: {
struct curl_slist *list = NULL;
ruby_curl_easy_clear_connect_to_list(rbce);
if (NIL_P(val)) {
list = NULL;
} else if (TYPE(val) == T_ARRAY) {
long i, len = RARRAY_LEN(val);
for (i = 0; i < len; i++) {
VALUE item = rb_ary_entry(val, i);
struct curl_slist *new_list = curl_slist_append(list, StringValueCStr(item));
if (!new_list) {
curl_slist_free_all(list);
rb_raise(rb_eNoMemError, "Failed to append to connect-to list");
}
list = new_list;
}
} else {
list = curl_slist_append(NULL, StringValueCStr(val));
if (!list) {
rb_raise(rb_eNoMemError, "Failed to create connect-to list");
}
}
rbce->curl_connect_to = list;
rb_hash_aset(rbce->opts, rb_easy_hkey("connect_to"), val);
curl_easy_setopt(rbce->curl, CURLOPT_CONNECT_TO, list);
} break;
#endif
default:
rb_raise(rb_eTypeError, "Curb unsupported option");
}
return val;
}
|
#ssl_verify_host ⇒ Numeric
Determine whether this Curl instance will verify that the server cert is for the server it is known as.
3153 3154 3155 |
# File 'ext/curb_easy.c', line 3153 static VALUE ruby_curl_easy_ssl_verify_host_get(VALUE self) { CURB_IMMED_GETTER(ruby_curl_easy, ssl_verify_host, 0); } |
#ssl_verify_host=(value) ⇒ Object
414 415 416 417 418 |
# File 'lib/curl/easy.rb', line 414 def ssl_verify_host=(value) value = 1 if value.class == TrueClass value = 0 if value.class == FalseClass self.ssl_verify_host_integer=value end |
#ssl_verify_host? ⇒ Boolean
call-seq:
easy.ssl_verify_host? => boolean
Deprecated: call easy.ssl_verify_host instead can be one of [0,1,2]
Determine whether this Curl instance will verify that the server cert is for the server it is known as.
430 431 432 |
# File 'lib/curl/easy.rb', line 430 def ssl_verify_host? ssl_verify_host.nil? ? false : (ssl_verify_host > 0) end |
#ssl_verify_host_integer=(ssl_verify_host) ⇒ Object
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? .
3142 3143 3144 |
# File 'ext/curb_easy.c', line 3142
static VALUE ruby_curl_easy_ssl_verify_host_set(VALUE self, VALUE ssl_verify_host) {
CURB_IMMED_SETTER(ruby_curl_easy, ssl_verify_host, 0);
}
|
#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.
3114 3115 3116 |
# File 'ext/curb_easy.c', line 3114
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.
3125 3126 3127 |
# File 'ext/curb_easy.c', line 3125 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).
5267 5268 5269 5270 5271 5272 5273 5274 5275 |
# File 'ext/curb_easy.c', line 5267
static VALUE ruby_curl_easy_ssl_verify_result_get(VALUE self) {
ruby_curl_easy *rbce;
long result;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, 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.
3010 3011 3012 |
# File 'ext/curb_easy.c', line 3010 static VALUE ruby_curl_easy_ssl_version_get(VALUE self) { 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_DEFAULT
Curl::CURL_SSLVERSION_TLSv1 (TLS 1.x)
Curl::CURL_SSLVERSION_SSLv2
Curl::CURL_SSLVERSION_SSLv3
Curl::CURL_SSLVERSION_TLSv1_0
Curl::CURL_SSLVERSION_TLSv1_1
Curl::CURL_SSLVERSION_TLSv1_2
Curl::CURL_SSLVERSION_TLSv1_3
3000 3001 3002 |
# File 'ext/curb_easy.c', line 3000
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.
5047 5048 5049 5050 5051 5052 5053 5054 5055 |
# File 'ext/curb_easy.c', line 5047
static VALUE ruby_curl_easy_start_transfer_time_get(VALUE self) {
ruby_curl_easy *rbce;
double time;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, rbce);
curl_easy_getinfo(rbce->curl, CURLINFO_STARTTRANSFER_TIME, &time);
return rb_float_new(time);
}
|
#status ⇒ Object
call-seq:
easy.status => String
134 135 136 137 138 |
# File 'lib/curl/easy.rb', line 134 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 |
#sym2curl(opt) ⇒ Object
call-seq:
easy.sym2curl :symbol => Fixnum
translates ruby symbols to libcurl
166 167 168 |
# File 'lib/curl/easy.rb', line 166 def sym2curl(opt) Curl.const_get("CURLOPT_#{opt.to_s.upcase}") end |
#timeout ⇒ Numeric
Obtain the maximum time in seconds that you allow the libcurl transfer operation to take.
Uses timeout_ms internally instead of timeout.
2697 2698 2699 2700 2701 |
# File 'ext/curb_easy.c', line 2697
static VALUE ruby_curl_easy_timeout_get(VALUE self) {
ruby_curl_easy *rbce;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, rbce);
return DBL2NUM(rbce->timeout_ms / 1000.0);
}
|
#timeout=(float) ⇒ Numeric
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).
Uses timeout_ms internally instead of timeout because it allows for better precision and libcurl will use the last set value when both timeout and timeout_ms are set.
2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 |
# File 'ext/curb_easy.c', line 2674
static VALUE ruby_curl_easy_timeout_set(VALUE self, VALUE timeout_s) {
ruby_curl_easy *rbce;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, rbce);
if (Qnil == timeout_s || NUM2DBL(timeout_s) <= 0.0) {
rbce->timeout_ms = 0;
} else {
rbce->timeout_ms = (unsigned long)(NUM2DBL(timeout_s) * 1000);
}
return DBL2NUM(rbce->timeout_ms / 1000.0);
}
|
#timeout_ms ⇒ Fixnum?
Obtain the maximum time in milliseconds that you allow the libcurl transfer operation to take.
2735 2736 2737 2738 2739 |
# File 'ext/curb_easy.c', line 2735
static VALUE ruby_curl_easy_timeout_ms_get(VALUE self) {
ruby_curl_easy *rbce;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, rbce);
return LONG2NUM(rbce->timeout_ms);
}
|
#timeout_ms=(fixnum) ⇒ Fixnum?
Set the maximum time in milliseconds 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).
2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 |
# File 'ext/curb_easy.c', line 2715
static VALUE ruby_curl_easy_timeout_ms_set(VALUE self, VALUE timeout_ms) {
ruby_curl_easy *rbce;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, rbce);
if (Qnil == timeout_ms || NUM2DBL(timeout_ms) <= 0.0) {
rbce->timeout_ms = 0;
} else {
rbce->timeout_ms = NUM2ULONG(timeout_ms);
}
return ULONG2NUM(rbce->timeout_ms);
}
|
#total_time ⇒ Float
Retrieve the total time in seconds for the previous transfer, including name resolving, TCP connect etc.
4953 4954 4955 4956 4957 4958 4959 4960 4961 |
# File 'ext/curb_easy.c', line 4953
static VALUE ruby_curl_easy_total_time_get(VALUE self) {
ruby_curl_easy *rbce;
double time;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, 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.
6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 |
# File 'ext/curb_easy.c', line 6036
static VALUE ruby_curl_easy_unescape(VALUE self, VALUE str) {
ruby_curl_easy *rbce;
int rlen;
char *result;
VALUE rresult;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, rbce);
#if (LIBCURL_VERSION_NUM >= 0x070f04)
result = (char*)curl_easy_unescape(rbce->curl, StringValuePtr(str), (int)RSTRING_LEN(str), &rlen);
#else
result = (char*)curl_unescape(StringValuePtr(str), (int)RSTRING_LEN(str));
rlen = strlen(result);
#endif
rresult = rb_str_new(result, rlen);
curl_free(result);
return rresult;
}
|
#unix_socket_path ⇒ String?
Return the configured Unix socket path, if set through CURLOPT_UNIX_SOCKET_PATH.
3506 3507 3508 3509 3510 3511 |
# File 'ext/curb_easy.c', line 3506
static VALUE ruby_curl_easy_unix_socket_path_get(VALUE self) {
ruby_curl_easy *rbce;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, rbce);
return rb_easy_get("unix_socket_path");
}
|
#unrestricted_auth=(boolean) ⇒ Boolean
Configure whether this Curl instance may use any HTTP authentication method available when necessary.
3240 3241 3242 |
# File 'ext/curb_easy.c', line 3240
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.
3251 3252 3253 |
# File 'ext/curb_easy.c', line 3251 static VALUE ruby_curl_easy_unrestricted_auth_q(VALUE self) { CURB_BOOLEAN_GETTER(ruby_curl_easy, unrestricted_auth); } |
#unsafe_destination_error ⇒ String?
Return the native network policy block reason from the most recent transfer.
3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 |
# File 'ext/curb_easy.c', line 3488
static VALUE ruby_curl_easy_unsafe_destination_error_get(VALUE self) {
ruby_curl_easy *rbce;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, rbce);
if (rbce->unsafe_destination_blocked && rbce->unsafe_destination_error[0]) {
return rb_str_new2(rbce->unsafe_destination_error);
}
return Qnil;
}
|
#upload_speed ⇒ Float
Retrieve the average upload speed that curl measured for the preceeding complete upload.
5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 |
# File 'ext/curb_easy.c', line 5188
static VALUE ruby_curl_easy_upload_speed_get(VALUE self) {
ruby_curl_easy *rbce;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, rbce);
#ifdef HAVE_CURLINFO_SPEED_UPLOAD_T
curl_off_t bytes;
curl_easy_getinfo(rbce->curl, CURLINFO_SPEED_UPLOAD_T, &bytes);
return LL2NUM(bytes);
#else
double bytes;
curl_easy_getinfo(rbce->curl, CURLINFO_SPEED_UPLOAD, &bytes);
return rb_float_new(bytes);
#endif
}
|
#uploaded_bytes ⇒ Float
Retrieve the total amount of bytes that were uploaded in the preceeding transfer.
5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 |
# File 'ext/curb_easy.c', line 5144
static VALUE ruby_curl_easy_uploaded_bytes_get(VALUE self) {
ruby_curl_easy *rbce;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, rbce);
#ifdef HAVE_CURLINFO_SIZE_UPLOAD_T
curl_off_t bytes;
curl_easy_getinfo(rbce->curl, CURLINFO_SIZE_UPLOAD_T, &bytes);
return LL2NUM(bytes);
#else
double bytes;
curl_easy_getinfo(rbce->curl, CURLINFO_SIZE_UPLOAD, &bytes);
return rb_float_new(bytes);
#endif
}
|
#uploaded_content_length ⇒ Float
Retrieve the content-length of the upload.
5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 |
# File 'ext/curb_easy.c', line 5313
static VALUE ruby_curl_easy_uploaded_content_length_get(VALUE self) {
ruby_curl_easy *rbce;
TypedData_Get_Struct(self, ruby_curl_easy, &ruby_curl_easy_data_type, rbce);
#ifdef HAVE_CURLINFO_CONTENT_LENGTH_UPLOAD_T
curl_off_t bytes;
curl_easy_getinfo(rbce->curl, CURLINFO_CONTENT_LENGTH_UPLOAD_T, &bytes);
return LL2NUM(bytes);
#else
double bytes;
curl_easy_getinfo(rbce->curl, CURLINFO_CONTENT_LENGTH_UPLOAD, &bytes);
return rb_float_new(bytes);
#endif
}
|
#url ⇒ String
Obtain the URL that will be used by subsequent calls to perform.
1725 1726 1727 |
# File 'ext/curb_easy.c', line 1725 static VALUE ruby_curl_easy_url_get(VALUE self) { CURB_OBJECT_HGETTER(ruby_curl_easy, url); } |
#url=(u) ⇒ Object
call-seq:
easy.url = "http://some.url/" => "http://some.url/"
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.
365 366 367 |
# File 'lib/curl/easy.rb', line 365 def url=(u) set :url, u end |
#use_netrc=(boolean) ⇒ Boolean
Configure whether this Curl instance will use data from the user’s .netrc file for FTP connections.
3187 3188 3189 |
# File 'ext/curb_easy.c', line 3187
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.
3198 3199 3200 |
# File 'ext/curb_easy.c', line 3198 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.
3031 3032 3033 |
# File 'ext/curb_easy.c', line 3031 static VALUE ruby_curl_easy_use_ssl_get(VALUE self) { 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.
3021 3022 3023 |
# File 'ext/curb_easy.c', line 3021
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
2030 2031 2032 |
# File 'ext/curb_easy.c', line 2030 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
2020 2021 2022 |
# File 'ext/curb_easy.c', line 2020
static VALUE ruby_curl_easy_useragent_set(VALUE self, VALUE useragent) {
CURB_OBJECT_HSETTER(ruby_curl_easy, useragent);
}
|
#username ⇒ String
Get the current username
2948 2949 2950 2951 2952 2953 2954 |
# File 'ext/curb_easy.c', line 2948 static VALUE ruby_curl_easy_username_get(VALUE self) { #ifdef HAVE_CURLOPT_USERNAME CURB_OBJECT_HGETTER(ruby_curl_easy, username); #else return Qnil; #endif } |
#username=(string) ⇒ String
Set the HTTP Authentication username.
2934 2935 2936 2937 2938 2939 2940 |
# File 'ext/curb_easy.c', line 2934
static VALUE ruby_curl_easy_username_set(VALUE self, VALUE username) {
#ifdef 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.
1837 1838 1839 |
# File 'ext/curb_easy.c', line 1837 static VALUE ruby_curl_easy_userpwd_get(VALUE self) { CURB_OBJECT_HGETTER(ruby_curl_easy, userpwd); } |
#userpwd=(value) ⇒ Object
call-seq:
easy.userpwd = string => string
Set the username/password string to use for subsequent calls to perform. The supplied string should have the form “username:password”
452 453 454 |
# File 'lib/curl/easy.rb', line 452 def userpwd=(value) set :userpwd, value end |
#verbose=(boolean) ⇒ Boolean
Configure whether this Curl instance gives verbose output to STDERR during transfers. Ignored if this instance has an on_debug handler.
3262 3263 3264 |
# File 'ext/curb_easy.c', line 3262
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.
3273 3274 3275 |
# File 'ext/curb_easy.c', line 3273 static VALUE ruby_curl_easy_verbose_q(VALUE self) { CURB_BOOLEAN_GETTER(ruby_curl_easy, verbose); } |
#version ⇒ Object
353 354 355 |
# File 'lib/curl/easy.rb', line 353 def version http_version end |
#version=(http_version) ⇒ Object
349 350 351 |
# File 'lib/curl/easy.rb', line 349 def version=(http_version) self.http_version = http_version end |