TclCurl(n)
๐ฆ TclCurl(n) โ TclCurl Easy Interface ๐ฆ
okay bestie, sit down, hydrate, and let me tell you about TclCurl โ it's the Tcl extension that lets you talk to basically the entire internet like it's nothing. โจ
โจ NAME โจ
TclCurl โ transfer data to and from URLs using FTP, FTPS, HTTP, HTTPS, SCP, SFTP, TFTP, TELNET, DICT, FILE, LDAP, LDAPS, IMAP, IMAPS, POP, POP3, SMTP, SMTPS, and GOPHER.
likeโฆ pick a protocol, any protocol ๐
๐ SYNOPSIS ๐
curl::init
curl::transfer ?options?
curl::version
curl::escape url
curl::unescape url
curl::curlConfig option
curl::versioninfo option
curl::easystrerror errorCode
curlHandle configure ?options?
curlHandle perform
curlHandle getinfo curlinfo_option
curlHandle cleanup
curlHandle reset
curlHandle duphandle
curlHandle pause
curlHandle resume
๐ DESCRIPTION ๐
So TclCurl is the extension that hands Tcl programmers the keys to the libcurl library, written by Daniel Stenberg. With TclCurl you can download from URLs, upload to them, and do a whole bunch of other network transfer operations. Want more tea? Go look at http://curl.haxx.se. โโจ
๐ธ curl::init ๐ธ
okay so this procedure must be called first, no skipping, no shortcuts. It returns a curlHandle, and you use that handle to invoke all your TclCurl procedures. Calling init initializes TclCurl, and every single call to init MUST have a corresponding call to cleanup when the operation is complete. like, they're a matched set, you don't leave one hanging ๐ญ
You should perform all sequential file transfers using the same curlHandle. This lets TclCurl reuse persistent connections when possible โ bestie behaviour fr fr ๐ซถ
RETURN VALUE
The curlHandle to use. that's it, that's the gift ๐
๐
curlHandle configure ?OPTIONS? ๐
configure
configure is used to set the options for a transfer. Most operations in TclCurl have default behavior, and you can change that behavior by setting the appropriate options as documented. Each option is specified as the option followed by a parameter. ๐ง
Notes:
- The options set with this procedure apply to subsequent data transfers performed when you invoke
perform. - The options are not reset between transfers (except where noted), so if you want subsequent transfers with different options, you must change them between the transfers. You can optionally reset all options back to the internal default with
curlHandle reset. curlHandleis the value returned by thecurl::initcall.
โจ OPTIONS โจ
๐ฅ BEHAVIOUR OPTIONS ๐ฅ
-verboseโ Set this option to1to make the library display detailed information about its operations. This option is useful when debugginglibcurland protocol-related problems.
You will rarely want to enable this in production, but it is often helpful when debugging or reporting problems. Another useful debugging option is -debugproc.
-headerโ Set this option to1to include headers in the body output. This is relevant only for protocols that actually send headers before the data, such asHTTP.-noprogressโ Set this option to1to disable the progress meter completely. It also preventsprogressprocfrom being called.-nosignalโ Set this option to1to make TclCurl avoid functions that install signal handlers or cause signals to be sent to the process. This option exists mainly so that multi-threaded Unix applications can still use timeout options without risking signal-related side effects.
If this option is set and libcurl has been built with the standard name resolver, timeouts will not occur while name resolution is in progress. Consider building libcurl with c-ares support to enable asynchronous DNS lookups, which allows proper timeouts for name resolution without signals.
Setting nosignal to 1 makes libcurl stop asking the system to ignore SIGPIPE signals. Such signals may otherwise be sent by the system when data is written to a socket that has been closed by the peer. libcurl tries to avoid triggering SIGPIPE, but some operating systems provide no reliable way to prevent it, and even on those that do, some corner cases remain. In addition, using ntlm_Wb authentication may cause a SIGCHLD signal to be raised.
-wildcardโ Set this option to1to transfer multiple files that match a file name pattern. The pattern can be specified as part of the-urloption, using an fnmatch-like pattern (shell pattern matching) in the last part of the URL, that is, the file name.
By default, TclCurl uses its internal wildcard matching implementation. You can provide your own matching function with the -fnmatchproc option.
At present, this feature is supported only for FTP downloads.
A brief introduction of its syntax follows:
*- ASTERISK
ftp://example.com/some/path/***.txt** (for all .txt files from the
root directory) - ? - QUESTION MARK
The question mark matches any single character.
ftp://example.com/some/path/**photo?.jpeg** - [ - BRACKET EXPRESSION
The left bracket opens a bracket expression. The question mark and asterisk have no special meaning in a bracket expression. Each bracket expression ends by the right bracket and matches exactly one character. Some examples follow:
[a-zA-Z0-9] or [f-gF-G] - character interval
[abc] - character enumeration
[^abc] or [!abc] - negation
[[:name:]] class expression. Supported classes are alnum,lower,
space, alpha, digit, print, upper, blank, graph, xdigit.
[][-!^] - special case - matches only โ-โ, โ]โ, โ[โ, โ!โ or โ^โ.
These characters have no special purpose.
[\[\]\\] - escape syntax. Matches โ[โ, โ]โ or โ\โ.
Using the rules above, a file name pattern can be constructed:
ftp://example.com/some/path/**[a-z[:upper:]\\\\].jpeg**
๐ซถ CALLBACK OPTIONS ๐ซถ
-writeprocโ Sets a Tcl procedure that TclCurl invokes whenever received data is available to be handled. The callback procedure must have a single argument. When the procedure is invoked, that argument refers to the contents of a data buffer managed bylibcurl.
NOTE: The amount of data passed on each invocation is not fixed. The callback may be invoked with an empty buffer, or with a buffer containing a large amount of data. so don't be weird about it, okay? ๐
-fileโ File in which the transferred data will be saved. ๐-readprocโ Sets a Tcl procedure that TclCurl calls whenever it needs to read data to send to the peer. The procedure must take one parameter, which contains the maximum number of bytes to read. It should return the actual number of bytes read, or0if you want to stop the transfer.
If you stop the current transfer by returning 0 prematurely, for example after indicating that you would upload N bytes but uploading fewer than N, the server may appear to hang while waiting for the remaining data. ๐ญ awkward.
When doing TFTP uploads, you must return exactly the amount of data requested by the callback. Otherwise, the server may treat it as the final packet and end the transfer. no cap, exact numbers only.
-infileโ File from which the data will be transferred.-progressprocโ Name of the Tcl procedure that TclCurl invokes at regular intervals during an operation, roughly once per second or more often, whether or not data is currently being transferred. Unknown or unused argument values passed to the callback are set to zero. For example, if you only download data, the upload size remains0. The procedure must have the following prototype:
proc ProgressCallback {dltotal dlnow ultotal ulnow}
For this option to work, you must set the -noprogress option to 0. Setting this option to the empty string restores the original progress function.
If you transfer data with the multi interface, this procedure will not be called during periods of idleness unless you call the appropriate procedure that performs transfers.
You can pause and resume a transfer from within this procedure using the pause and resume commands. โโถ๏ธ
-writeheaderโ Pass the file name to which the header part of the received data will be written. Headers are written to this file one by one, and only complete lines are written. This makes header parsing straightforward. ๐ง
See also the -headervar option to get the headers into an array.
-debugprocโ Name of the procedure that receives the debug data produced by the-verboseoption. The callback procedure must have two arguments:
debugProc {infoType data}
The infoType argument identifies the kind of debug information: 0 text, 1 incoming header, 2 outgoing header, 3 incoming data, 4 outgoing data, 5 incoming SSL data, and 6 outgoing SSL data. The data argument contains the corresponding data buffer.
-chunkbgnprocโ Name of the procedure that is called before a file is transferred byFTP. The callback procedure must have one argument:
ChunkBgnProc {remains}
The remains argument is the number of files left to be transferred or skipped.
This callback makes sense only when using the -wildcard option.
-chunkbgnvarโ Name of the variable in the global scope that will contain the data for the file about to be transferred. If you do not use this option,::fileDatais used.
The available data is: filename, filetype (file, directory, symlink, device block, device char, named pipe, socket, door, or error if it could not be identified), time, perm, uid, gid, size, hardlinks, and flags. ๐
-chunkendprocโ Name of the procedure that is called after a file has been transferred or skipped byFTP. The callback procedure takes no arguments:
ChunkEndProc {}
It should return 0 if everything is fine and 1 if an error occurred.
-fnmatchProcโ Name of the procedure that is called instead of the internal wildcard matching function. The callback procedure must have two arguments:
FnMatchProc {pattern string}
The pattern argument contains the pattern to be matched. The string argument contains the candidate string. The procedure must return 0 if the string matches the pattern and 1 otherwise. ๐ฏ
๐ ERROR OPTIONS ๐
-errorbufferโ hand over the name of a variable and TclCurl will stash a whole human-readable error message in there for you ๐ฅบ. Lowkey more useful than the return code alone, because the return code is giving one-word-answer energy and this is giving context.-stderrโ pass a file name. TclCurl writes to that stream instead of stderr whenever it's reporting errors. Redirecting your trauma, but make it a file ๐ .-failonerrorโ set this to1and the transfer fails if the HTTP status code that comes back is400or greater. By default though? TclCurl just returns the page like normal and is NOT treating those status codes as transfer errors. Chill behavior, honestly.
โ ๏ธ heads up bestie, this is not fail-safe. In some cases non-successful response codes may still slip through, especially when authentication is involved โ looking at you, status codes401and407๐.
Also, some header data may be transferred before this condition is even detected. For example, a 100-continue response may be received for a POST or PUT request before a subsequent 401 or 407 response comes back. It's giving โจchaosโจ.
๐ NETWORK OPTIONS ๐
-urlโ the URL to use for the transfer. Iconic. Essential. The main character, truly.
If the URL doesn't have a protocol part like http:// or ftp://, TclCurl tries to guess the protocol from the host name ๐ง. And if the protocol you specified in the URL isn't supported, TclCurl returns the unsupported protocol error when you call perform. Wanna know which protocols are actually supported? Use curl::versioninfo for the detailed tea โ.
Starting with version 7.22.0, the fragment part of the URI is no longer sent as part of the path, unlike earlier versions. Era change, periodt.
๐ NOTE: this is the only option that must be set before perform is called. The rest can vibe, this one cannot.
-protocolsโ pass a lowercase list of protocols to limit which ones TclCurl is allowed to use for the transfer. So if your TclCurl build supports a whole buffet of protocols, you can restrict a specific transfer down to just a subset ๐ฝ๏ธ.
Accepted protocols are http, https, ftp, ftps, scp, sftp, telnet, ldap, ldaps, dict, file, tftp, imap, imaps, pop, pop3, smtp, smtps, gopher, and all.
-redirprotocolsโ same deal, but for redirects ๐. Pass a lowercase list of accepted protocols to limit which ones TclCurl may use when following a redirect with-followlocationenabled. Lets you restrict specific transfers to a subset of protocols for redirections.
By default, TclCurl allows all protocols except FILE and SCP. Which is different from versions before 7.19.4 โ those would follow redirects to all supported protocols unconditionally. Wild times, glad we evolved ๐ฆ.
-proxyโ need an HTTP proxy? Set the proxy string right here. Wanna include a port number in the string? Append:[port]to the end of the host name, slay.
The proxy string may be prefixed with [protocol]://, although that prefix gets ignored unless noted otherwise below. iykyk.
When you configure an HTTP proxy, TclCurl transparently converts operations to HTTP even if you gave it an FTP URL or some other protocol. Sneaky! And this may affect which library features are available. For example, quote and similar FTP-specific features do not work unless you tunnel through the HTTP proxy โ and such tunneling is enabled with -proxytunnel ๐ณ๏ธ.
TclCurl respects the environment variables http_proxy, ftp_proxy, all_proxy, and others of the same kind, if they are set. Using this option overrides any such environment variables. Setting the proxy string to "" explicitly disables proxy use, even if a corresponding environment variable is set. Boundaries! We love to see it ๐
.
The proxy host string can be specified the same way as the proxy environment variables, including a protocol prefix such as http:// and embedded user name and password information.
Since 7.22.0, the proxy string may include a protocol:// prefix to specify alternative proxy protocols. Use socks4://, socks4a://, socks5://, or socks5h:// to request a specific SOCKS version. The last form enables SOCKS5 and asks the proxy to perform name resolution ๐ง . If no protocol is specified โ and for http:// and all other prefixes โ the proxy is treated as an HTTP proxy.
-proxyportโ use this to set the proxy port, unless it's already specified in the proxy string you passed with-proxy. And if you don't specify it at all? TclCurl uses port1080by default ๐.-proxytypeโ pass the proxy type. Available values arehttp,http1.0,socks4,socks4a,socks5, andsocks5h. The default ishttp.
If you set it to http1.0, it only affects how libcurl speaks to a proxy when CONNECT is used. The HTTP version used for ordinary HTTP requests is instead controlled by httpversion. Different department, bestie โจ.
-noproxyโ pass a string with a comma-separated list of hosts that should not use a proxy, if one is specified. The only wildcard is a single*character, which matches all hosts and effectively disables the proxy ๐ซ. Each name in the list is matched either as a domain containing the host name, or as the host name itself. For example,local.commatcheslocal.com,local.com:80, andwww.local.com, but notwww.notlocal.com. The receipts are right there ๐.-httpproxytunnelโ set to1to tunnel all non-HTTP operations through the given HTTP proxy. Using a proxy and tunneling through a proxy are different behaviors, okay? They're not the same thing. This option should only be enabled when that distinction is actually required ๐ซถ.-socks5gssapiserviceโ pass the service name. The default service name for a SOCKS5 server isrcmd/server-fqdn. This option lets you change it ๐.-socks5gssapinecโ pass1to enable or0to disable. As part of the GSSAPI negotiation, a protection mode gets negotiated. RFC 1961 specifies in sections4.3and4.4that this exchange should be protected, but the NEC reference implementation does not do that ๐. When enabled, this option allows the protection mode negotiation to be exchanged unprotected.-interfaceโ pass the interface name to use as the outgoing network interface. The name may be an interface name, an IP address, or a host name. Flexible queen โจ.-localportโ sets the local port number of the socket used for the connection. Can be used together with-interface, and it is recommended to use-localportrangeas well when this option is set. Valid port numbers are1through65535๐ข.-localportrangeโ the number of attempts TclCurl should make to find a working local port number. It starts with the port specified by-localportand increments it by one for each retry. Setting this value to1or less makes TclCurl try only one port number. Because port numbers are a limited resource and may already be in use, setting this value too low may cause unnecessary connection setup failures ๐. Don't do that to yourself.-dnscachetimeoutโ pass the timeout in seconds. Name resolution results are kept in memory for this number of seconds. Set this option to0to disable caching completely, or to-1to keep cached entries indefinitely. By default, TclCurl caches this info for60seconds โฑ๏ธ.
The name resolution functions in various libc implementations do not re-read name server information unless explicitly told to, for example by calling res_init(3). As a result, TclCurl may keep using older server information even after DHCP has updated it โ which may look like a DNS cache issue but is honestly not TclCurl's fault ๐ซ .
-dnsuseglobalcacheโ if set to1, TclCurl uses a global DNS cache that survives the creation and deletion of curl handles. This is not thread-safe, because it relies on a global variable ๐ญ. This option was deprecated in libcurl v7.11.1and is disabled by default in the TclCurl build. SeeREADME.mdfor instructions on how to re-enable it.
๐จ WARNING: This option is obsolete. Use the share interface instead. See tclcurl_share.
-buffersizeโ pass the preferred size for the TclCurl receive buffer. A smaller buffer may cause the write callback to be invoked more often with smaller chunks ๐งฉ. But bestie, this value is treated as a request, not as a guarantee. Manifesting it, essentially.-portโ pass the remote port number to connect to, instead of the port specified in the URL or the default port for the protocol in use. Override the default, you're the main character now ๐.-tcpnodelayโ pass a number to specify whether theTCP_NODELAYoption should be set or cleared (1= set,0= clear). This option is cleared by default. It has no effect after the connection has already been established โณ.
Setting this option will disable TCP's Nagle algorithm. The purpose of that algorithm is to try to minimize the number of small packets on the network โ and by "small packets" we mean TCP segments less than the Maximum Segment Size (MSS) for the network ๐ฆ.
Maximizing the amount of data sent per TCP segment is good, because it amortizes the overhead of the send. However, in some cases (most notably telnet or rlogin) small segments may need to be sent without delay. This is less efficient than sending larger amounts of data at a time, and can contribute to congestion on the network if overdone ๐. Basically: use it with intention, not on impulse.
-addressscopeโ pass a number specifying thescope_idvalue to use when connecting to IPv6 link-local or site-local addresses ๐ฆ.
๐ NAMES AND PASSWORDS OPTIONS ๐
okay bestie, this is the section where you tell TclCurl who you are and prove it. very "let me in, i have credentials" energy. ๐
-netrcโ set this bad boy and TclCurl goes digging through your~/.netrcfile looking for the user name and password of the remote site you're about to hit. heads up tho: TclCurl does not verify that the file has the correct properties set, unlike the standard Unix ftp client. only machine name, user name and password get taken into account โ init macros and similar entries are simply not supported. ๐
accepted values:
optionalโ using~/.netrcis optional, and whatever's in the URL wins. the file gets searched using the host and user name to find the password only, or using the host name alone to find the first user name and password for that machine โ depends on which info the URL is missing. Undefined values for this option do the exact same thing.ignoredโ TclCurl ignores the file completely and uses only what's in the URL. this is the default. ๐requiredโ TclCurl requires the file, ignores the info in the URL, and searches the file using the host name only.
-netrcfileโ pass a string with the full path name of the file to use as the.netrcfile. for this option to work you must set-netrctorequired. if you omit this option but-netrcis set, TclCurl tries to find a.netrcfile in the current user's home directory. ๐-userpwdโ pass a string in the form[username]:[password]to use for the connection. use-httpauthto pick the authentication method.
when you're using NTLM you can specify a domain by prepending it to the user name and separating the domain and name with a forward slash (/) or backward slash (\\), like domain/user:password or domain\\user:password. some HTTP servers on Windows also support this form for Basic authentication.
when you're using HTTP + -followlocation, TclCurl might make several requests to possibly different hosts. TclCurl will only send this user and password info to hosts using the initial host name (unless -unrestrictedauth is set), so if it follows locations to other hosts it will not hand over the user and password to those. this is enforced on purpose to prevent accidental information leakage. ๐ก๏ธ
-proxyuserpwdโ pass a string in the form[username]:[password]for the connection to the HTTP proxy.-usernameโ pass a string containing the user name to use for the transfer. this sets the user name used in protocol authentication. don't use this together with the older-userpwdoption, that's messy.
and to specify the password that goes with it, use the -password option. โจ
-passwordโ pass a string containing the password to use for the transfer. should be used together with-username, they're a duo, a package deal. ๐ซถ-proxyusernameโ pass a string containing the user name to use for the transfer while connecting to the proxy. it works just like-proxyuserpwd, except it lets the user name contain a colon, likesip:user@example.com.-proxyusernameis an alternative way to set the user name for proxy connections โ it should not be used together with-proxyuserpwd. pick one, queen. ๐-proxypasswordโ pass a string containing the password to use for the transfer while connecting to the proxy. this one is meant to be used together with-proxyusername.-httpauthโ set this to the authentication method you want. accepted values:basicโ HTTP Basic authentication. this is the default choice and the only method in widespread use that's supported just about everywhere. it sends the user name and password over the network in plain text. ๐ญdigestโ HTTP Digest authentication. over public networks this is generally more secure than Basic.digestieโ HTTP Digest authentication with an Internet Explorer-specific variant. TclCurl uses a compatibility behavior known to have been used by Internet Explorer before version 7, and still required by some servers. (legacy icons, we respect them ๐)gssnegotiateโ HTTP GSS-Negotiate authentication. also known simply as Negotiate, this method was designed by Microsoft and is used in Microsoft web applications. it's primarily intended to support Kerberos 5 authentication, but it may also be used with other authentication methods.ntlmโ HTTP NTLM authentication. a proprietary protocol developed and used by Microsoft. it uses a challenge-response mechanism and hashing, similar to Digest, to avoid sending the password in clear text.ntlmwbโ NTLM delegated to the winbind helper. authentication is performed by a separate binary application that's executed when needed. the name of that application is specified when libcurl is built, but it's typically/usr/bin/ntlm_auth.anyโ TclCurl automatically selects the method it considers the most secure.anysafeโ TclCurl may use any method except Basic, and automatically selects the one it considers the most secure.
โ ๏ธ note that libcurl will fork when necessary to run the winbind application and kill it when complete, callingwaitpid()to await its exit when done. on POSIX operating systems, killing the process will cause aSIGCHLDsignal to be raised (regardless of whether-nosignalis set). this behavior is subject to change in future versions of libcurl. so, yeah, it's real.
-tlsauthtypeโ selects the authentication method to use for TLS authentication. accepted values:tlsauthsrpโ uses TLS-SRP authentication. Secure Remote Password authentication for TLS is defined in RFC 5054 and provides mutual authentication if both sides share a secret. to use this value you must also set-tlsauthusernameand-tlsauthpassword.
libcurl must be built with GnuTLS or with OpenSSL support for TLS-SRP for any of this to work. ๐ง
-tlsauthusernameโ pass a string containing the user name to use for the TLS authentication method specified with-tlsauthtype. this option requires-tlsauthpasswordto be set as well. besties that travel in pairs. ๐-tlsauthpasswordโ pass a string containing the password to use for the TLS authentication method specified with-tlsauthtype. this option requires-tlsauthusernameto be set as well.-proxyauthโ use this to tell TclCurl which authentication method to use for proxy authentication. for some methods this causes an extra network round trip. set the actual user name and password with-proxyuserpwd.
the methods are those listed above for the httpauth option. as of this writing, only Basic and NTLM work. ๐
๐ HTTP OPTIONS ๐
the main character section. this is where all the real HTTPโจ moves live.
-autorefererโ set this option to1to enable automatic updates of theReferer:header when TclCurl follows aLocation:redirect. ๐-encodingโ sets the contents of theAccept-Encoding:header sent in an HTTP request, and enables decoding of a response when aContent-Encoding:header is received.
accepted values:
identityโ requests no encoding.deflateโ requests compression using the zlib algorithm.gzipโ requests gzip compression.allโ sends anAccept-Encoding:header containing all supported encodings.
important vibe check: this is a request, not a requirement. the server may or may not honor it. ๐ฅฒ this option must be set, or any unsolicited encoding used by the server is ignored. see lib/README.encoding in the libcurl documentation for details.
-transferencodingโ adds a request for compressed Transfer-Encoding in the outgoing HTTP request. if the server supports this and chooses to use it, the response may use a compressed Transfer-Encoding, which TclCurl then decompresses automatically when receiving the data. ๐ซง
Transfer-Encoding differs from the Content-Encoding requested with -encoding in that Transfer-Encoding applies strictly to the transfer, and therefore must be decoded before the data reaches the client. traditionally, Transfer-Encoding has been used less widely and is less consistently supported by HTTP clients and servers. it's giving niche. โจ
-followlocationโ set this option to1to make TclCurl follow any
Location: header
sent by the server as part of an HTTP response.
TclCurl resends the request to the new location and keeps following further Location: headers until no more come back. use -maxredirs to limit how many redirects TclCurl follows.
since 7.19.4, TclCurl can also restrict which protocols it follows automatically. the accepted protocols are set with -redirprotocols. by default, the FILE protocol is excluded. ๐
-unrestrictedauthโ set this option to1to allow TclCurl to keep sending authentication credentials when following redirects, even if the host name changes. this option is meaningful only when-followlocationis enabled. ๐จ-maxredirsโ sets the redirection limit. after that many redirects have been followed, the next redirect causes an error. this option is meaningful only when-followlocationis enabled. set the limit to0to refuse all redirects. set it to-1for an unlimited number of redirects, which is the default. ๐-postredirโ controls how TclCurl acts on redirects after POST requests that receive a301,302, or303response. accepted values are301,302,303, andall. the values301,302, and303make TclCurl preserve the POST request method for the corresponding redirect status code. the valueallenables all three behaviors.
the non-RFC behavior is common in web browsers, so TclCurl performs this conversion by default to maintain consistency. however, a server may require a POST to remain a POST after such a redirection. ๐ค
this option is meaningful only when -followlocation is enabled.
the legacy alias -post301 is accepted for compatibility and uses the same values.
-putโ set this option to1to make TclCurl upload a file using HTTP PUT. the file to upload must be specified with-infileand-infilesize.
this option is deprecated as of version 0.12.1. use -upload. ๐
โโ๏ธ
this option does not limit how much data TclCurl will actually send, as that is controlled entirely by what the read callback returns.
-postโ set this option to1to make TclCurl perform a regular HTTP POST request using theapplication/x-www-form-urlencodedformat commonly used by HTML forms. use-postfieldsto specify the data to post and-postfieldsizeto specify its size. ๐ฎ
Use the -postfields option to specify what data to post and -postfieldsize to set the data size. Optionally, you can also provide POST data using -readproc.
You can override the default POST Content-Type: header by setting your own with -httpheader.
Using POST with HTTP 1.1 implies the use of an Expect: 100-continue header. You can disable this header with -httpheader as usual.
If you use POST with an HTTP 1.1 server, you can send data without knowing the size in advance by using chunked encoding. Enable this by adding a header such as Transfer-Encoding: chunked with -httpheader. With HTTP 1.0, or without chunked transfer encoding, you must specify the size in the request.
Setting -post to 1 also sets -nobody to 0.
NOTE: if you already fired off a POST request and now you're like "actually bestie, gimme a HEAD or a GET instead" โ you have to explicitly pick the new request type with-nobody,-httpget, or a similar option. It will not just switch on its own, and that's on periodt. ๐
-postfieldsโ hand over a string with the complete data for your HTTP POST request. โจ And listen: you are responsible for formatting that data exactly the way you want the server to see it. TclCurl will not convert or encode it for you, no cap. Most web servers just assume it's URL-encoded.
This is the normal application/x-www-form-urlencoded form, aka the one HTML forms use like 90% of the time. ๐
Wanna do a zero-byte POST? Then you gotta set -postfieldsize explicitly to zero, because setting -postfields to NULL or "" effectively disables sending the specified string. TclCurl then assumes your POST data is coming through the read callback instead. ๐ซถ
Using POST with HTTP 1.1 implies the use of an Expect: 100-continue header. You can disable this header with -httpheader as usual.
NOTE: formultipart/form-dataposts, go look at-httppost. Different beast entirely. ๐ฆ
-postfieldsizeโ use this one when you wanna post data without letting TclCurl callstrlen()to figure out the data size. It's also required if you're posting fully binary data, which would otherwise likely fail. ๐ญ If this size is set to zero, the library usesstrlen()to determine the data size.-httppostโ makes TclCurl do an HTTPmultipart/form-dataPOST request. The data you're sending is described through a Tcl list. ๐
This is the only case where the data is reset after a transfer. Iconic, honestly.
Each part consists of at least a NAME and a CONTENTS part. If the part is used for file upload, it may also contain CONTENT-TYPE and FILENAME information.
The list must contain a 'name' tag followed by the section name. The section value can then be described with 'value', followed by a string containing the data to post, 'file', followed by the name of the file to post, or 'contenttype', followed by the content type (text/plain, image/jpg, and so on). You can also supply an alternate file name with 'filename'. This is useful if the server checks whether the provided file name is valid, or if you want to include the full path of the file being posted. You can also post the contents of a variable as if it were a file by using 'bufferName' and 'buffer', or use 'filecontent' followed by a file name to read that file and use its contents as data. ๐ธ
To specify additional headers for a form section, use 'contentheader' followed by a list of headers.
See httpPost.tcl and httpBufferPost.tcl for examples. ๐
Return values:
- If the memory allocation fails.
- If one option is given twice for one form.
- If an empty string was given.
- If an unknown option was used.
- If some form information is incomplete or invalid.
- If an illegal option is used in an array.
- If TclCurl has no HTTP support.
-refererโ pass a string to set theReferer:header in the HTTP request sent to the remote server.
The Referer: header identifies the resource from which the target URI was obtained. Servers may use it for logging, analytics, backlink generation, caching decisions, or request-flow checks. ๐
This option is useful when a scripted client must reproduce the request context normally sent by a web browser, or when a server expects a specific referring URI.
The header value should normally be a URI identifying the referring resource. Fragments and userinfo components are not part of a valid Referer: field value.
The field name Referer is a historical misspelling of referrer, but the misspelled form is the standardized HTTP header name. The way HTTP just kept the typo forever? It's giving fossilized lore. ๐
Careful bestie: this header may reveal navigation context or sensitive URI data, so set it with care. And do not rely on it as a secure means of authentication or access control. Like, at all. ๐
You can also set this header through -httpheader.
-useragentโ pass a string to set theUser-Agent:header in the HTTP request sent to the remote server. You can also set custom headers with-httpheader. ๐ง-httpheaderโ pass a list of HTTP headers to send in the request. Here's the tea โ: if you add a header that TclCurl would otherwise generate internally, your header is used instead. And if you add a header with no value, such asAccept:, the internal header gets disabled. So this option can add, replace, or remove internal headers. Add/replace/remove โ the whole trio, slay.
This option is useful when the request must include headers not exposed by dedicated TclCurl options, or when you need exact control over the final HTTP request. Common uses include setting custom authentication-related headers, API-specific headers, cache-control directives, or overriding headers such as Content-Type: or Accept:.
IMPORTANT: the headers in the list must not be CRLF-terminated, because TclCurl adds CRLF after each header item. If you include CRLF yourself, the server will likely ignore part of the headers you specified. ๐ Don't do it.
The first line of a request, containing the method, usually GET or POST, is not a header and cannot be replaced with this option. Only the lines following the request line are headers. Adding the method line to this list causes an invalid header to be sent. ๐ซ
NOTE: the most commonly replaced headers have dedicated shortcut options:-cookie,-useragent, and-referer. Use those for the easy wins. ๐
-http200aliasesโ pass a list of aliases to be treated as valid HTTP 200 responses. Some servers return a custom response line. For example, IceCast servers may returnICY 200 OK. If you include such a string in the list, it is treated as a valid HTTP status line such asHTTP/1.0 200 OK. ๐
NOTE: the alias itself is not parsed for a version string. Before version7.16.3, TclCurl used the value set by-httpversion, but since7.16.3the protocol is assumed to match HTTP 1.0 when an alias matches. Little glow-up in the version history, we love to see it. โจ
-cookieโ pass a string to set a cookie in the HTTP request. The string should use the format[NAME]=[CONTENTS];, where NAME is the cookie name and CONTENTS is the cookie value. ๐ช
If you need to set multiple cookies, you must set them all in a single option value by concatenating them into one string, for example name1=content1; name2=content2;.
This option sets the cookie header explicitly in the outgoing request(s). If multiple requests are performed because of authentication, redirects, or similar causes, they all receive this cookie header.
If this option is used multiple times, only the last value is kept. So don't stack 'em, mmkay? ๐
-cookiefileโ pass the name of a file containing cookie data. The cookie data may be in Netscape cookie file format or in regular HTTP-style headers written to a file. ๐
If the file is empty or does not exist, this option still enables cookies for the handle, causing TclCurl to parse received cookies and use matching cookies in later requests.
If you use this option multiple times, each use adds another file to read. Additive, not replace-y. ๐
-cookiejarโ pass a file name to which TclCurl writes all internally known cookies whencurlHandlecleanup is called. If no cookies are known, no file is created. Specify-to write the cookies to standard output. ๐ซ
Using this option also enables cookies for the session, so matching cookies are sent on later requests, including those caused by redirects.
Heads up: TclCurl cannot report an error if writing the cookie jar fails. If-verboseis enabled, a warning is displayed, but that is the only visible feedback in this case. So if your jar's empty and you're confused, turn on-verboseand look. ๐ญ
-cookiesessionโ set this option to1to mark the current run as a new cookie session. This makes TclCurl ignore session cookies loaded from a previous session. By default, TclCurl stores and loads all cookies, including session cookies. Session cookies are cookies without an expiry date and are meant to exist only for the current session. ๐ฆ-cookielistโ pass a string containing a cookie. The cookie may be in Netscape/Mozilla format or in regular HTTP-style header form, such asSet-Cookie: ..... If the cookie engine is not enabled, it is enabled automatically. No setup needed, it just handles it. ๐
Special values are ALL, which erases all known cookies, and FLUSH, which writes all known cookies to the file specified by -cookiejar. ๐งน
-httpgetโ set this option to1to force the HTTP request method back toGET. This is useful ifPOST,PUT, or a custom request has previously been used with the same handle. Take it back, bestie. ๐
Setting -httpget to 1 also sets -nobody to 0.
-httpversionโ selects the HTTP version to use. This option should be used only when it is necessary to override the default behavior because of server-side requirements. Don't just fiddle with it for funsies. ๐
Accepted values:
noneโ lets TclCurl use the HTTP version it considers appropriate.1.0โ enforce HTTP 1.0 requests.1.1โ enforce HTTP 1.1 requests.2.0โ enforce HTTP version 2 requests.2TLSโ enforce version 2 requests for HTTPS, version 1.1 for HTTP.2_PRIOR_KNOWLEDGEโ enforce HTTP 2 requests without performing an HTTP/1.1 Upgrade first.
-ignorecontentlengthโ ignores theContent-Lengthheader. This is useful for Apache 1.x and similar servers, which may report an incorrect content length for files larger than 2 gigabytes. ๐๏ธ
Warning: if this option is used, TclCurl cannot report progress accurately and stops the download only when the server closes the connection. So your progress bar is basically lying to you. ๐
-httpcontentdecodingโ set this option to0to disable content decoding, or to1to enable it. TclCurl does not enable content decoding by default; for that, you must also use-encoding. No cap, two options for one vibe. ๐ธ-httptransferencodingโ set this to0to turn transfer decoding OFF, or1to turn it ON. The default is1. TclCurl does chunked transfer decoding by default unless you disable this option. Lowkey important, don't forget it ๐ซถ
๐ SMTP OPTIONS ๐
-mailfromโ pass in a string with the sender address to use in the SMTP envelope.
Ok so real talk: this controls the envelope sender at the SMTP protocol level. It does not set or modify the From: header field in the message body. Two totally different things bestie, do not conflate them ๐
-mailrcptโ pass a list of recipient addresses to use in the SMTP envelope.
Same energy as above: this controls the envelope recipients at the SMTP protocol level. It does not set or modify message header fields like To:, Cc:, or Bcc:.
In SMTP, recipients are written with angle brackets (<>) around them. If one of your recipient values doesn't already start with an angle bracket, TclCurl assumes it's a plain email address and adds the angle brackets for you automatically. So chill, it's handled โจ
๐ TFTP OPTION ๐
-tftpblksizeโ specifies the block size to use for TFTP data transmission. According to RFC 2348, valid values range from8to65464bytes. If you don't specify this option, the default block size is512bytes.
Big caveat though: the block size you asked for only actually gets used if the remote server supports it. If the server doesn't return an option acknowledgment, or it returns an acknowledgment without a block size value, then you're getting the default 512 bytes. No negotiation, no drama ๐ธ
๐ FTP OPTIONS ๐
-ftpportโ pass a string identifying the address to use for the FTPPORTinstruction. ThePORTinstruction tells the remote server to connect to the specified client address. That string can be a plain IP address, a host name, a network interface name on Unix, or just-to let the library use the system's default IP address. By default FTP transfers are passive, soPORTdoesn't get used at all.
You can tack : and a port number onto the address, and optionally - and a port range after that. If the port you specify is 0, the operating system picks a free port for you. If you gave a range and none of the ports in it are available, libcurl reports CURLE_FTP_PORT_FAILED for the handle. Invalid port or port-range settings? Ignored, silently. Also โ IPv6 addresses followed by a port or port range must be enclosed in brackets. IPv6 addresses without a port or port range may also be enclosed in brackets.
Examples:
eth0:0 192.168.1.2:32000-33000 curl.se:32123 [::1]:1234-4567
Wanna turn PORT off and go back to passive mode? Set this option to the empty string. Easy ๐
-quoteโ pass a list of FTP or SFTP commands to send to the server before the FTP transfer request. These go out before any other FTP commands, includingCWD. If you don't actually want to transfer any files, set-nobodyto1and-headerto0.
Prefix a command with an asterisk (*) and TclCurl keeps going even if that command fails. By default though, a failure stops the transfer. ๐
To disable this option, set it to the empty string.
The commands have to be raw FTP commands. Like, if you wanna create a directory you send mkd Test, not mkdir Test. Don't argue with the server, it's not gonna meet you halfway.
Valid SFTP commands are chgrp, chmod, chown, ln, mkdir, pwd, rename, rm, rmdir, and symlink.
-postquoteโ pass a list of FTP commands to send to the server after the FTP transfer request. If you don't wanna transfer any files, set-nobodyto1and-headerto0.-prequoteโ pass a list of FTP or SFTP commands to send to the server after the transfer type has been set.-dirlistonlyโ set this to1and you get just the file names in a directory, instead of requesting a full directory listing with file sizes, dates and all that extra info. Works with both FTP and SFTP URLs โจ
For FTP, this makes an NLST command get sent. Heads up: some FTP servers return only files in response to NLST, and may leave out subdirectories and symbolic links. Rude, but that's the server's problem not yours.
Setting this to 1 also implies a directory listing even if the URL doesn't end with a slash, which would otherwise be required.
Do not use this option together with -wildcardmatch โ it effectively disables that feature. Pick a lane bestie.
-appendโ set this to1to append to the remote file instead of overwriting it. Only useful when you're uploading to an FTP site.-ftpuseeprtโ set this to1and TclCurl uses theEPRTandLPRTcommands for active FTP transfers, which are the ones enabled with-ftpport. With this on, TclCurl triesEPRTfirst, thenLPRT, and only then falls back toPORT. Set it to0and onlyPORTis used. Simple as.-ftpuseepsvโ set this to1and TclCurl uses theEPSVcommand for passive FTP transfers. This is the default behavior. When it's on, TclCurl triesEPSVbefore falling back toPASV. Set this to0and TclCurl uses onlyPASV.-ftpusepretโ set this to1and TclCurl sends aPRETcommand beforePASVorEPSV. Some FTP servers, especially drftpd, require this non-standard command for directory listings and uploads or downloads in passive mode. This option has no effect for active FTP transfers though โ it's passive-only energy ๐-ftpcreatemissingdirsโ controls whether TclCurl should try to create a remote directory when the transfer needs that directory to exist, but aCWDcommand shows it doesn't exist yet or can't be entered yet.
This also applies to SFTP connections. TclCurl attempts to create the remote directory if it can't obtain a handle to the target location. Creation fails if a file with the same name already exists, or if permissions don't allow directory creation. It's giving "we tried our best" ๐ญ
Accepted values:
1โ after a failedCWD, TclCurl attempts to create the missing remote directory, then continues with the transfer.2โ after a failedCWD, TclCurl attempts to create the missing remote directory. If the followingMKDcommand fails, TclCurl retries theCWDcommand before giving up. Super useful when multiple simultaneous connections target the same server and another connection may have created the directory in the meantime. Teamwork fr fr ๐ซถ
-ftpresponsetimeoutโ sets a timeout, in seconds, for how long the server may take to return a response to an FTP command before the session counts as hung. While TclCurl is waiting for such a response, this value overrides-timeout. If you're using both,-ftpresponsetimeoutshould normally be set smaller than-timeout. Keep it snappy โจ-ftpalternativetouserโ pass a string to use for authentication if the usual FTPUSERuser andPASSpassword negotiation fails. This is known to be required in some cases when connecting to Tumbleweed Secure Transport FTPS servers that use client-certificate authentication. Niche but iconic ๐-ftpskippasvipโ set this to1and TclCurl ignores the IP address the server suggested in its227response to TclCurl'sPASVcommand when opening the data connection. Instead, TclCurl reuses the same IP address already in use for the control connection, while still using the port number from the227response.
This option has no effect if PORT, EPRT, or EPSV is used instead of PASV. Sorry, wrong door ๐
-ftpsslauthโ selects how TclCurl issuesAUTH TLSorAUTH SSLwhen FTP over SSL is enabled with-ftpssl.
You might need this for servers like BSDFTPD-SSL, which don't handle AUTH SSL correctly and require AUTH TLS instead.
Accepted values:
defaultโ lets TclCurl choose.sslโ triesAUTH SSLfirst, and triesAUTH TLSonly if that fails.tlsโ triesAUTH TLSfirst, and triesAUTH SSLonly if that fails.
-ftpsslcccโ controls use ofCCC(Clear Command Channel).CCCshuts down the SSL/TLS layer after authentication, so the rest of the control channel is unencrypted. This can let NAT routers inspect the FTP control channel. Yes, that is a real tradeoff, read it again ๐ฅ
Accepted values are:
noneโ do not attempt to useCCC.passiveโ do not initiate the shutdown. Wait for the server to do so, and don't send a reply.activeโ initiate the shutdown and wait for a reply.
-ftpaccountโ pass a string containing account data, or""to disable it. If an FTP server asks for account data after the user name and password have been provided, TclCurl sends this value with theACCTcommand.-ftpfilemethodโ selects how TclCurl navigates FTP paths. Accepted values are:multicwdโ the default. TclCurl performs oneCWDoperation for each path component in the URL. For deep hierarchies this may require many commands. This is the method described by RFC 1738.nocwdโ TclCurl does not performCWDat all. Instead it sends commands such asSIZE,RETR, andSTORwith the full path.singlecwdโ TclCurl performs oneCWDto the full target directory and then operates on the file normally. This is somewhat more standards compliant thannocwd, without the full overhead ofmulticwd. Best of both worlds, honestly ๐
๐ PROTOCOL OPTIONS ๐
-transfertextโ set this bad boy to1and you get ASCII mode for FTP transfers instead of the default binary mode. Heads up tho: on Win32 systems this does NOT flipstdoutinto binary mode. It's genuinely useful when you're moving text data between systems that treat stuff like newlines differently (they're messy like that ๐ฅด).
โ ๏ธ NOTE: TclCurl does not do full ASCII conversion during ASCII FTP transfers. It literally just sets the transfer mode to ASCII and then does a normal transfer. That's it. That's the whole thing. ๐
-proxytransfermodeโ set to1and TclCurl will set the transfer mode (binary or ASCII) for FTP transfers going through an HTTP proxy, by appending;type=aor;type=ito the URL. If you omit this or set it to0, then-transfertextdoes absolutely nothing for FTP transfers through an HTTP proxy. And not every proxy supports this either, so vibe check your proxy first ๐ซถ-crlfโ set to1and TclCurl converts Unix newlines to CRLF newlines during transfers. Set to0and it stops doing that. Simple as. โจ-rangeโ hand it a string with the range you want. Format isX-Y, and eitherXorYcan be omitted. HTTP transfers also support multiple ranges separated by commas, likeX-Y,N-M. When you ask for multiple ranges over HTTP, the server sends the document back in pieces using standard MIME separation rules, no cap.
Range requests are supported only for HTTP, FTP, and FILE transfers. That's the whole guest list ๐
-resumefromโ pass the offset, in bytes, where the transfer should start. Set it to0to start from the very beginning, which kills the resume behavior entirely.
For FTP, set it to -1 to start from the end of the target file โ super handy when you're continuing an interrupted upload ๐
For FTP uploads, the resume position tells TclCurl where in the local source file to resume reading. Whatever data it reads from that point gets appended to the remote target file. Chef's kiss.
-customrequestโ pass a string with the request method you wanna use instead of the default one (likeGETorHEAD) when making an HTTP request. Great for methods likeDELETEand other less common HTTP requests. Only use this when you know the server supports the method you picked, bestie.
TclCurl still behaves internally according to the type of request it would've used otherwise. So switching the method with this option can give you inconsistent behavior if you didn't also select the right request type through the usual dedicated option. Like โ to make a proper HEAD request, use -nobody. To make a proper POST request, use -post or -postfields. Don't freestyle it ๐
-filetimeโ set to1to make TclCurl try to grab the modification time of the remote document during the transfer. This needs the remote server to either send that time directly or support a command that queries it. After the transfer, you can get the filetime value with thegetinfoprocedure. Lowkey satisfying when it works.
For FTP transfers, this usually means the server has to support a command for querying the remote file modification time, like MDTM. If the server doesn't have this info, the transfer can still succeed โ it's just that the filetime value stays unknown. No drama. ๐
-nobodyโ set to1to leave the body out of the output. This only matters for protocols that actually distinguish a header part from a body part. For HTTP and HTTPS, this makes TclCurl issue aHEADrequest.
Wanna go back to GET? Use -httpget. Wanna switch to POST? Use -post or a related option. Slay. ๐ฅ
-infilesizeโ use this when uploading a file to specify the expected size of the input file.
This option is mandatory for uploads done with SCP. Like, required required. Don't skip it. โญ
-uploadโ set to1to get ready for an upload. The-infileand-infilesizeoptions are also relevant for uploads. If the protocol is HTTP, uploading means using thePUTrequest unless you tell TclCurl otherwise.
Using PUT with HTTP 1.1 implies the use of a Expect: 100-continue header. You can disable that header with -httpheader, as usual โจ
If you use PUT to an HTTP 1.1 server, you can upload data without knowing the size before you start the transfer โ as long as you use chunked encoding. You enable that by adding a header like Transfer-Encoding: chunked with -httpheader. With HTTP 1.0, or without chunked transfer, you must specify the size. No shortcuts, sorry ๐
-maxfilesizeโ lets you specify the maximum size (in bytes) of a file to download. If the requested file is bigger than this value, the transfer won't even start, and error'filesize exceeded'(63) gets returned. Bye bye ๐
โ ๏ธ NOTE: the file size isn't always known before the download, and for files like that this option has no effect โ even if the transfer ends up being bigger than the limit you set. This concerns both FTP and HTTP transfers. Rough, ik.
-timeconditionโ defines how thetimevaluevalue gets treated. Accepted values areifmodsinceandifunmodsince. This feature applies to HTTP, FTP, and FILE. ๐-timevalueโ this should be the time in seconds since1 jan 1970, and that time gets used in a condition exactly as specified withtimecondition. Time travelling but make it HTTP. โฐ
๐ CONNECTION OPTIONS ๐
-timeoutโ pass the maximum time, in seconds, that a TclCurl transfer operation may take. Name resolution alone can eat up a noticeable chunk of time, so setting this too low can abort operations that would've been perfectly fine. Don't be impatient, bestie ๐ญ
Heads up: this option may cause libcurl to use SIGALRM to interrupt blocking system calls. So on Unix-like systems, signals may be used unless -nosignal is enabled. โ ๏ธ
-timeoutmsโ like-timeout, but the value is in milliseconds. If libcurl is built to use the standard system name resolver, name resolution still uses full-second timeout granularity. Slightly less precise than you'd hope, ngl. ๐ซถ-lowspeedlimitโ pass the speed, in bytes per second, below which the transfer rate has to stay for-lowspeedtimeseconds before TclCurl decides the transfer is too slow and aborts it. Slow and steady does not win this race ๐-lowspeedtimeโ pass the number of seconds during which the transfer speed has to stay below-lowspeedlimitbefore TclCurl considers the transfer too slow and aborts it. It's giving patience with a timer โณ-maxsendspeedโ pass a speed in bytes per second. If an upload exceeds this average speed during the transfer, TclCurl pauses the transfer as needed to keep the average rate at or below the value you set. Default is unlimited speed. Go fast if you want ๐๏ธ-maxrecvspeedโ pass a speed in bytes per second. If a download exceeds this average speed during the transfer, TclCurl pauses the transfer as needed to keep the average rate at or below the value you set. Default is unlimited speed. Same energy, download edition ๐ธ-maxconnectsโ sets the size of the persistent connection cache for protocols that support persistent connections. This value is the max number of simultaneous connections TclCurl may cache in the easy handle. Default is5.
When you hit the max, TclCurl closes the oldest cached connection so the number of open connections can't keep growing. Efficiency era ๐
โ ๏ธ NOTE: if transfers have already been performed with this easy handle, lowering -maxconnects may cause existing open connections to be closed earlier than you expected. Surprise! ๐
If this easy handle gets added to a multi handle, this setting is ignored. In that case, configure the corresponding maxconnects option on the multi handle instead. โจ
-connecttimeoutโ pass the maximum time, in seconds, that the connection phase may take. This only limits the time needed to establish the connection. Once it's connected, this option doesn't apply anymore. Set it to0to disable the connection timeout entirely. ๐
On Unix-like systems, signals may be used unless -nosignal is enabled. โ ๏ธ
-connecttimeoutmsโ like-connecttimeout, but the value is in milliseconds. If libcurl is built to use the standard system name resolver, name resolution still uses full-second timeout granularity. Yeah, same caveat, different unit ๐ซถ-ipresolveโ picks which IP address families can be used when resolving host names. This only matters when a host name resolves to more than one IP version.
Accepted values are:
whateverโ the default. Resolves addresses using all IP versions supported by the system. ๐v4โ resolves only IPv4 addresses.v6โ resolves only IPv6 addresses.
-resolveโ pass a list of host name resolution entries to use for requests made with this handle.
Every entry has to use the format HOST:PORT:ADDRESS, where HOST is the name TclCurl tries to resolve, PORT is the destination service port, and ADDRESS is the numeric IP address to use. If libcurl supports IPv6, ADDRESS can be either an IPv4 or an IPv6 address. โจ
This option basically pre-populates the DNS cache with entries for a given HOST:PORT pair, so redirects and other requests to the same HOST:PORT use the ADDRESS you supplied. Iconic shortcut behavior ๐
To remove an entry from the DNS cache, include a string in the form -HOST:PORT. The host name must be prefixed with a dash, and both the host name and port have to exactly match an entry you added earlier. No partial matches, bestie ๐
-usesslโ selects the desired level of SSL or TLS use for the transfer. Relevant for protocols like FTP, SMTP, POP3, and IMAP.
You can also use ftps:// URLs to enable SSL/TLS explicitly for both the control connection and the data connection. Double the SSL, double the slay ๐
Accepted values:
nopeโ do not attempt to use SSL. Not today. ๐tryโ attempt to use SSL, but keep going even if it can't be negotiated.controlโ use SSL for the control connection, or fail withuse ssl failed(64). โ ๏ธallโ use SSL for all communication, or fail withuse ssl failed(64). โ ๏ธ
๐ SSL AND SECURITY OPTIONS ๐
okay bestie this is the one where we lock it DOWN. certificates, keys, handshakes, all the trust issues (the good kind). let's go ๐
-sslcertโ hands over a string with the file name of the certificate you wanna use. default format is PEM, and you can switch that up with-sslcerttype.
ngl, when libcurl is built against NSS, this value isn't a filename at all โ it's the nickname of the certificate to use for authentication. and if you genuinely want a file that's chillin in the current directory in that case, prefix it with ./ so nobody gets confused and thinks it's a nickname. ๐
-sslcerttypeโ passes a string saying what format the certificate from-sslcertis in.
accepted values, bestie:
PEMโ PEM format.DERโ DER format.
-sslkeyโ passes a string with the file name of the private key you wanna use. default format is PEM, and you can change it with-sslkeytype.-sslkeytypeโ passes a string saying what format the private key from-sslkeyis in.
accepted values:
PEMโ PEM format.DERโ DER format.ENGโ uses a crypto engine. in this case-sslkeygets interpreted as an identifier that gets passed to the engine, and-sslenginemust also be set.
NOTE: the DER private-key format may not work with some OpenSSL versions because of upstream limitations. like, not her fault, it's the upstream's fault fr. ๐ญ
-keypasswdโ passes a string with the passphrase needed to use the private key you specified with-sslkeyor-sshprivatekeyfile.
lowkey important: a passphrase isn't needed to load a certificate itself, but it may be needed to load the matching private key.
this option used to be known as -sslkeypasswd and -sslcertpasswd โ glow-up era โจ
-sslengineโ passes a string with the identifier of the crypto engine to use for private-key operations.
NOTE: if the crypto engine cannot be loaded, TclCurl returns an error. no engine, no vibes. ๐
-sslenginedefaultโ set this to1to make the selected crypto engine the default for asymmetric cryptographic operations.
NOTE: if the crypto engine cannot be made the default, TclCurl returns an error. periodt.
-sslversionโ picks the SSL or TLS protocol version to use. she's choosing her era ๐
accepted values:
defaultโ uses the default behavior. TclCurl attempts to negotiate an appropriate protocol version with the remote server.tlsv1โ requires TLSv1 or later.sslv2โ requires SSLv2.sslv3โ requires SSLv3.tlsv1_0โ requires TLSv1.0 or later.tlsv1_1โ requires TLSv1.1 or later.tlsv1_2โ requires TLSv1.2 or later.tlsv1_3โ requires TLSv1.3 or later.maxdefaultโ uses the maximum TLS version supported by libcurl or by the SSL backend's default configuration.maxtlsv1_0โ sets the maximum supported TLS version to TLSv1.0.maxtlsv1_1โ sets the maximum supported TLS version to TLSv1.1.maxtlsv1_2โ sets the maximum supported TLS version to TLSv1.2.maxtlsv1_3โ sets the maximum supported TLS version to TLSv1.3.
-sslverifypeerโ controls whether TclCurl verifies the authenticity of the peer certificate. set it to1to turn verification on, or0to turn it off. default is1. ๐
during the SSL or TLS handshake, the server sends a certificate declaring its identity. TclCurl verifies that certificate against a chain of trust rooted in one or more certification authority (CA) certificates.
TclCurl uses the default CA bundle that libcurl provides, but you can hand it alternate certificates with -cainfo or -capath.
if -sslverifypeer is nonzero and the verification fails, the connection fails. if this option is 0, peer-certificate verification gets skipped.
heads up bestie: certificate verification on its own does NOT confirm that the peer is the specific host you meant to contact. use -sslverifyhost if you wanna control host-name verification.
-cainfoโ passes the name of a file holding one or more CA certificates used to verify the peer certificate.
this option is meaningful primarily together with -sslverifypeer. if peer verification is disabled, -cainfo doesn't need to name an accessible file.
by default, this option is set to the system path of libcurl's CA bundle, as determined when libcurl was built.
when libcurl is built against NSS, this value refers to the directory containing the NSS certificate database. ๐๏ธ
-issuercertโ passes the name of a file containing a CA certificate in PEM format. if this option is set, an extra check happens to verify that the peer certificate was issued by the CA certificate you provided here.
this is useful in multi-level PKI environments where the peer certificate has to be constrained to a specific branch of the certificate hierarchy. like, staying in your lane, but for certs ๐ณ
this option is meaningful only when used together with -sslverifypeer. otherwise, if this additional check fails, it's not treated as a connection failure.
-capathโ passes the name of a directory containing multiple CA certificates to use when verifying the peer certificate.
when libcurl is built against OpenSSL, this directory must be prepared with the openssl c_rehash utility. this option is meaningful primarily together with -sslverifypeer. if peer verification is disabled, -capath doesn't need to name an accessible directory.
this option is OpenSSL-specific and has no effect when libcurl is built against GnuTLS. NSS-based libcurl provides it only for backward compatibility.
on Windows, this option may not work because of OpenSSL limitations. sorry windows girlies ๐ญ
-crlfileโ passes the name of a file containing one or more certificate revocation lists in PEM format to use during certificate validation.
when libcurl is built against NSS or GnuTLS, there's no supported way to influence revocation checking with this option. when libcurl is built with OpenSSL support, both X509_V_FLAG_CRL_CHECK and X509_V_FLAG_CRL_CHECK_ALL are enabled if a CRL file is provided, so CRL checking is applied throughout the certificate chain.
this option is meaningful only when used together with -sslverifypeer.
if the CRL file cannot be loaded, the SSL exchange fails with the specific error code CURLE_SSL_CRL_BADFILE. a certificate-verification failure caused by revocation information in the CRL does not produce that specific error code. two different problems, two different error codes, don't mix them up bestie ๐
-sslverifyhostโ controls whether TclCurl verifies that the server certificate matches the host name you intended to contact.
during the SSL or TLS handshake, the server sends a certificate declaring its identity.
when -sslverifyhost is set to 2, the certificate must identify the intended server or the connection fails. TclCurl considers the server a match when the Common Name field or a Subject Alternative Name field in the certificate matches the host name in the URL.
when this option is set to 1, the certificate must contain a Common Name field, but the specific name is not checked. this setting is generally not useful, ngl.
when this option is set to 0, the connection succeeds regardless of the names contained in the certificate. ๐
default value is 2.
this option verifies the host identity the certificate claims. if you wanna verify that the certificate itself is trusted, use -sslverifypeer. and one more thing: if libcurl is built against NSS and -sslverifypeer is 0, then -sslverifyhost is ignored. she said nothing, she's not participating. ๐
-certinfoโ set this to1to enable collection of certificate-chain information. when it's enabled, TclCurl โ if built against OpenSSL โ extracts certificate details from the chain used in the SSL connection.
you can pull that info back out after the transfer with the getinfo command and its certinfo option. โจ
-randomfileโ passes a file name. TclCurl uses this file as a source of randomness for the SSL random engine.
this option was deprecated in libcurl v7.84 and is disabled by default in the TclCurl build. see README.md for instructions on how to re-enable it. she's retired but not gone gone.
-egdsocketโ passes the path name of an Entropy Gathering Daemon socket. TclCurl uses it as a source of randomness for the SSL random engine.
this option was deprecated in libcurl v7.84 and is disabled by default in the TclCurl build. see README.md for instructions on how to re-enable it. same retired queen energy ๐
-sslcipherlistโ passes a string with the cipher list to use for the SSL or TLS connection. the list is made of one or more cipher strings separated normally by colons, although commas or spaces are also accepted. the characters!,-, and+may also be used as operators.
with OpenSSL and GnuTLS, valid examples include RC4-SHA, SHA1+DES, TLSv1, and DEFAULT. the default list is usually defined by the SSL backend at build time.
with NSS, valid examples include rsa_rc4_128_md5 and rsa_aes_128_sha. NSS does not support incremental add or remove semantics for ciphers. if this option is used, all known ciphers are disabled and only the ciphers listed here are enabled. all or nothing, no in-between ๐
for details about cipher-list syntax, see: http://www.openssl.org/docs/apps/ciphers.html
for NSS-specific cipher-list details, see: http://directory.fedora.redhat.com/docs/mod_nss.html
-sslsessionidcacheโ set this to0to disable TclCurl's use of SSL session-ID caching, or to1to enable it. default is1.
in normal circumstances, reusing SSL session IDs is harmless and may improve performance. however, some broken SSL implementations may require this option to be disabled. (broken behavior found, we're working around it ๐ซถ)
-krblevelโ picks the Kerberos security level for FTP and thereby also enables Kerberos awareness.
accepted values are clear, safe, confidential, and private. if the string doesn't match one of these values, private is used.
set the string to NULL to disable Kerberos 4. set it to "" to disable Kerberos support for FTP. two different empties, two different meanings, wild fr fr.
-gssapidelegationโ picks the GSSAPI credential delegation mode.
accepted values:
flagโ allows unconditional delegation.policyflagโ delegates only if the OK-AS-DELEGATE flag is set in the service ticket, provided that this feature is supported by the GSSAPI implementation and thatGSS_C_DELEG_POLICY_FLAGwas available at compile time.
delegation is disabled by default since 7.21.7.
๐ SSH OPTIONS ๐
-sshauthtypes ๐
okay so this one selects the allowed SSH authentication types. like you're telling TclCurl which glow-up method the server is allowed to use to prove it's them โจ
Accepted values are:
publickeyโ use public-key authentication ๐passwordโ use password authentication ๐คซhostโ use host-based authentication ๐keyboardโ use keyboard-interactive authentication โจ๏ธanyโ let TclCurl pick an authentication method automatically, no stress, it's got this ๐
-sshhostpublickeymd5
pass a string with 32 hexadecimal digits. that string has to be the 128-bit MD5 checksum of the remote host public key. if the checksum doesn't match, TclCurl rejects the connection, periodt ๐ โโ๏ธ
heads up bestie: this option applies only to SCP and SFTP transfers. fr fr.
-sshpublickeyfile
pass the file name of the public key to use ๐๏ธ
if you don't set this option, TclCurl defaults to $HOME/.ssh/id_dsa.pub when the HOME environment variable is set, and to id_dsa.pub in the current directory otherwise ๐ซถ
-sshprivatekeyfile
pass the file name of the private key to use ๐
if you don't set this option, TclCurl defaults to $HOME/.ssh/id_dsa when the HOME environment variable is set, and to id_dsa in the current directory otherwise ๐
if your private key is passphrase-protected, use -keypasswd to hand over the passphrase. iykyk ๐
-sshknownhosts
pass a string containing the file name of the known_hosts file you wanna use ๐ the file must use the OpenSSH known_hosts format that libssh2 supports.
if this option is set, TclCurl accepts connections only to hosts that are present in that file with a matching public key โจ
want to override the default behavior for host and key matching? use -sshkeyproc, that's literally what it's for ๐
-sshkeyproc
pass the name of a callback procedure that TclCurl invokes after known_hosts matching has been performed, so your app can decide how the connection should proceed ๐
the callback is invoked only if -sshknownhosts is also set. no known_hosts, no callback, that's the vibe check.
the callback receives a list with three elements:
- a list containing the key type from the
known_hostsfile and the key itself ๐ - a list containing the key type presented by the remote host and the key itself ๐
- a value describing TclCurl's matching result ๐ง
possible key-type values are rsa, rsa1, dss, and unknown.
possible match-result values are match, mismatch, missing, and error.
Return values:
0โ accept the host and key. TclCurl appends the host and key to theknown_hostsfile before continuing with the connection. If the host and key are not already present in the in-memory known-hosts pool, TclCurl also adds them there. updating the file is done by replacing it with a new copy, so the file permissions must allow that โ ๏ธ1โ accept the host and key, and continue with the connection. If the host and key are not already present in the in-memory known-hosts pool, TclCurl also adds them there โจ2โ reject the host and key. TclCurl closes the connection ๐3โ reject the host and key, but keep the SSH connection alive ๐ค this can be useful if the application needs to inspect the host or key state and then retry without incurring the full setup cost again.- any other return value causes TclCurl to close the connection ๐
โจ OTHER OPTIONS โจ
-headervar
name of the Tcl array variable where TclCurl stores the headers returned by the server ๐ฌ
-bodyvar
name of the Tcl variable where TclCurl stores the requested file contents ๐ฅ the stored data may be either text or binary data, so whatever comes through, it's coming through.
-canceltransvarname
name of a Tcl variable used together with -progressproc ๐ if the progress callback sets this variable to 1, the transfer is canceled. that's the whole deal, iconic.
-command
executes the given command after the transfer has completed ๐ฌ
ngl: this option works only with blocking transfers, and therefore has limited practical use. like, it's giving niche.
-share
pass a share handle ๐ซ the share handle must have been created previously by calling curl::shareinit.
setting this option causes the easy handle to use data from the shared handle instead of keeping its own separate copy. see tclcurl_share for details ๐ซถ
-newfileperms
pass a numeric value specifying the permissions assigned to newly created files on the remote server ๐ the default value is 0644, but any valid value may be used.
this option applies only tosftp://,scp://, andfile://transfers ๐ฆ
-newdirectoryperms
pass a numeric value specifying the permissions assigned to newly created directories on the remote server ๐ the default value is 0755, but any valid value may be used.
this option applies only tosftp://,scp://, andfile://transfers ๐ฆ
๐ก TELNET OPTIONS ๐ก
-telnetoptions
pass a list with variables to pass to the telnet negotiations ๐ค the variables should be in the format .
TclCurl supports the options 'TTYPE', 'XDISPLOC' and 'NEW_ENV'. see the TELNET standard for details ๐
๐ NOT SUPPORTED ๐
some of the options libcurl offers are not supported. the author doesn't think them worth supporting in TclCurl, but if you need one of them, don't forget to complain ๐ฃ
CURLOPT_FRESH_CONNECT, CURLOPT_FORBID_REUSE, CURLOPT_PRIVATE,
CURLOPT_SSL_CTX_FUNCTION, CURLOPT_SSL_CTX_DATA, CURLOPT_SSL_CTX_FUNCTION and
CURLOPT_CONNECT_ONLY, CURLOPT_OPENSOCKETFUNCTION, CURLOPT_OPENSOCKETDATA.
๐ curlHandle perform ๐
Okay bestie, this procedure is called after init and all the configure calls are made, and it will perform the transfer exactly as described in the options. ๐
It must be called with the same curlHandle that curl::init returned. You can do any amount of calls to perform while using the same handle. If you intend to transfer more than one file, you are even encouraged to do so. TclCurl 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 configure between the invokes to set options for the following perform. ๐
๐จ You must never call this procedure simultaneously from two places using the same handle. Let it return first before invoking it another time. If you want parallel transfers, you must use several curl handles. Periodt. ๐
โจ RETURN VALUE โจ
0 if all went well, non-zero if it didnโt. In case of error, if the errorbuffer was set with configure, there will be a readable error message. The error codes are:
1โ Unsupported protocol. This build of TclCurl has no support for this protocol. ๐ซ2โ The very early initialization code failed. This is likely to be an internal error or a resource problem where something fundamental couldnโt get done at init time. ๐ญ3โ URL malformat. The syntax was not correct. ๐4โ A requested feature, protocol, or option was not found built-in in this libcurl due to a build-time decision. This means that a feature or option was not enabled or explicitly disabled when libcurl was built, and in order to get it to function you have to get a rebuilt libcurl. ๐ ๏ธ5โ Couldnโt resolve proxy. The given proxy host could not be resolved. ๐6โ Couldnโt resolve host. The given remote host was not resolved. ๐ต7โ Failed to connect to host or proxy. ๐8โ FTP weird server reply. The server sent data TclCurl couldnโt parse. The given remote server is probably not an OK FTP server. ๐ฉ9โ We were denied access to the resource given in the URL. For FTP, this occurs while trying to change to the remote directory. โ11โ FTP weird PASS reply. TclCurl couldnโt parse the reply sent to the PASS request. ๐ฌ13โ FTP weird PASV reply. TclCurl couldnโt parse the reply sent to the PASV or EPSV request. ๐14โ FTP weird 227 format. TclCurl couldnโt parse the 227-line the server sent. ๐15โ FTP canโt get host. Couldnโt resolve the host IP we got in the 227-line. ๐17โ FTP couldnโt set type. Couldnโt change transfer method to either binary or ascii. ๐18โ Partial file. Only a part of the file was transferred. This happens when the server first reports an expected transfer size and then delivers data that doesnโt match the given size. ๐ช19โ FTP couldnโt RETR file; we either got a weird reply to aRETRcommand or a zero byte transfer. ๐21โ Quote error. A customQUOTEreturned error code 400 or higher (for FTP) or otherwise indicated unsuccessful completion of the command. ๐22โ HTTP returned error. This return code only appears if-failonerroris used and the HTTP server returns an error code that is 400 or higher. ๐จ23โ Write error. TclCurl couldnโt write data to a local filesystem or an error was returned from a write callback. โ๏ธโ25โ Failed upload failed. For FTP, the server typically denied theSTORcommand. The error buffer usually contains the serverโs explanation to this. ๐ค๐26โ Read error. There was a problem reading from a local file or an error was returned from the read callback. ๐โ27โ Out of memory. A memory allocation request failed. This should never happen unless something weird is going on in your computer. ๐พ28โ Operation timeout. The specified time-out period was reached according to the conditions. โฐ30โ The FTPPORTcommand failed. Not all FTP servers support thePORTcommand; try doing a transfer using PASV instead! ๐31โ FTP couldnโt use REST. This command is used for resumed FTP transfers. โฏ๏ธ33โ Range error. The server doesnโt support or accept range requests. ๐34โ HTTP post error. Internal post-request generation error. ๐ฎ35โ SSL connect error. The SSL handshaking failed; the error buffer may have a clue to the reason, could be certificates, passwords, โฆ ๐36โ The download could not be resumed because the specified offset was out of the file boundary. ๐ง37โ A file given withFILE://couldnโt be read. Did you check the permissions? ๐38โ LDAP cannot bind. LDAP bind operation failed. ๐ชข39โ LDAP search failed. ๐๐41โ A required zlib function was not found. ๐๏ธ42โ Aborted by callback. An application told TclCurl to abort the operation. โ43โ Internal error. A function was called with a bad parameter. ๐ฉ45โ Interface error. A specified outgoing interface could not be used. ๐47โ Too many redirects. When following redirects, TclCurl hit the maximum amount; set your limit withโmaxredirs. ๐48โ An option passed to TclCurl is not recognized/known. Refer to the appropriate documentation. This is most likely a problem in the program that uses TclCurl. The error buffer might contain more specific information about which exact option it concerns. ๐ค49โ A telnet option string was illegally formatted. ๐51โ The remote peerโs SSL certificate or SSH md5 fingerprint wasnโt ok. ๐ซ๐52โ The server didnโt reply anything, which here is considered an error. ๐ค53โ The specified crypto engine wasnโt found. ๐๐54โ Failed setting the selected SSL crypto engine as default! ๐ฅ55โ Failed sending network data. ๐ก๐56โ Failure with receiving network data. ๐ฅ๐58โ Problem with the local client certificate. ๐59โ Couldnโt use specified SSL cipher. ๐60โ Peer certificate cannot be authenticated with known CA certificates. ๐ง61โ Unrecognized transfer encoding. ๐คท62โ Invalid LDAP URL. ๐63โ Maximum file size exceeded. ๐64โ SSL use failed. ๐65โ Sending the data requires a rewind that failed. Since TclCurl should take care of it for you, it means you found a bug. ๐66โ Failed to initialise ssl engine. ๐ง67โ Failed to login; user password or similar was not accepted. ๐ช68โ File not found on TFTP server. ๐โ69โ There is a permission problem with the TFTP request. ๐70โ The remote server has run out of space. ๐๏ธ๐ฅ71โ Illegal TFTP operation. ๐ซ72โ Unknown transfer ID. ๐73โ TFTP file already exists and will not be overwritten. ๐74โ No such user in the TFTP server, and good behaving TFTP servers should never return this. ๐75โ Character conversion failed. ๐ค77โ Problem with reading the SSL CA cert (path? access rights?). ๐78โ Remote file not found. ๐ญ79โ Error from the SSH layer. ๐80โ Failed to shut down the SSL connection. ๐82โ Failed to load CRL file. ๐83โ Issuer check failed. ๐ต๏ธ84โ The FTP server does not understand thePRETcommand at all or does not support the given argument. Be careful when using-customrequest; a customLISTcommand will be sent withPRET CMDbeforePASVas well. โ ๏ธ85โ Mismatch of RTSP CSeq numbers. ๐ข86โ Mismatch of RTSP Session Identifiers. ๐ชช87โ Unable to parse FTP file list (during FTP wildcard downloading). ๐88โ Chunk callback reported error. ๐งฉ
โจ curlHandle getinfo OPTION โจ
Okay bestie, this one is literally the โจteaโจ procedure โ it goes and digs up the internal lore from your curl session. One thing though: you call this AFTER a transfer has been performed, and you can only fr fr trust what it tells you if the perform came back 0. So like, use it after a transfer when you want transfer-flavoured data. ๐
Here's everything you can extract, no gatekeeping:
effectiveurlโ the last effective URL that got used. The final form, the glow-up version. ๐responsecodeโ the last HTTP or FTP code you received. Heads up: it's zero if no server response code came in at all. And important โ if you want a proxy'sCONNECTresponse, that'shttpconnectcode, NOT this one, k? Don't mix them up, bestie, that's a vibe check fail. ๐httpconnectcodeโ the last received proxy response code to aCONNECTrequest. Yep, this is the one for that.filetimeโ the remote time of the retrieved document, in seconds since 1 Jan 1970 in GMT/UTC. If you get-1, it could be for a whole bunch of reasons (unknown, the server is being sneaky and hiding it, the server doesn't support the command that reports document time, etc etc) โ basically the time of the document is a mystery. ๐ต๏ธ
For this to even work you HAVE to set the -filetime option before the transfer. No setting, no info. Periodt.
namelookuptimeโ how many seconds it took, from the start, until name resolving was done. ๐ฆconnecttimeโ seconds from the start until the connect to the remote host (or proxy) completed.appconnecttimeโ seconds from the start until the SSL/SSH connect/handshake to the remote host completed. This one is usually super close to the PRETRANSFER time, except in cases like HTTP pipelining where pretransfer can get delayed from waiting in line for the pipeline and more. (yes the original says "pippelining", love that for it ๐ญ)pretransfertimeโ seconds from the start until the file transfer is just about to begin. This includes all the pre-transfer commands and negotiations that are specific to the protocol(s) in play.starttransfertimeโ seconds from the start until the first byte is just about to be transferred. Includespretransfertime, plus the time the server needs to calculate the result. Math girlies stay winning. ๐ฅtotaltimeโ the total transaction time, in seconds, for the previous transfer, including name resolving, TCP connect, all of it.redirecturlโ the URL a redirect would take you to if you enablefollowlocation. This is highkey handy if you think the built-in libcurl redirect logic isn't good enough for you, but you'd still rather avoid implementing all the โจmagicโจ of figuring out the new URL yourself.redirecttimeโ the total time, in seconds, for all the redirection steps including name lookup, connect, pretransfer and transfer, before the final transaction started. It gives you the complete execution time for multiple redirections โ so it returns zero if no redirections were needed at all. ๐redirectcountโ the total number of redirections that were actually followed.numconnectsโ how many new connections TclCurl had to create to pull off the previous transfer (only the successful connects get counted, we're not counting flops). Combine it withredirectcountand you can figure out how many times TclCurl successfully reused existing connection(s) or didn't. See the Connection Options ofsetoptto see how TclCurl tries to make persistent connections to save time. โญprimaryipโ the IP address of the most recent connection made with this handle. This string can be IPv6 if that's enabled, slay.primaryportโ the destination port of the most recent connection made with this handle.localipโ the local (source) IP address of the most recent connection made with this handle. Also IPv6-able if enabled. ๐localportโ the local (source) port of the most recent connection made with this handle.sizeuploadโ the total amount of bytes that were uploaded.sizedownloadโ the total amount of bytes that were downloaded. Note: this is only for the latest transfer and gets reset again for each new transfer, so don't expect it to accumulate, bestie.speeddownloadโ the average download speed, measured in bytes/second, for the complete download.speeduploadโ the average upload speed, measured in bytes/second, for the complete upload.headersizeโ the total size in bytes of all the headers received.requestsizeโ the total size of the issued requests. So far this is only for HTTP requests. And heads up: this may be more than one request iffollowLocationis true. ๐ซถsslverifyresultโ the result of the certification verification that was requested (configured using the-sslverifypeeroption).sslenginesโ a list of the OpenSSL crypto-engines supported. Note that engines are normally implemented in separate dynamic libraries, so not all the returned engines may actually be available at run-time.contentlengthdownloadโ the content-length of the download. This is the value read from theContent-Length:field. If the size isn't known, it returns-1.contentlengthuploadโ the specified size of the upload.contenttypeโ the content-type of the downloaded object, i.e. the value read from theContent-Type:field. If you get an empty string, it means either the server didn't send a validContent-Typeheader OR the protocol used doesn't support this. Either way, not its fault. ๐httpauthavailโ a list with the authentication method(s) available.proxyauthavailโ a list with the authentication method(s) available for your proxy athentication. (their typo, not mine ๐)oserrnoโ theerrnovalue from a connect failure. This value is only set on failure โ it is not reset after a successful operation, so don't be reading it after a win.cookielistโ a list of ALL the cookies TclCurl knows about (expired ones too, we include everyone). If there are no cookies โ either cookies for the handle haven't been enabled or simply none have been received โ the list will be empty. ๐ftpentrypathโ a string holding the path of the entry path. That's the initial path TclCurl ended up in when logging on to the remote FTP server. Returns an empty string if something is wrong.certinfoโ a list with info about the certificate chain, assuming you had the-certinfooption enabled when the previous request was done. The first item of the list reports how many certs it found, and then you can extract info for each of those certs by following the list. The info chain comes as a series of data in the format"name:content"where the content is for that specific named data. ๐
NOTE: this option is only available in libcurl built with OpenSSL support. No OpenSSL, no certinfo, sorry bestie. ๐
conditionunmetโ returns the number1if the condition provided in the previous request didn't match (seetimecondition), and you'll get a zero if the condition instead was met.
๐ธ curlHandle cleanup ๐ธ
This procedure has to be the last one you call for a curl session. It's literally the opposite of the curl::init procedure, and you must call it with the same curlhandle as input that the curl::init call returned. It effectively closes all connections TclCurl has used and possibly kept open until now. ๐ซถ
Don't call this procedure if you intend to transfer more files. Do NOT. It's giving closed-for-business and there's no reopening. ๐ญ
๐ฆ curlHandle reset ๐ฆ
Re-initializes all options previously set on a specified handle right back to the default values.
This puts the handle back to the exact same state it was in when it was just created with curl::init. Fresh out the box energy. โจ
It does not change the following info kept in the handle:
- live connections
- the Session ID cache
- the DNS cache
- the cookies and shares
๐ curlHandle duphandle ๐
This procedure returns a new curl handle โ a duplicate โ using all the options previously set in the input curl handle. Both handles can then be used independently, and they must both be freed with cleanup. Two queens, two cleanups. ๐
The new handle will not inherit any state information, connections, SSL sessions or cookies.
RETURN VALUE
A new curl handle, or an error message if the copy fails. ๐
โญ curlHandle pause โญ
You can use this command from within a progress callback procedure to pause the transfer. Hit the pause button, bestie. โ
โญ curlHandle resume โญ
Resumes a transfer paused with curlhandle pause. And we're back. ๐ฅ
๐ curl::transfer ๐
In case you do not want to use persistent connections, you can use this command โ it takes the same arguments as the curlHandle configure and will init, configure, perform and cleanup a connection for you. One-stop shop, main character energy. ๐
You can also get the getinfo information by using -infooption variable pairs, after the transfer variable will contain the value that would have been returned by $curlHandle getinfo option.
RETURN VALUE
The same error code perform would return.
๐ curl::version ๐
Returns a string with the version number of tclcurl, libcurl and some of its important components (like the OpenSSL version).
RETURN VALUE
The string with the version info.
๐ง curl::escape URL ๐ง
This procedure converts the given input string to a URL encoded string and returns that. All input characters that are not a-z, A-Z or 0-9 will be converted to their "URL escaped" version (%NN where NN is a two-digit hexadecimal number). Very demure, very encoded. ๐
RETURN VALUE
The converted string.
๐ฆ curl::unescape URL ๐ฆ
This procedure converts the given URL encoded input string to a "plain string" and returns that. All input characters that are URL encoded (%XX where XX is a two-digit hexadecimal number) will be converted to their plain text versions. The decoding arc. โจ
RETURN VALUE
The string unencoded.
๐ธ curl::curlConfig OPTION ๐ธ
Returns some info about how you have cURL installed. Tell me everything, king. ๐
-prefixโ returns the directory root where you installed cURL.-featureโ returns a list containing particular main features the installed libcurl was built with. The list may includeSSL,KRB4orIPv6โ do not assume any particular order, it's a chaotic lil list. ๐-vernumโ outputs version information about the installed libcurl, in numerical mode. This outputs the version number, in hexadecimal, with 8 bits for each part: major, minor, patch. So that libcurl7.7.4would appear as070704and libcurl12.13.14would appear as0c0d0eโฆ ๐งฎ
๐ฆ curl::versioninfo OPTION
Okay bestie, this one is your little spy into what your TclCurl actually is at runtime ๐ It hands back the deets about all the various run-time features of TclCurl.
And here's the part that's actually important, so listen up: apps should use this info to figure out whether something is possible or not, instead of doing compile-time checks. Why? Because dynamic/DLL libraries can be swapped out independently of the applications that use them. So likeโฆ your app can't just assume, okay? It has to ask. โจ
-versionโ tells you the version of libcurl you're using. Slay.-versionnumโ gives you that same libcurl version in hexadecimal, 8 bits for each part: major, minor, patch. So7.7.4would show up as070704, and a hypothetical12.13.14would show up as0c0d0eโฆ also, heads up, the initial zero might just be omitted. ๐-hostโ a string with the host info, as discovered by a configure script or as set by the build environment.-featuresโ a list of the features compiled into libcurl! The possible elements are:ASYNCHDNSโ libcurl was built with support for asynchronous name lookups, which allows more exact timeouts (even on Windows) and less blocking when using the multi interface. ๐CONVโ libcurl was built with support for character conversions.DEBUGโ libcurl was built with extra debug capabilities built in. This is mainly of interest for libcurl hackers. ๐งGSSNEGOTIATEโ supports HTTP GSS-Negotiate.IDNโ supports IDNA, domain names with international letters. ๐IPV6โ supports IPv6.KERBEROS4โ supports kerberos4 (when using FTP).LARGEFILEโ libcurl was built with support for large files.LIBZโ supports HTTP deflate using libz.NTMLโ supports HTTP NTLM.SPNEGOโ libcurl was built with support for SPNEGO authentication (Simple and Protected GSS-API Negotiation Mechanism, defined in RFC 2478).SSLโ supports SSL (HTTPS/FTPS). ๐ฅSSPIโ libcurl was built with support for SSPI. This is only available on Windows and makes libcurl use Windows-provided functions for NTLM authentication. It also allows libcurl to use the current user and the current user's password without the app having to pass them on.TLSAUTH_SRPโ libcurl was built with support for TLS-SRP.NTLM_WBโ libcurl was built with support for NTLM delegation to a winbind helper.
And fr fr, do not assume any particular order. The list is a vibe, not a sequence. ๐ญ
-sslversionโ a string with the OpenSSL version used, likeOpenSSL/0.9.6b.-sslversionnumโ the numerical OpenSSL version value as defined by the OpenSSL project. If libcurl has no SSL support, this is0.-libzversionโ a string (there's no numerical version for this one), for example:1.1.3.-protocolsโ lists what particular protocols the installed TclCurl was built to support. At the time of writing, this list may includeHTTP,HTTPS,FTP,FTPS,FILE,TELNET,LDAP,DICT. Also do not assume any particular order here either, bestie. The protocols will be listed using uppercase, and there may be none, one, or several protocols in the list. ๐
๐ curl::easystrerror errorCode
This procedure returns a string describing the error code passed in the argument. That's it, that's the whole thing โ you hand it an error code, it hands you back words that make sense of it. ๐ซถ
โจ EXAMPLES โจ
The examples in this section assume you are running from the root of the TclCurl source tree. (Yes, root. Go stand there. ๐)
To start the local HTTP test server used in the examples, run:
tclsh testservers/testserver.tcl
By default, this starts an HTTP server on http://127.0.0.1:8990/. ๐ธ
The path http://127.0.0.1:8990/tclcurl-man returns the HTML version of this manual page from doc/tclcurl.html, which makes it a super convenient target for a basic GET example. No cap. โจ
๐ BASIC HTTP GET
The file examples/http_get.tcl contains a minimal HTTP GET example. It performs a simple request, stores the response body in a Tcl variable, and prints both the HTTP response code and the size of the returned document. Main character behavior, honestly. ๐
If the request succeeds, rc is 0, responsecode is 200, and body contains the HTML document returned by the server. Periodt. ๐
๐ AUTHORS
- Andres Garcia Garcia
- Massimo Manghi
๐ SEE ALSO
curl- The art of HTTP scripting (at
http://curl.haxx.se) RFC 2396
aaaand that's the whole page, bestie!! ๐ You just read all of TclCurl(n) โ from TclCurl 8.0.3, dated 15 May 2026. Go forth and curl responsibly, you absolute icon. ๐ฆ๐โจ
๐ฆ where this page comes from
- ubuntu stonking: tclcurl 8.0.3-1
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms