These are the procedures provided by the library.
Returns a curl handle that you must use as input to other functions. This handle represents one connection to a server. If it fails, it will throw an error.
If libcurl was built without an asynchronous DNS resolver, the new
handle has the nosignal option set. Such a libcurl uses
signals to time out DNS lookups, which is unsafe in a multithreaded
program, and a Guile process always has several threads. The option
can be turned off with (curl-easy-setopt handle 'nosignal #f).
Returns #t if x is a curl handle such as would be
created by curl-easy-init. #f otherwise.
This forcibly closes all connections that this handle has used and have possibly kept open until now. Any use of the handle after it has been closed is invalid. The return value is unspecified.
Calling this procedure is optional: handles will automatically be freed when no longer in use.
Re-initializes all options previously set on a specified CURL handle to its default values. This puts back the handle to the same state as it was in when it was just created with [
curl-easy-init].It does not change the following information kept in the handle: live connections, the Session ID cache, the DNS cache, the cookies and shares.1
The return value is unspecified.
From the C documentation
This function is called after the init and all the [
curl-easy-setopt] calls are made, and will perform the transfer as described in the options. It must be called with the same handle as input as the [curl-easy-init] call returned.You can do any amount of calls to [
curl-easy-perform] while using the same handle. If you intend to transfer more than one file, you are even encouraged to do so. libcurl will then attempt to re-use the same connection for the following transfers, thus making the operations faster, less CPU intense and using less network resources. Just note that you will have to use [curl-easy-setopt] between the invokes to set options for the following [curl-easy-perform]You must never call this function simultaneously from two places using the same handle. Let the function return first before invoking it another time. If you want parallel transfers, you must use several curl handles.2
The default behavior is to return a string containing
the resource. There is no way to handle the encoding of the string:
the binary data will mapped byte-by-byte to a string containing
codepoints U+0000 through U+00FF. If the optional bytevector?
parameter is given and is set to #t, the resource will be
returned as a bytevector.
It returns either a string containing the resource, a bytevector
containing the resource, or #f on failure. For information
about the failure, you can call curl-error-string.
If the optional header? parameter is set to #t, it
returns a list of two elements. The first is a string that contains
any headers, such as HTTP headers, associated with this operation.
The second is the body of the request, either as a string or as a
bytevector, as described above.
If reading the data to upload from a readdata port raises an
error, the transfer is stopped and curl-easy-perform raises that
error.
Perform the transfer like curl-easy-perform, but write the
response body directly to the open file descriptor fd instead of
returning it, so that a large download does not have to fit in memory.
If offset is omitted or #f, the data is written at the
descriptor’s current position. Otherwise offset must be a
non-negative integer, and the data is written starting at that byte
offset with positioned writes, without moving the descriptor’s
position; this lets several transfers, for example of different
ranges, write into one file at once. Writing at an offset is
not available on platforms without pwrite.
Returns the number of bytes written, or #f on failure; as with
curl-easy-perform, curl-error-code and
curl-error-string then say why. If a write to fd fails,
the error is CURLE_WRITE_ERROR and the error string gives the
system error. The descriptor remains open and is owned by the caller.
While the transfer runs, other Guile threads keep running and may call
curl-easy-progress and curl-easy-cancel! on handle.
Return a pair of the downloaded and total byte counts most recently
reported by a curl-easy-perform-to-fd transfer on handle.
The total is zero while the size of the download is not known. This
may be called from another thread while the transfer runs.
Request that a running curl-easy-perform-to-fd transfer on
handle stop, typically from another thread. The transfer then
returns #f, with the error code CURLE_ABORTED_BY_CALLBACK.
Return the value of the response header name of the most recent
transfer on handle, as a string, or #f if the response had
no such header. name is matched without regard to case. If the
header occurs more than once, index (default 0) selects which
occurrence. Requires libcurl 7.83.0 or later.
Return all the response headers of the most recent transfer on
handle as a list of (name . value) pairs of
strings, in the order they were received. Requires libcurl 7.83.0 or
later.
Send and receive raw data over a connection that libcurl set up but did
not use, so that a program can speak a protocol libcurl does not
support. Set the connect-only option and call
curl-easy-perform to connect first.
curl-easy-send sends data, a string (sent as UTF-8) or a
bytevector, and returns the number of bytes sent, which may be fewer
than given. curl-easy-receive returns a bytevector of at most
max-bytes bytes; it is empty when the other side has closed the
connection. Both return #f on failure, including when the
connection is not ready yet, in which case curl-error-code is
CURLE_AGAIN and the call can be repeated later.
Perform connection upkeep on the connections of handle, such as
sending HTTP/2 PING frames on idle connections that need them. Returns
#t, or #f on failure.
When libcurl reports a failure to a procedure of this library, such as
curl-easy-perform returning #f or curl-easy-setopt
raising an error because libcurl rejected a value, these return
information about it: curl-error-string as a message, and
curl-error-code as one of the integer error codes from libcurl’s
<curl/curl.h> (see Error Codes). Errors found before libcurl
is called, such as an unknown option or an argument of the wrong type,
raise an error without changing them. They are recorded per thread, so
another thread’s failure does not change them either.
Return a new bytevector in which every byte of the bytevector bv
other than an ASCII letter, a digit or one of $ ' ( ) * + , - . /
_ is replaced by % and two upper-case hexadecimal digits. Note
that +, /, , and $ are not escaped; to
encode a value for a URL query string, Guile’s uri-encode from
(web uri) may be more suitable.
A debugging aid: print the internal state of handle, such as the lists and form data stored with it, to the standard error stream.
This procedure sets the options for this handle that will
describe what will happen when curl-easy-perform is called. At
a minimum, curl-easy-setopt must be called at least once per
handle to set the url option. option is a symbol name of
an option, and info is additional information needed for the
option. See Options for setopt, for a table of options and their
associated required type.
important: Options for a handle are not cleared after
curl-easy-performis called. Make sure to callcurl-easy-resetwhen you want the options for this handle to be reset.
The return value is unspecified. An error is raised if handle
is already closed, if option is unknown or not supported by the
installed version of libcurl, if info is not of the option’s
type, or if libcurl rejects the value; in the last case
curl-error-code and curl-error-string say why.
This procedure will extract internal information from a curl handle.
The option is an symbol that indicates the value to be
returned. The returned value is either the requested value or
is #f on error.
You must execute an operation on a handle with
curl-easy-perform before curl-easy-getinfo can be called
on that handle.
important: Care must be taken not do disrupt internal values managed by curl. For example, this procedure can return a file descriptor which is managed by curl and should not be closed.
This may throw an error if handle is already closed or has not yet been used to perform an operation. Also, it may thrown an error if option is not available for the version of curl being used.
The curl-easy-getinfo procedure takes one of the option
symbols give in the first column of the table below. These symbols
are shorthand for the underlying CURL option given in the 2nd column.
Note that whether these options are available is dependent on the
version of curl being used. To verify that a particular option is
available, check that the defined constant is not #f. For
example, to ensure the the 'xfer-id option is available, check
that the CURLINFO_XFER_ID evaluates to an integer.
| Option Symbol | C Library Name | Output Type |
|---|---|---|
| activesocket | CURLINFO_ACTIVESOCKET | integer file descriptor |
| appconnect-time | CURLINFO_APPCONNECT_TIME | real seconds |
| appconnect-time-t | CURLINFO_APPCONNECT_TIME_T | integer microseconds |
| cainfo | CURLINFO_CAINFO | string |
| capath | CURLINFO_CAPATH | string |
| certinfo | CURLINFO_CERTINFO | list of lists of strings3 |
| condition-unmet | CURLINFO_CONDITION_UNMET | integer 1 or zero |
| connect-time | CURLINFO_CONNECT_TIME | real seconds |
| connect-time-t | CURLINFO_CONNECT_TIME_T | integer microseconds |
| conn-id | CURLINFO_CONN_ID | integer |
| content-length-download-t | CURLINFO_CONTENT_LENGTH_DOWNLOAD_T | integer |
| content-length-upload-t | CURLINFO_CONTENT_LENGTH_UPLOAD_T | integer |
| content-type | CURLINFO_CONTENT_TYPE | string |
| cookielist | CURLINFO_COOKIELIST | list of strings |
| earlydata-sent-t | CURLINFO_EARLYDATA_SENT_T | integer bytes |
| effective-method | CURLINFO_EFFECTIVE_METHOD | string |
| effective-url | CURLINFO_EFFECTIVE_URL | string |
| filetime | CURLINFO_FILETIME | integer |
| filetime-t | CURLINFO_FILETIME_T | integer |
| ftp-entry-path | CURLINFO_FTP_ENTRY_PATH | string |
| header-size | CURLINFO_HEADER_SIZE | integer |
| httpauth-avail | CURLINFO_HTTPAUTH_AVAIL | bitfield of CURLAUTH constants See Integer Constants for httpauth |
| httpauth-used | CURLINFO_HTTPAUTH_USED | bitfield of CURLAUTH constants See Integer Constants for httpauth |
| http-connectcode | CURLINFO_HTTP_CONNECTCODE | integer |
| http-version | CURLINFO_HTTP_VERSION | integer of CURL_HTTP_VERSION constants See Integer Constants for http-version |
| local-ip | CURLINFO_LOCAL_IP | string |
| local-port | CURLINFO_LOCAL_PORT | integer |
| namelookup-time | CURLINFO_NAMELOOKUP_TIME | real seconds |
| namelookup-time-t | CURLINFO_NAMELOOKUP_TIME_T | integer microseconds |
| num-connects | CURLINFO_NUM_CONNECTS | integer |
| os-errno | CURLINFO_OS_ERRNO | integer |
| posttransfer-time-t | CURLINFO_POSTTRANSFER_TIME_T | integer microseconds |
| pretransfer-time | CURLINFO_PRETRANSFER_TIME | real seconds |
| pretransfer-time-t | CURLINFO_PRETRANSFER_TIME_T | integer microseconds |
| primary-ip | CURLINFO_PRIMARY_IP | string |
| primary-port | CURLINFO_PRIMARY_PORT | integer |
| proxyauth-avail | CURLINFO_PROXYAUTH_AVAIL | bitfield of CURLAUTH constants |
| proxyauth-used | CURLINFO_PROXYAUTH_USED | bitfield of CURLAUTH constants |
| proxy-error | CURLINFO_PROXY_ERROR | integer of a CURLPX constant |
| proxy-ssl-verifyresult | CURLINFO_PROXY_SSL_VERIFYRESULT | integer |
| queue-time-t | CURLINFO_QUEUE_TIME_T | integer microseconds |
| redirect-count | CURLINFO_REDIRECT_COUNT | integer |
| redirect-time | CURLINFO_REDIRECT_TIME | real seconds |
| redirect-time-t | CURLINFO_REDIRECT_TIME_T | integer microseconds |
| redirect-url | CURLINFO_REDIRECT_URL | string |
| referer | CURLINFO_REFERER | string |
| request-size | CURLINFO_REQUEST_SIZE | integer |
| response-code | CURLINFO_RESPONSE_CODE | integer |
| retry-after | CURLINFO_RETRY_AFTER | integer |
| rtsp-client-cseq | CURLINFO_RTSP_CLIENT_CSEQ | integer CSeq |
| rtsp-cseq-recv | CURLINFO_RTSP_CSEQ_RECV | integer CSeq |
| rtsp-server-cseq | CURLINFO_RTSP_SERVER_CSEQ | integer CSeq |
| rtsp-session-id | CURLINFO_RTSP_SESSION_ID | string |
| scheme | CURLINFO_SCHEME | string |
| size-download-t | CURLINFO_SIZE_DOWNLOAD_T | integer |
| size-upload-t | CURLINFO_SIZE_UPLOAD_T | integer |
| speed-download-t | CURLINFO_SPEED_DOWNLOAD_T | integer bytes per second |
| speed-upload-t | CURLINFO_SPEED_UPLOAD_T | integer bytes per second |
| ssl-engines | CURLINFO_SSL_ENGINES | list of strings |
| ssl-verifyresult | CURLINFO_SSL_VERIFYRESULT | integer |
| starttransfer-time | CURLINFO_STARTTRANSFER_TIME | real seconds |
| starttransfer-time-t | CURLINFO_STARTTRANSFER_TIME_T | integer microseconds |
| total-time | CURLINFO_TOTAL_TIME | real seconds |
| total-time-t | CURLINFO_TOTAL_TIME_T | integer microseconds |
| used-proxy | CURLINFO_USED_PROXY | integer form of boolean |
| xfer-id | CURLINFO_XFER_ID | integer ID |
from the libcurl 7.12.1 curl_easy_reset man page
from the libcurl 7.7 curl_easy_perform man page
One list per certificate in the server’s chain, each of "name:value" strings. The certinfo option must be set before the transfer; otherwise the list is empty.