pub struct Easy { /* private fields */ }
Expand description
Raw bindings to a libcurl “easy session”.
This type is the same as the Easy2
type in this library except that it
does not contain a type parameter. Callbacks from curl are all controlled
via closures on this Easy
type, and this type namely has a transfer
method as well for ergonomic management of these callbacks.
There’s not necessarily a right answer for which type is correct to use, but
as a general rule of thumb Easy
is typically a reasonable choice for
synchronous I/O and Easy2
is a good choice for asynchronous I/O.
Examples
Creating a handle which can be used later
use curl::easy::Easy;
let handle = Easy::new();
Send an HTTP request, writing the response to stdout.
use std::io::{stdout, Write};
use curl::easy::Easy;
let mut handle = Easy::new();
handle.url("https://www.rust-lang.org/").unwrap();
handle.write_function(|data| {
stdout().write_all(data).unwrap();
Ok(data.len())
}).unwrap();
handle.perform().unwrap();
Collect all output of an HTTP request to a vector.
use curl::easy::Easy;
let mut data = Vec::new();
let mut handle = Easy::new();
handle.url("https://www.rust-lang.org/").unwrap();
{
let mut transfer = handle.transfer();
transfer.write_function(|new_data| {
data.extend_from_slice(new_data);
Ok(new_data.len())
}).unwrap();
transfer.perform().unwrap();
}
println!("{:?}", data);
More examples of various properties of an HTTP request can be found on the specific methods as well.
Implementations
sourceimpl Easy
impl Easy
sourcepub fn new() -> Easy
pub fn new() -> Easy
Creates a new “easy” handle which is the core of almost all operations in libcurl.
To use a handle, applications typically configure a number of options
followed by a call to perform
. Options are preserved across calls to
perform
and need to be reset manually (or via the reset
method) if
this is not desired.
sourcepub fn show_header(&mut self, show: bool) -> Result<(), Error>
pub fn show_header(&mut self, show: bool) -> Result<(), Error>
Same as Easy2::show_header
sourcepub fn wildcard_match(&mut self, m: bool) -> Result<(), Error>
pub fn wildcard_match(&mut self, m: bool) -> Result<(), Error>
Same as Easy2::wildcard_match
sourcepub fn unix_socket(&mut self, unix_domain_socket: &str) -> Result<(), Error>
pub fn unix_socket(&mut self, unix_domain_socket: &str) -> Result<(), Error>
Same as Easy2::unix_socket
sourcepub fn unix_socket_path<P: AsRef<Path>>(
&mut self,
path: Option<P>
) -> Result<(), Error>
pub fn unix_socket_path<P: AsRef<Path>>(
&mut self,
path: Option<P>
) -> Result<(), Error>
Same as Easy2::unix_socket_path
sourcepub fn write_function<F>(&mut self, f: F) -> Result<(), Error> where
F: FnMut(&[u8]) -> Result<usize, WriteError> + Send + 'static,
pub fn write_function<F>(&mut self, f: F) -> Result<(), Error> where
F: FnMut(&[u8]) -> Result<usize, WriteError> + Send + 'static,
Set callback for writing received data.
This callback function gets called by libcurl as soon as there is data received that needs to be saved.
The callback function will be passed as much data as possible in all
invokes, but you must not make any assumptions. It may be one byte, it
may be thousands. If show_header
is enabled, which makes header data
get passed to the write callback, you can get up to
CURL_MAX_HTTP_HEADER
bytes of header data passed into it. This
usually means 100K.
This function may be called with zero bytes data if the transferred file is empty.
The callback should return the number of bytes actually taken care of.
If that amount differs from the amount passed to your callback function,
it’ll signal an error condition to the library. This will cause the
transfer to get aborted and the libcurl function used will return
an error with is_write_error
.
If your callback function returns Err(WriteError::Pause)
it will cause
this transfer to become paused. See unpause_write
for further details.
By default data is sent into the void, and this corresponds to the
CURLOPT_WRITEFUNCTION
and CURLOPT_WRITEDATA
options.
Note that the lifetime bound on this function is 'static
, but that
is often too restrictive. To use stack data consider calling the
transfer
method and then using write_function
to configure a
callback that can reference stack-local data.
Examples
use std::io::{stdout, Write};
use curl::easy::Easy;
let mut handle = Easy::new();
handle.url("https://www.rust-lang.org/").unwrap();
handle.write_function(|data| {
Ok(stdout().write(data).unwrap())
}).unwrap();
handle.perform().unwrap();
Writing to a stack-local buffer
use std::io::{stdout, Write};
use curl::easy::Easy;
let mut buf = Vec::new();
let mut handle = Easy::new();
handle.url("https://www.rust-lang.org/").unwrap();
let mut transfer = handle.transfer();
transfer.write_function(|data| {
buf.extend_from_slice(data);
Ok(data.len())
}).unwrap();
transfer.perform().unwrap();
sourcepub fn read_function<F>(&mut self, f: F) -> Result<(), Error> where
F: FnMut(&mut [u8]) -> Result<usize, ReadError> + Send + 'static,
pub fn read_function<F>(&mut self, f: F) -> Result<(), Error> where
F: FnMut(&mut [u8]) -> Result<usize, ReadError> + Send + 'static,
Read callback for data uploads.
This callback function gets called by libcurl as soon as it needs to read data in order to send it to the peer - like if you ask it to upload or post data to the server.
Your function must then return the actual number of bytes that it stored in that memory area. Returning 0 will signal end-of-file to the library and cause it to stop the current transfer.
If you stop the current transfer by returning 0 “pre-maturely” (i.e before the server expected it, like when you’ve said you will upload N bytes and you upload less than N bytes), you may experience that the server “hangs” waiting for the rest of the data that won’t come.
The read callback may return Err(ReadError::Abort)
to stop the
current operation immediately, resulting in a is_aborted_by_callback
error code from the transfer.
The callback can return Err(ReadError::Pause)
to cause reading from
this connection to pause. See unpause_read
for further details.
By default data not input, and this corresponds to the
CURLOPT_READFUNCTION
and CURLOPT_READDATA
options.
Note that the lifetime bound on this function is 'static
, but that
is often too restrictive. To use stack data consider calling the
transfer
method and then using read_function
to configure a
callback that can reference stack-local data.
Examples
Read input from stdin
use std::io::{stdin, Read};
use curl::easy::Easy;
let mut handle = Easy::new();
handle.url("https://example.com/login").unwrap();
handle.read_function(|into| {
Ok(stdin().read(into).unwrap())
}).unwrap();
handle.post(true).unwrap();
handle.perform().unwrap();
Reading from stack-local data:
use std::io::{stdin, Read};
use curl::easy::Easy;
let mut data_to_upload = &b"foobar"[..];
let mut handle = Easy::new();
handle.url("https://example.com/login").unwrap();
handle.post(true).unwrap();
let mut transfer = handle.transfer();
transfer.read_function(|into| {
Ok(data_to_upload.read(into).unwrap())
}).unwrap();
transfer.perform().unwrap();
sourcepub fn seek_function<F>(&mut self, f: F) -> Result<(), Error> where
F: FnMut(SeekFrom) -> SeekResult + Send + 'static,
pub fn seek_function<F>(&mut self, f: F) -> Result<(), Error> where
F: FnMut(SeekFrom) -> SeekResult + Send + 'static,
User callback for seeking in input stream.
This function gets called by libcurl to seek to a certain position in the input stream and can be used to fast forward a file in a resumed upload (instead of reading all uploaded bytes with the normal read function/callback). It is also called to rewind a stream when data has already been sent to the server and needs to be sent again. This may happen when doing a HTTP PUT or POST with a multi-pass authentication method, or when an existing HTTP connection is reused too late and the server closes the connection.
The callback function must return SeekResult::Ok
on success,
SeekResult::Fail
to cause the upload operation to fail or
SeekResult::CantSeek
to indicate that while the seek failed, libcurl
is free to work around the problem if possible. The latter can sometimes
be done by instead reading from the input or similar.
By default data this option is not set, and this corresponds to the
CURLOPT_SEEKFUNCTION
and CURLOPT_SEEKDATA
options.
Note that the lifetime bound on this function is 'static
, but that
is often too restrictive. To use stack data consider calling the
transfer
method and then using seek_function
to configure a
callback that can reference stack-local data.
sourcepub fn progress_function<F>(&mut self, f: F) -> Result<(), Error> where
F: FnMut(f64, f64, f64, f64) -> bool + Send + 'static,
pub fn progress_function<F>(&mut self, f: F) -> Result<(), Error> where
F: FnMut(f64, f64, f64, f64) -> bool + Send + 'static,
Callback to progress meter function
This function gets called by libcurl instead of its internal equivalent with a frequent interval. While data is being transferred it will be called very frequently, and during slow periods like when nothing is being transferred it can slow down to about one call per second.
The callback gets told how much data libcurl will transfer and has transferred, in number of bytes. The first argument is the total number of bytes libcurl expects to download in this transfer. The second argument is the number of bytes downloaded so far. The third argument is the total number of bytes libcurl expects to upload in this transfer. The fourth argument is the number of bytes uploaded so far.
Unknown/unused argument values passed to the callback will be set to zero (like if you only download data, the upload size will remain 0). Many times the callback will be called one or more times first, before it knows the data sizes so a program must be made to handle that.
Returning false
from this callback will cause libcurl to abort the
transfer and return is_aborted_by_callback
.
If you transfer data with the multi interface, this function will not be called during periods of idleness unless you call the appropriate libcurl function that performs transfers.
progress
must be set to true
to make this function actually get
called.
By default this function calls an internal method and corresponds to
CURLOPT_PROGRESSFUNCTION
and CURLOPT_PROGRESSDATA
.
Note that the lifetime bound on this function is 'static
, but that
is often too restrictive. To use stack data consider calling the
transfer
method and then using progress_function
to configure a
callback that can reference stack-local data.
sourcepub fn ssl_ctx_function<F>(&mut self, f: F) -> Result<(), Error> where
F: FnMut(*mut c_void) -> Result<(), Error> + Send + 'static,
pub fn ssl_ctx_function<F>(&mut self, f: F) -> Result<(), Error> where
F: FnMut(*mut c_void) -> Result<(), Error> + Send + 'static,
Callback to SSL context
This callback function gets called by libcurl just before the
initialization of an SSL connection after having processed all
other SSL related options to give a last chance to an
application to modify the behaviour of the SSL
initialization. The ssl_ctx
parameter is actually a pointer
to the SSL library’s SSL_CTX. If an error is returned from the
callback no attempt to establish a connection is made and the
perform operation will return the callback’s error code.
This function will get called on all new connections made to a server, during the SSL negotiation. The SSL_CTX pointer will be a new one every time.
To use this properly, a non-trivial amount of knowledge of your SSL library is necessary. For example, you can use this function to call library-specific callbacks to add additional validation code for certificates, and even to change the actual URI of a HTTPS request.
By default this function calls an internal method and
corresponds to CURLOPT_SSL_CTX_FUNCTION
and
CURLOPT_SSL_CTX_DATA
.
Note that the lifetime bound on this function is 'static
, but that
is often too restrictive. To use stack data consider calling the
transfer
method and then using progress_function
to configure a
callback that can reference stack-local data.
sourcepub fn debug_function<F>(&mut self, f: F) -> Result<(), Error> where
F: FnMut(InfoType, &[u8]) + Send + 'static,
pub fn debug_function<F>(&mut self, f: F) -> Result<(), Error> where
F: FnMut(InfoType, &[u8]) + Send + 'static,
Specify a debug callback
debug_function
replaces the standard debug function used when
verbose
is in effect. This callback receives debug information,
as specified in the type argument.
By default this option is not set and corresponds to the
CURLOPT_DEBUGFUNCTION
and CURLOPT_DEBUGDATA
options.
Note that the lifetime bound on this function is 'static
, but that
is often too restrictive. To use stack data consider calling the
transfer
method and then using debug_function
to configure a
callback that can reference stack-local data.
sourcepub fn header_function<F>(&mut self, f: F) -> Result<(), Error> where
F: FnMut(&[u8]) -> bool + Send + 'static,
pub fn header_function<F>(&mut self, f: F) -> Result<(), Error> where
F: FnMut(&[u8]) -> bool + Send + 'static,
Callback that receives header data
This function gets called by libcurl as soon as it has received header
data. The header callback will be called once for each header and only
complete header lines are passed on to the callback. Parsing headers is
very easy using this. If this callback returns false
it’ll signal an
error to the library. This will cause the transfer to get aborted and
the libcurl function in progress will return is_write_error
.
A complete HTTP header that is passed to this function can be up to CURL_MAX_HTTP_HEADER (100K) bytes.
It’s important to note that the callback will be invoked for the headers of all responses received after initiating a request and not just the final response. This includes all responses which occur during authentication negotiation. If you need to operate on only the headers from the final response, you will need to collect headers in the callback yourself and use HTTP status lines, for example, to delimit response boundaries.
When a server sends a chunked encoded transfer, it may contain a trailer. That trailer is identical to a HTTP header and if such a trailer is received it is passed to the application using this callback as well. There are several ways to detect it being a trailer and not an ordinary header: 1) it comes after the response-body. 2) it comes after the final header line (CR LF) 3) a Trailer: header among the regular response-headers mention what header(s) to expect in the trailer.
For non-HTTP protocols like FTP, POP3, IMAP and SMTP this function will get called with the server responses to the commands that libcurl sends.
By default this option is not set and corresponds to the
CURLOPT_HEADERFUNCTION
and CURLOPT_HEADERDATA
options.
Note that the lifetime bound on this function is 'static
, but that
is often too restrictive. To use stack data consider calling the
transfer
method and then using header_function
to configure a
callback that can reference stack-local data.
Examples
use std::str;
use curl::easy::Easy;
let mut handle = Easy::new();
handle.url("https://www.rust-lang.org/").unwrap();
handle.header_function(|header| {
print!("header: {}", str::from_utf8(header).unwrap());
true
}).unwrap();
handle.perform().unwrap();
Collecting headers to a stack local vector
use std::str;
use curl::easy::Easy;
let mut headers = Vec::new();
let mut handle = Easy::new();
handle.url("https://www.rust-lang.org/").unwrap();
{
let mut transfer = handle.transfer();
transfer.header_function(|header| {
headers.push(str::from_utf8(header).unwrap().to_string());
true
}).unwrap();
transfer.perform().unwrap();
}
println!("{:?}", headers);
sourcepub fn fail_on_error(&mut self, fail: bool) -> Result<(), Error>
pub fn fail_on_error(&mut self, fail: bool) -> Result<(), Error>
Same as Easy2::fail_on_error
sourcepub fn connect_to(&mut self, list: List) -> Result<(), Error>
pub fn connect_to(&mut self, list: List) -> Result<(), Error>
Same as Easy2::connect_to
sourcepub fn path_as_is(&mut self, as_is: bool) -> Result<(), Error>
pub fn path_as_is(&mut self, as_is: bool) -> Result<(), Error>
Same as Easy2::path_as_is
sourcepub fn proxy_port(&mut self, port: u16) -> Result<(), Error>
pub fn proxy_port(&mut self, port: u16) -> Result<(), Error>
Same as Easy2::proxy_port
sourcepub fn proxy_cainfo(&mut self, cainfo: &str) -> Result<(), Error>
pub fn proxy_cainfo(&mut self, cainfo: &str) -> Result<(), Error>
Same as Easy2::proxy_cainfo
sourcepub fn proxy_capath<P: AsRef<Path>>(&mut self, path: P) -> Result<(), Error>
pub fn proxy_capath<P: AsRef<Path>>(&mut self, path: P) -> Result<(), Error>
Same as Easy2::proxy_capath
sourcepub fn proxy_sslcert(&mut self, sslcert: &str) -> Result<(), Error>
pub fn proxy_sslcert(&mut self, sslcert: &str) -> Result<(), Error>
Same as Easy2::proxy_sslcert
sourcepub fn proxy_sslcert_blob(&mut self, blob: &[u8]) -> Result<(), Error>
pub fn proxy_sslcert_blob(&mut self, blob: &[u8]) -> Result<(), Error>
Same as Easy2::proxy_sslcert_blob
sourcepub fn proxy_sslkey(&mut self, sslkey: &str) -> Result<(), Error>
pub fn proxy_sslkey(&mut self, sslkey: &str) -> Result<(), Error>
Same as Easy2::proxy_sslkey
sourcepub fn proxy_sslkey_blob(&mut self, blob: &[u8]) -> Result<(), Error>
pub fn proxy_sslkey_blob(&mut self, blob: &[u8]) -> Result<(), Error>
Same as Easy2::proxy_sslkey_blob
sourcepub fn proxy_type(&mut self, kind: ProxyType) -> Result<(), Error>
pub fn proxy_type(&mut self, kind: ProxyType) -> Result<(), Error>
Same as Easy2::proxy_type
sourcepub fn http_proxy_tunnel(&mut self, tunnel: bool) -> Result<(), Error>
pub fn http_proxy_tunnel(&mut self, tunnel: bool) -> Result<(), Error>
Same as Easy2::http_proxy_tunnel
sourcepub fn set_local_port(&mut self, port: u16) -> Result<(), Error>
pub fn set_local_port(&mut self, port: u16) -> Result<(), Error>
Same as Easy2::set_local_port
sourcepub fn local_port_range(&mut self, range: u16) -> Result<(), Error>
pub fn local_port_range(&mut self, range: u16) -> Result<(), Error>
Same as Easy2::local_port_range
sourcepub fn dns_servers(&mut self, servers: &str) -> Result<(), Error>
pub fn dns_servers(&mut self, servers: &str) -> Result<(), Error>
Same as Easy2::dns_servers
sourcepub fn dns_cache_timeout(&mut self, dur: Duration) -> Result<(), Error>
pub fn dns_cache_timeout(&mut self, dur: Duration) -> Result<(), Error>
Same as Easy2::dns_cache_timeout
sourcepub fn buffer_size(&mut self, size: usize) -> Result<(), Error>
pub fn buffer_size(&mut self, size: usize) -> Result<(), Error>
Same as Easy2::buffer_size
sourcepub fn tcp_nodelay(&mut self, enable: bool) -> Result<(), Error>
pub fn tcp_nodelay(&mut self, enable: bool) -> Result<(), Error>
Same as Easy2::tcp_nodelay
sourcepub fn tcp_keepalive(&mut self, enable: bool) -> Result<(), Error>
pub fn tcp_keepalive(&mut self, enable: bool) -> Result<(), Error>
Same as Easy2::tcp_keepalive
sourcepub fn tcp_keepintvl(&mut self, dur: Duration) -> Result<(), Error>
pub fn tcp_keepintvl(&mut self, dur: Duration) -> Result<(), Error>
Same as Easy2::tcp_keepintvl
sourcepub fn tcp_keepidle(&mut self, dur: Duration) -> Result<(), Error>
pub fn tcp_keepidle(&mut self, dur: Duration) -> Result<(), Error>
Same as Easy2::tcp_keepidle
sourcepub fn address_scope(&mut self, scope: u32) -> Result<(), Error>
pub fn address_scope(&mut self, scope: u32) -> Result<(), Error>
Same as Easy2::address_scope
sourcepub fn proxy_username(&mut self, user: &str) -> Result<(), Error>
pub fn proxy_username(&mut self, user: &str) -> Result<(), Error>
Same as Easy2::proxy_username
sourcepub fn proxy_password(&mut self, pass: &str) -> Result<(), Error>
pub fn proxy_password(&mut self, pass: &str) -> Result<(), Error>
Same as Easy2::proxy_password
sourcepub fn proxy_auth(&mut self, auth: &Auth) -> Result<(), Error>
pub fn proxy_auth(&mut self, auth: &Auth) -> Result<(), Error>
Same as Easy2::proxy_auth
sourcepub fn autoreferer(&mut self, enable: bool) -> Result<(), Error>
pub fn autoreferer(&mut self, enable: bool) -> Result<(), Error>
Same as Easy2::autoreferer
sourcepub fn accept_encoding(&mut self, encoding: &str) -> Result<(), Error>
pub fn accept_encoding(&mut self, encoding: &str) -> Result<(), Error>
Same as Easy2::accept_encoding
sourcepub fn transfer_encoding(&mut self, enable: bool) -> Result<(), Error>
pub fn transfer_encoding(&mut self, enable: bool) -> Result<(), Error>
Same as Easy2::transfer_encoding
sourcepub fn follow_location(&mut self, enable: bool) -> Result<(), Error>
pub fn follow_location(&mut self, enable: bool) -> Result<(), Error>
Same as Easy2::follow_location
sourcepub fn unrestricted_auth(&mut self, enable: bool) -> Result<(), Error>
pub fn unrestricted_auth(&mut self, enable: bool) -> Result<(), Error>
Same as Easy2::unrestricted_auth
sourcepub fn max_redirections(&mut self, max: u32) -> Result<(), Error>
pub fn max_redirections(&mut self, max: u32) -> Result<(), Error>
Same as Easy2::max_redirections
sourcepub fn post_fields_copy(&mut self, data: &[u8]) -> Result<(), Error>
pub fn post_fields_copy(&mut self, data: &[u8]) -> Result<(), Error>
Same as Easy2::post_field_copy
sourcepub fn post_field_size(&mut self, size: u64) -> Result<(), Error>
pub fn post_field_size(&mut self, size: u64) -> Result<(), Error>
Same as Easy2::post_field_size
sourcepub fn http_headers(&mut self, list: List) -> Result<(), Error>
pub fn http_headers(&mut self, list: List) -> Result<(), Error>
Same as Easy2::http_headers
Same as Easy2::cookie
Same as Easy2::cookie_file
Same as Easy2::cookie_jar
Same as Easy2::cookie_session
Same as Easy2::cookie_list
sourcepub fn ignore_content_length(&mut self, ignore: bool) -> Result<(), Error>
pub fn ignore_content_length(&mut self, ignore: bool) -> Result<(), Error>
Same as Easy2::ignore_content_length
sourcepub fn http_content_decoding(&mut self, enable: bool) -> Result<(), Error>
pub fn http_content_decoding(&mut self, enable: bool) -> Result<(), Error>
Same as Easy2::http_content_decoding
sourcepub fn http_transfer_decoding(&mut self, enable: bool) -> Result<(), Error>
pub fn http_transfer_decoding(&mut self, enable: bool) -> Result<(), Error>
Same as Easy2::http_transfer_decoding
sourcepub fn resume_from(&mut self, from: u64) -> Result<(), Error>
pub fn resume_from(&mut self, from: u64) -> Result<(), Error>
Same as Easy2::resume_from
sourcepub fn custom_request(&mut self, request: &str) -> Result<(), Error>
pub fn custom_request(&mut self, request: &str) -> Result<(), Error>
Same as Easy2::custom_request
sourcepub fn fetch_filetime(&mut self, fetch: bool) -> Result<(), Error>
pub fn fetch_filetime(&mut self, fetch: bool) -> Result<(), Error>
Same as Easy2::fetch_filetime
sourcepub fn in_filesize(&mut self, size: u64) -> Result<(), Error>
pub fn in_filesize(&mut self, size: u64) -> Result<(), Error>
Same as Easy2::in_filesize
sourcepub fn max_filesize(&mut self, size: u64) -> Result<(), Error>
pub fn max_filesize(&mut self, size: u64) -> Result<(), Error>
Same as Easy2::max_filesize
sourcepub fn time_condition(&mut self, cond: TimeCondition) -> Result<(), Error>
pub fn time_condition(&mut self, cond: TimeCondition) -> Result<(), Error>
Same as Easy2::time_condition
sourcepub fn time_value(&mut self, val: i64) -> Result<(), Error>
pub fn time_value(&mut self, val: i64) -> Result<(), Error>
Same as Easy2::time_value
sourcepub fn low_speed_limit(&mut self, limit: u32) -> Result<(), Error>
pub fn low_speed_limit(&mut self, limit: u32) -> Result<(), Error>
Same as Easy2::low_speed_limit
sourcepub fn low_speed_time(&mut self, dur: Duration) -> Result<(), Error>
pub fn low_speed_time(&mut self, dur: Duration) -> Result<(), Error>
Same as Easy2::low_speed_time
sourcepub fn max_send_speed(&mut self, speed: u64) -> Result<(), Error>
pub fn max_send_speed(&mut self, speed: u64) -> Result<(), Error>
Same as Easy2::max_send_speed
sourcepub fn max_recv_speed(&mut self, speed: u64) -> Result<(), Error>
pub fn max_recv_speed(&mut self, speed: u64) -> Result<(), Error>
Same as Easy2::max_recv_speed
sourcepub fn max_connects(&mut self, max: u32) -> Result<(), Error>
pub fn max_connects(&mut self, max: u32) -> Result<(), Error>
Same as Easy2::max_connects
sourcepub fn maxage_conn(&mut self, max_age: Duration) -> Result<(), Error>
pub fn maxage_conn(&mut self, max_age: Duration) -> Result<(), Error>
Same as Easy2::maxage_conn
sourcepub fn fresh_connect(&mut self, enable: bool) -> Result<(), Error>
pub fn fresh_connect(&mut self, enable: bool) -> Result<(), Error>
Same as Easy2::fresh_connect
sourcepub fn forbid_reuse(&mut self, enable: bool) -> Result<(), Error>
pub fn forbid_reuse(&mut self, enable: bool) -> Result<(), Error>
Same as Easy2::forbid_reuse
sourcepub fn connect_timeout(&mut self, timeout: Duration) -> Result<(), Error>
pub fn connect_timeout(&mut self, timeout: Duration) -> Result<(), Error>
Same as Easy2::connect_timeout
sourcepub fn ip_resolve(&mut self, resolve: IpResolve) -> Result<(), Error>
pub fn ip_resolve(&mut self, resolve: IpResolve) -> Result<(), Error>
Same as Easy2::ip_resolve
sourcepub fn connect_only(&mut self, enable: bool) -> Result<(), Error>
pub fn connect_only(&mut self, enable: bool) -> Result<(), Error>
Same as Easy2::connect_only
sourcepub fn ssl_cert<P: AsRef<Path>>(&mut self, cert: P) -> Result<(), Error>
pub fn ssl_cert<P: AsRef<Path>>(&mut self, cert: P) -> Result<(), Error>
Same as Easy2::ssl_cert
sourcepub fn ssl_cert_blob(&mut self, blob: &[u8]) -> Result<(), Error>
pub fn ssl_cert_blob(&mut self, blob: &[u8]) -> Result<(), Error>
Same as Easy2::ssl_cert_blob
sourcepub fn ssl_cert_type(&mut self, kind: &str) -> Result<(), Error>
pub fn ssl_cert_type(&mut self, kind: &str) -> Result<(), Error>
Same as Easy2::ssl_cert_type
sourcepub fn ssl_key_blob(&mut self, blob: &[u8]) -> Result<(), Error>
pub fn ssl_key_blob(&mut self, blob: &[u8]) -> Result<(), Error>
Same as Easy2::ssl_key_blob
sourcepub fn ssl_key_type(&mut self, kind: &str) -> Result<(), Error>
pub fn ssl_key_type(&mut self, kind: &str) -> Result<(), Error>
Same as Easy2::ssl_key_type
sourcepub fn key_password(&mut self, password: &str) -> Result<(), Error>
pub fn key_password(&mut self, password: &str) -> Result<(), Error>
Same as Easy2::key_password
sourcepub fn ssl_engine(&mut self, engine: &str) -> Result<(), Error>
pub fn ssl_engine(&mut self, engine: &str) -> Result<(), Error>
Same as Easy2::ssl_engine
sourcepub fn ssl_engine_default(&mut self, enable: bool) -> Result<(), Error>
pub fn ssl_engine_default(&mut self, enable: bool) -> Result<(), Error>
Same as Easy2::ssl_engine_default
sourcepub fn http_version(&mut self, version: HttpVersion) -> Result<(), Error>
pub fn http_version(&mut self, version: HttpVersion) -> Result<(), Error>
Same as Easy2::http_version
sourcepub fn ssl_version(&mut self, version: SslVersion) -> Result<(), Error>
pub fn ssl_version(&mut self, version: SslVersion) -> Result<(), Error>
Same as Easy2::ssl_version
sourcepub fn ssl_min_max_version(
&mut self,
min_version: SslVersion,
max_version: SslVersion
) -> Result<(), Error>
pub fn ssl_min_max_version(
&mut self,
min_version: SslVersion,
max_version: SslVersion
) -> Result<(), Error>
Same as Easy2::ssl_min_max_version
sourcepub fn ssl_verify_host(&mut self, verify: bool) -> Result<(), Error>
pub fn ssl_verify_host(&mut self, verify: bool) -> Result<(), Error>
Same as Easy2::ssl_verify_host
sourcepub fn ssl_verify_peer(&mut self, verify: bool) -> Result<(), Error>
pub fn ssl_verify_peer(&mut self, verify: bool) -> Result<(), Error>
Same as Easy2::ssl_verify_peer
sourcepub fn issuer_cert<P: AsRef<Path>>(&mut self, path: P) -> Result<(), Error>
pub fn issuer_cert<P: AsRef<Path>>(&mut self, path: P) -> Result<(), Error>
Same as Easy2::issuer_cert
sourcepub fn issuer_cert_blob(&mut self, blob: &[u8]) -> Result<(), Error>
pub fn issuer_cert_blob(&mut self, blob: &[u8]) -> Result<(), Error>
Same as Easy2::issuer_cert_blob
sourcepub fn random_file<P: AsRef<Path>>(&mut self, p: P) -> Result<(), Error>
pub fn random_file<P: AsRef<Path>>(&mut self, p: P) -> Result<(), Error>
Same as Easy2::random_file
sourcepub fn egd_socket<P: AsRef<Path>>(&mut self, p: P) -> Result<(), Error>
pub fn egd_socket<P: AsRef<Path>>(&mut self, p: P) -> Result<(), Error>
Same as Easy2::egd_socket
sourcepub fn ssl_cipher_list(&mut self, ciphers: &str) -> Result<(), Error>
pub fn ssl_cipher_list(&mut self, ciphers: &str) -> Result<(), Error>
Same as Easy2::ssl_cipher_list
sourcepub fn ssl_sessionid_cache(&mut self, enable: bool) -> Result<(), Error>
pub fn ssl_sessionid_cache(&mut self, enable: bool) -> Result<(), Error>
Same as Easy2::ssl_sessionid_cache
sourcepub fn ssl_options(&mut self, bits: &SslOpt) -> Result<(), Error>
pub fn ssl_options(&mut self, bits: &SslOpt) -> Result<(), Error>
Same as Easy2::ssl_options
sourcepub fn pinned_public_key(&mut self, pubkey: &str) -> Result<(), Error>
pub fn pinned_public_key(&mut self, pubkey: &str) -> Result<(), Error>
Same as Easy2::pinned_public_key
sourcepub fn time_condition_unmet(&mut self) -> Result<bool, Error>
pub fn time_condition_unmet(&mut self) -> Result<bool, Error>
Same as Easy2::time_condition_unmet
sourcepub fn effective_url(&mut self) -> Result<Option<&str>, Error>
pub fn effective_url(&mut self) -> Result<Option<&str>, Error>
Same as Easy2::effective_url
sourcepub fn effective_url_bytes(&mut self) -> Result<Option<&[u8]>, Error>
pub fn effective_url_bytes(&mut self) -> Result<Option<&[u8]>, Error>
Same as Easy2::effective_url_bytes
sourcepub fn response_code(&mut self) -> Result<u32, Error>
pub fn response_code(&mut self) -> Result<u32, Error>
Same as Easy2::response_code
sourcepub fn http_connectcode(&mut self) -> Result<u32, Error>
pub fn http_connectcode(&mut self) -> Result<u32, Error>
Same as Easy2::http_connectcode
sourcepub fn download_size(&mut self) -> Result<f64, Error>
pub fn download_size(&mut self) -> Result<f64, Error>
Same as Easy2::download_size
sourcepub fn content_length_download(&mut self) -> Result<f64, Error>
pub fn content_length_download(&mut self) -> Result<f64, Error>
Same as Easy2::content_length_download
sourcepub fn total_time(&mut self) -> Result<Duration, Error>
pub fn total_time(&mut self) -> Result<Duration, Error>
Same as Easy2::total_time
sourcepub fn namelookup_time(&mut self) -> Result<Duration, Error>
pub fn namelookup_time(&mut self) -> Result<Duration, Error>
Same as Easy2::namelookup_time
sourcepub fn connect_time(&mut self) -> Result<Duration, Error>
pub fn connect_time(&mut self) -> Result<Duration, Error>
Same as Easy2::connect_time
sourcepub fn appconnect_time(&mut self) -> Result<Duration, Error>
pub fn appconnect_time(&mut self) -> Result<Duration, Error>
Same as Easy2::appconnect_time
sourcepub fn pretransfer_time(&mut self) -> Result<Duration, Error>
pub fn pretransfer_time(&mut self) -> Result<Duration, Error>
Same as Easy2::pretransfer_time
sourcepub fn starttransfer_time(&mut self) -> Result<Duration, Error>
pub fn starttransfer_time(&mut self) -> Result<Duration, Error>
Same as Easy2::starttransfer_time
sourcepub fn redirect_time(&mut self) -> Result<Duration, Error>
pub fn redirect_time(&mut self) -> Result<Duration, Error>
Same as Easy2::redirect_time
sourcepub fn redirect_count(&mut self) -> Result<u32, Error>
pub fn redirect_count(&mut self) -> Result<u32, Error>
Same as Easy2::redirect_count
sourcepub fn redirect_url(&mut self) -> Result<Option<&str>, Error>
pub fn redirect_url(&mut self) -> Result<Option<&str>, Error>
Same as Easy2::redirect_url
sourcepub fn redirect_url_bytes(&mut self) -> Result<Option<&[u8]>, Error>
pub fn redirect_url_bytes(&mut self) -> Result<Option<&[u8]>, Error>
Same as Easy2::redirect_url_bytes
sourcepub fn header_size(&mut self) -> Result<u64, Error>
pub fn header_size(&mut self) -> Result<u64, Error>
Same as Easy2::header_size
sourcepub fn request_size(&mut self) -> Result<u64, Error>
pub fn request_size(&mut self) -> Result<u64, Error>
Same as Easy2::request_size
sourcepub fn content_type(&mut self) -> Result<Option<&str>, Error>
pub fn content_type(&mut self) -> Result<Option<&str>, Error>
Same as Easy2::content_type
sourcepub fn content_type_bytes(&mut self) -> Result<Option<&[u8]>, Error>
pub fn content_type_bytes(&mut self) -> Result<Option<&[u8]>, Error>
Same as Easy2::content_type_bytes
sourcepub fn primary_ip(&mut self) -> Result<Option<&str>, Error>
pub fn primary_ip(&mut self) -> Result<Option<&str>, Error>
Same as Easy2::primary_ip
sourcepub fn primary_port(&mut self) -> Result<u16, Error>
pub fn primary_port(&mut self) -> Result<u16, Error>
Same as Easy2::primary_port
sourcepub fn local_port(&mut self) -> Result<u16, Error>
pub fn local_port(&mut self) -> Result<u16, Error>
Same as Easy2::local_port
Same as Easy2::cookies
sourcepub fn transfer<'data, 'easy>(&'easy mut self) -> Transfer<'easy, 'data>
pub fn transfer<'data, 'easy>(&'easy mut self) -> Transfer<'easy, 'data>
Creates a new scoped transfer which can be used to set callbacks and data which only live for the scope of the returned object.
An Easy
handle is often reused between different requests to cache
connections to servers, but often the lifetime of the data as part of
each transfer is unique. This function serves as an ability to share an
Easy
across many transfers while ergonomically using possibly
stack-local data as part of each transfer.
Configuration can be set on the Easy
and then a Transfer
can be
created to set scoped configuration (like callbacks). Finally, the
perform
method on the Transfer
function can be used.
When the Transfer
option is dropped then all configuration set on the
transfer itself will be reset.
sourcepub fn unpause_read(&self) -> Result<(), Error>
pub fn unpause_read(&self) -> Result<(), Error>
Same as Easy2::unpause_read
sourcepub fn unpause_write(&self) -> Result<(), Error>
pub fn unpause_write(&self) -> Result<(), Error>
Same as Easy2::unpause_write
sourcepub fn url_encode(&mut self, s: &[u8]) -> String
pub fn url_encode(&mut self, s: &[u8]) -> String
Same as Easy2::url_encode
sourcepub fn url_decode(&mut self, s: &str) -> Vec<u8>
pub fn url_decode(&mut self, s: &str) -> Vec<u8>
Same as Easy2::url_decode
sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Same as Easy2::reset
sourcepub fn raw(&self) -> *mut CURL
pub fn raw(&self) -> *mut CURL
Same as Easy2::raw
sourcepub fn take_error_buf(&self) -> Option<String>
pub fn take_error_buf(&self) -> Option<String>
Same as Easy2::take_error_buf
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Easy
impl Send for Easy
impl !Sync for Easy
impl Unpin for Easy
impl !UnwindSafe for Easy
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more