TclCurl

Section: TclCurl Easy Interface (n)
Updated: 3 September 2003
Index  

NAME

TclCurl: - get a URL with FTP, TELNET, LDAP, GOPHER, DICT, FILE, HTTP or HTTPS syntax.  

SYNOPSIS

curl::init

curlHandle configure ?options?

curlHandle perform

curlHandle duhandle

curlHandle getinfo curlinfo_option

curlhandle cleanup

curl::transfer ?options?

curl::version

curl::escape url

curl::unescape url

curl::curlConfig option

curl::versioninfo option

 

DESCRIPTION

The TclCurl extension gives Tcl programmers access to the libcurl library written by Daniel Stenberg, with it you can download urls, upload them and many other neat tricks, for more information check cURL's web site  

curl::init

This procedure must be the first one to call, it returns a curlHandle that you need to use to invoke TclCurl procedures. The init calls intializes curl and this call MUST have a corresponding call to cleanup when the operation is completed. You should perform all your sequential file transfers using the same curlHandle. This enables TclCurl to use persistant connections when possible.

RETURN VALUE

curlHandle to use.  

curlHandle configure ?options?

configure is called to set the options for the transfer. Most operations in TclCurl have default actions, and by using the appropriate options you can make them behave differently (as documented). All options are set with the option followed by a parameter.

Notes: the options set with this procedure are valid for the forthcoming data transfers that are 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.

curlHandle is the return code from the curl::init call.

 

Behaviour options

-verbose
Set the parameter to non-zero to get the library to display a lot of verbose information about its operations. Very useful for libcurl and/or protocol debugging and understanding.

You hardly ever want this set in production use, you will almost always want this when you debug/report problems. Another neat option for debugging is -debugproc

-header
A non-zero parameter tells the extension to include the headers in the body output. This is only relevant for protocols that actually have headers preceding the data (like HTTP).

-noprogress
A non-zero parameter tells the extension to turn on the built-in progress meter. Nowadays it is turn off by default.

-nosignal
A non zero parameter tells TclCurl not use any functions that install signal handlers or any functions that cause signals to be sent to the process. This option is mainly here to allow multi-threaded unix applications to still set/use all timeout options etc, without risking getting signals.

 

Callback options

-writeproc
Use it to set a Tcl procedure that will be invoked by TclCurl as soon as there is received data that needs to be saved. The procedure will receive a single parameter with the data to be saved.

-file
File in which the transfered data will be saved.

-readproc
Sets a Tcl procedure to be called by TclCurl as soon as it needs to read data in order to send it to the peer. The procedure has to take one parameter, which will contain the maximun numbers of bytes to read. It should return the actual number of bytes read, or '0' if you want to stop the transfer.

-infile
File from which the data will be transfered.

-progressproc
Name of the Tcl procedure that will invoked by TclCurl whenever there is new data, the prototype of the procedure must be:

proc ProgressCallback {dltotal dlnow ultotal ulnow}

In order to this option to work you have to set the noprogress option to '0'. Setting this option to the empty string will restore the original progress function.

-writeheader
Pass a the file name to be used to write the header part of the received data to. The headers are guaranteed to be written one-by-one to this file and only complete lines are written. Parsing headers should be easy enough using this.

-debugproc
Name of the procedure that will receive the debug data produced by the -verbose option, it should match the following prototype:

debugProc {infoType data}

where infoType specifies what kind of information it is (0 text, 1 incoming header, 2 outgoing header, 3 incoming data, 4 outgoing data).

 

Error Options

-errorbuffer
Pass a variable name where TclCurl may store human readable error messages in. This may be more helpful than just the return code from the command.

-stderr
Pass a file name as parameter. This is the stream to use internally instead of stderr when reporting errors.
-failonerror
A non-zero parameter tells the extension to fail silently if the HTTP code returned is equal or larger than 300. The default action would be to return the page normally, ignoring that code.

 

Network options

-url
The actual URL to deal with.

NOTE: this the one option required to be set before perform is called.

-proxy
If you need to use a http proxy to access the outside world, set the proxy string with this option. To specify port number in this string, append :[port] to the end of the host name. The proxy string may be prefixed with [protocol]:// since any such prefix will be ignored.

NOTE: when you tell the extension to use a HTTP proxy, TclCurl will transparently convert operations to HTTP even if you specify a FTP URL etc. This may have an impact on what other features of the library you can use, such as quote and similar FTP specifics that will not work unless you tunnel through the HTTP proxy. Such tunneling is activated with proxytunnel

NOTE2: TclCurl respects the environment variables http_proxy, ftp_proxy, all_proxy etc, if any of those are set.

-proxyport
Use this option to set the proxy port to use unless it is specified in the proxy string by -proxy.

-proxytype
Pass the type of the proxy. Available options are 'http' and 'socks5', with the HTTP one being default.

-httpproxytunnel
Set the parameter to non-zero to get the extension to tunnel all non-HTTP operations through the given HTTP proxy. Do note that there is a big difference between using a proxy and tunneling through it. If you don't know what this means, you probably don't want this tunnel option.

-interface
Pass the interface name to use as outgoing network interface. The name can be an interface name, an IP address or a host name.

-dnscachetimeout
Pass the timeout in seconds. Name resolves will be kept in memory for this number of seconds. Set to '0' to completely disable caching, or '-1' to make the cached entries remain forever. By default, TclCurl caches info for 60 seconds.

-dnsuseglobalcache
If the value passed is non-zero, it tells TclCurl to use a global DNS cache that will survive between curl handles creations and deletions. This is not thread-safe as it uses a global varible.

-buffersize
Pass your prefered size for the receive buffer in TclCurl. The main point of this would be that the write callback gets called more often and with smaller chunks. This is just treated as a request, not an order. You cannot be guaranteed to actually get the given size.

 

Names and Passwords options

-netrc
A non-zero parameter tells the extension to scan your ~/.netrc file to find user name and password for the remote site you are about to access. Do note that TclCurl does not verify that the file has the correct properties set (as the standard unix ftp client does), and that only machine name, user name and password is taken into account (init macros and similar things are not supported).

You can set it to the following values:

optional
The use of your ~/.netrc file is optional, and information in the URL is to be preferred. The file will be scanned with the host and user name (to find the password only) or with the host only, to find the first user name and password after that machine, which ever information is not specified in the URL.

Undefined values of the option will have this effect.

ignored
The extension will ignore the file and use only the information in the URL. This is the default.
required
This value tells the library that use of the file is required, to ignore the information in the URL, and to search the file with the host only.

-userpwd
Pass a string as parameter, which should be [username]:[password] to use for the connection.

When using HTTP and -followlocation, TclCurl might perform several requests to possibly different hosts. TclCurl will only send this user and password information to hosts using the initial host name (unless -unrestrictedauth is set), so if TclCurl follows locations to other hosts it will not send the user and password to those. This is enforced to prevent accidental information leakage.

-proxyuserpwd
Pass a string as parameter, which should be [username]:[password] to use for the connection to the HTTP proxy.

-httpauth
Set to the authentication method you want, the available ones are:
basic
HTTP Basic authentication. This is the default choice, and the only method that is in widespread use and supported virtually everywhere. It sends the user name and password over the network in plain text, easily captured by others.

digest
HTTP Digest authentication. Digest authentication is a more secure way to do authentication over public networks than the regular old-fashioned Basic method.

gssnegotiate
HTTP GSS-Negotiate authentication. The GSS-Negotiate method was designed by Microsoft and is used in their web aplications. It is primarily meant as a support for Kerberos5 authentication but may be also used along with another authentication methods.

ntlm
HTTP NTLM authentication. A proprietary protocol invented and used by Microsoft.

any
TclCurl will automaticaly select the one it finds most secure.

anysafe
It may use anything but basic, TclCurl will automaticly select the one it finds most secure.

 

HTTP options

-encoding
Sets the contents of the Accept-Encoding: header sent in an HTTP request, and enables decoding of a response when a Content-Encoding: header is received. Three encodings are supported: identity, which does nothing, deflate which requests the server to compress its response using the zlib algorithm, and gzip which requests the gzip algorithm. Use all to send an Accept-Encoding: header containing all supported encodings.

This is a request, not an order; the server may or may not do it. This option must be set or else any unsolicited encoding done by the server is ignored. See the special file lib/README.encoding in libcurl docs for details.

-followlocation
A non-zero parameter tells the library to follow any Location: header that the server sends as part of a HTTP header.

NOTE: this means that the extension will re-send the same request on the new location and follow new Location: headers all the way until no more such headers are returned. -maxredirs can be used to limit the number of redirects TclCurl will follow.

-unrestrictedauth
A non-zero parameter tells the extension it can continue to send authentication (user+password) when following locations, even when hostname changed. Note that this is meaningful only when setting -followlocation.

-maxredirs
Sets the redirection limit. If that many redirections have been followed, the next redirect will cause an error. This option only makes sense if the -followlocation option is used at the same time.

-put
A non-zero parameter tells the extension to use HTTP PUT a file. The file to put must be set with -infile and -infilesize.

-post
A non-zero parameter tells the library to do a regular HTTP post. This is a normal application/x-www-form-urlencoded kind, which is the most commonly used one by HTML forms. See the -postfields option for how to specify the data to post and -postfieldsize about how to set the data size.

Starting with TclCurl 0.7.8, this option is obsolete. Using the -postfields option will imply it.

-postfields
Pass a string as parameter, which should be the full data to post in a HTTP post operation. This is a normal application/x-www-form-urlencoded kind, which is the most commonly used one by HTML forms.

Note: to make multipart/formdata posts (aka rfc1867-posts), check out httppost option.

-postfieldsize
If you want to post data to the server without letting TclCurl do a strlen() to measure the data size, this option must be used. Also, when this option is used, you can post fully binary data which otherwise is likely to fail. If this size is set to zero, the library will use strlen() to get the data size.

-httppost
Tells TclCurl you want a multipart/formdata HTTP POST to be made and you instruct what data to pass on to the server through a Tcl list.

This is the only case where the data is reset after a transfer.

First, there are some basics you need to understand about multipart/formdata posts. Each part consists of at least a NAME and a CONTENTS part. If the part is made for file upload, there are also a stored CONTENT-TYPE and a FILENAME. Below here, we'll discuss on what options you use to set these properties in the parts you want to add to your post.

The list must contain a 'name' tag with the name of the section followed by a string with the name, there are three tags to indicate the value of the section: 'value' followed by a string with the data to post, 'file' followed by the name of the file to post and 'contenttype' with the type of the data (text/plain, image/jpg, ...), you can also indicate a false file name with 'filename', this is useful in case the server checks if the given file name is valid, for example, by testing if it starts with 'c:\' as any real file name does. You can also post the content of a variable as if it were a file with the options 'bufferName' and 'buffer'

Should you need to specify extra headers for the form POST section, use 'contentheader' followed by a list with the headers to post.

Please see 'httpPost.tcl' and 'httpBufferPost.tcl' for examples.

-referer
Pass a string as parameter. It will be used to set the referer header in the http request sent to the remote server. This can be used to fool servers or scripts. You can also set any custom header with -httpheader.

-useragent
Pass a string as parameter. It will be used to set the user-agent: header in the http request sent to the remote server. This can be used to fool servers or scripts. You can also set any custom header with -httpheader.

-httpheader
Pass a list with the HTTP headers to pass to the server in your request. If you add a header that is otherwise generated and used by TclCurl internally, your added one will be used instead. If you add a header with no contents as in 'Accept:', the internally used header will just get disabled. Thus, using this option you can add new headers, replace and remove internal headers.

NOTE:The most commonly replaced headers have "shortcuts" in the options: cookie, useragent, and referer.

-http200aliases
Pass a list of aliases to be treated as valid HTTP 200 responses. Some servers respond with a custom header response line. For example, IceCast servers respond with "ICY 200 OK". By including this string in your list of aliases, the response will be treated as a valid HTTP header line such as "HTTP/1.0 200 OK".

NOTE:The alias itself is not parsed for any version strings. So if your alias is "MYHTTP/9.9", TclCurl will not treat the server as responding with HTTP version 9.9. Instead TclCurl will use the value set by option httpversion

-cookie
Pass a string as parameter. It will be used to set a cookie in the http request. The format of the string should be what the cookie should contain.

If you need to set mulitple cookies, you need to set them all using a single option and thus you need to concat them all in one single string. Set multiple cookies in one string like this: "name1=content1; name2=content2;" etc.

Using this option multiple times will only make the latest string override the previously ones.

-cookiefile
Pass a string as parameter. It should contain the name of your file holding cookie data. The cookie data may be in netscape cookie data format or just regular HTTP-style headers dumped to a file.

Given an empty or non-existing file, this option will enable cookies for this curl handle, making it understand and parse received cookies and then use matching cookies in future requests.

-cookiejar
Pass a file name in which TclCurl will dump all internally known cookies when curlHandle cleanup is called. If no cookies are known, no file will be created. Specify "-" to have the cookies written to stdout.

Using this option also enables cookies for this session, so if you, for example, follow a location it will make matching cookies get sent accordingly.

TclCurl will not and cannot report an error for this. Using 'verbose' will get a warning to display, but that is the only visible feedback you get about this possibly lethal situation.

-timecondition
This defines how the timevalue value is treated. You can set this parameter to ifmodsince or ifunmodsince. This is a HTTP-only feature.

-timevalue
This should be the time in seconds since 1 jan 1970, and the time will be used in a condition as specified with timecondition.

-httpget
If set to non-zero forces the HTTP request to get back to GET. Only really usable if POST, PUT or a custom request have been used previously with the same handle.

-httpversion
Set to one of the values decribed below, they force TclCurl to use the specific http versions. It should only be used if you really MUST do that because of a silly remote server.
none
We do not care about what version the library uses. TclCurl will use whatever it thinks fit.
1.0
Enforce HTTP 1.0 requests.
1.1
Enforce HTTP 1.1 requests.

 

FTP options

-ftpport
Pass a string as parameter. It will be used to get the IP address to use for the ftp PORT instruction. The PORT instruction tells the remote server to connect to our specified IP address. The string may be a plain IP address, a host name, a network interface name (under unix) or just a '-' to let the library use your systems default IP address. Default FTP operations are passive, and thus will not use PORT.

-quote
Pass a list with the FTP commands to pass to the server prior to your ftp request. This will be done before any other FTP commands are issued (even before the CWD command).If you do not want to transfer any files, set nobody to '1' and header to '0'.

-postquote
Pass a list with the FTP commands to pass to the server after your ftp transfer request. If you do not want to transfer any files, set nobody to '1' and header to '0'.

-prequote
Pass a list of FTP commands to issue just before the transfer command (RETR or STOR etc).

-ftplistonly
A non-zero parameter tells the library to just list the names of a ftp directory, instead of doing a full directory listing that would include file sizes, dates etc.

This causes an FTP NLST command to be sent. Beware that some FTP servers list only files in their response to NLST they might not include subdirectories and symbolic links.

-ftpappend
A non-zero parameter tells the extension to append to the remote file instead of overwriting it. This is only useful when uploading to a ftp site.

-ftpuseeprt
Set to non-zero, to tell TclCurl to use the EPRT (and LPRT) command when doing active FTP downloads (which is enabled by 'ftpport'). Using EPRT means that it will first attempt to use EPRT and then LPRT before using PORT, if you pass zero to this option, it will not try using EPRT or LPRT, only plain PORT.

-ftpuseepvs
Set to one to tell TclCurl to use the EPSV command when doing passive FTP downloads (which it always does by default). Using EPSV means that it will first attempt to use EPSV before using PASV, but if you pass a zero to this option, it will not try using EPSV, only plain PASV.

-ftpcreatemissingdirs If set to non-zero, TclCurl will attempt to create any remote directory that it fails to CWD into. CWD is the command that changes working directory.

 

Protocol options

-transfertext
A non-zero parameter tells the extension to use ASCII mode for ftp transfers, instead of the default binary transfer. For LDAP transfers it gets the data in plain text instead of HTML and for win32 systems it does not set the stdout to binary mode. This option can be usable when transferring text data between systems with different views on certain characters, such as newlines or similar.

-crlf
Convert unix newlines to CRLF newlines on FTP transfers.

-range
Pass a string as parameter, which should contain the specified range you want. It should be in the format X-Y , where X or Y may be left out. HTTP transfers also support several intervals, separated with commas as in X-Y,N-M Using this kind of multiple intervals will cause the HTTP server to send the response document in pieces.

-resumefrom
Pass the offset in number of bytes that you want the transfer to start from.

-customrequest
Pass a string as parameter. It will be used instead of GET or HEAD when doing the HTTP request. This is useful for doing DELETE or other more obscure HTTP requests. Do not do this at will, make sure your server supports the command first.

-filetime
If you pass a non-zero value, TclCurl will attempt to get the modification date of the remote document in this operation. This requires that the remote server sends the time or replies to a time querying command. The getinfo procedure with the filetime argument can be used after a transfer to extract the received time (if any).

-nobody
A non-zero parameter tells the library not to include the body-part in the output. This is only relevant for protocols that have a separate header and body part.

-infilesize
When uploading a file to a remote site, this option should be used to tell TclCurl what the expected size of the infile is.

-upload
A non-zero parameter tells the library to prepare for an upload. The -infile and -infilesize options are also interesting for uploads.

 

Connection options

-timeout Pass the maximum time in seconds that you allow the TclCurl transfer operation to take. Do note that normally, name lookups may take a considerable time and that limiting the operation to less than a few minutes risks aborting perfectly normal operations. This option will cause libcurl to use the SIGALRM to enable time-outing system calls.

NOTE: this is not recommended to use in unix multithreaded programs, as it uses signals unless -nosignal is set.

-lowspeedlimit
Pass the speed in bytes per second that the transfer should be below during lowspeedtime seconds for the extension to consider it too slow and abort.

-lowspeedtime
Pass the time in seconds that the transfer should be below the lowspeedlimit for the extension to consider it too slow and abort.

-maxconnects
Sets the persistant connection cache size. The set amount will be the maximum amount of simultaneous connections that TclCurl may cache between file transfers. Default is 5, and there is not much point in changing this value unless you are perfectly aware of how this works and changes the behaviour of TclCurl.

When reaching the maximum limit, TclCurl uses the closepolicy to figure out which of the existing connections to close to prevent the number of open connections to increase.

Note: if you have already performed transfers with this curl handle, setting a smaller maxconnects than before may cause open connections to unnecessarily get closed.

-closepolicy
This option sets what policy TclCurl should use when the connection cache is filled and one of the open connections has to be closed to make room for a new connection. Use leastrecentlyused to make libcurl close the connection that was least recently used, that connection is also least likely to be capable of reuse. Use oldest to make libcurl close the oldest connection, the one that was created first among the ones in the connection cache.

-connecttimeout
Maximum time in seconds that you allow the connection to the server to take. This only limits the connection phase, once it has connected, this option is of no more use. Set to zero to disable connection timeout (it will then only timeout on the internal timeouts).

NOTE: It is not recommended to use in unix multithreaded programs, as it uses signals unless -nosignal is set.

 

SSL and security options

-sslcert
Pass a string as parameter. The string should be the file name of your certificate. The default format is "PEM" and can be changed with -sslcerttype.

-sslcerttype
Pass a string as parameter. The string should be the format of your certificate. Supported formats are "PEM" and "DER".

-sslcertpasswd
Pass a string as parameter. It will be used as the password required to use the -sslcert certificate

NOTE:This option is replaced by -sslkeypasswd and only kept for backward compatibility. You never need a pass phrase to load a certificate but you need one to load your private key.

-sslkey
Pass a pointer to a zero terminated string as parameter. The string should be the file name of your private key. The default format is "PEM" and can be changed with -sslkeytype.

-sslkeytype
Pass a pointer to a zero terminated string as parameter. The string should be the format of your private key. Supported formats are "PEM", "DER" and "ENG"

NOTE:The format "ENG" enables you to load the private key from a crypto engine. in this case -sslkey is used as an identifier passed to the engine. You have to set the crypto engine with -sslengine.

-sslkeypasswd
Pass a string as parameter. It will be used as the password required to use the -sslkey private key.

-sslengine
Pass a string as parameter. It will be used as the identifier for the crypto engine you want to use for your private key.

NOTE:If the crypto device cannot be loaded, an error will be returned.

-sslenginedefault
Sets the actual crypto engine as the default for (asymetric) crypto operations.

NOTE:If the crypto device cannot be set, an error will be returned.

-sslversion
Pass what version of SSL to attempt to use, 2 or 3. By default, the SSL library will try to solve this by itself although some servers make this difficult, that is why you at times will have to use this option.

-sslverifypeer
Pass a zero value to stop TclCurl from verifying the peer's certificate. Alternate certificates to verify against can be specified with the -cainfo option or a certificate directory can be specified with the -capath option. -sslverifyhost may also need to be set to 1 or 0 if -sslverifypeer is disabled (it defaults to 2).

-cainfo
Pass a file naming holding the certificate to verify the peer with. This only makes sense when used in combination with the -sslverifypeer option.

-capath
Pass the directory holding multiple CA certificates to verify the peer with. The certificate directory must be prepared using the openssl c_rehash utility. This only makes sense when used in combination with the -sslverifypeer option.

-randomfile
Pass a file name. The file will be used to read from to seed the random engine for SSL. The more random the specified file is, the more secure will the SSL connection become.

-egdsocket
Pass a path name to the Entropy Gathering Daemon socket. It will be used to seed the random engine for SSL.

-sslverifyhost
Set to non-zero if we should verify the Common name from the peer certificate in the SSL hand­shake, set 1 to check existence, 2 to ensure that it matches the provided hostname. (It defaults to 2)

-sslcypherlist
Pass a string holding the ciphers to use for the SSL connection. The list must consists of one or more cipher strings separated by colons. Commas or spaces are also acceptable separators but colons are normally used, , - and + can be used as operators. Valid examples of cipher lists include 'RC4-SHA', 'SHA1+DES', 'TLSv1' and 'DEFAULT'. The default list is normally set when you compile OpenSSL.

You will find more details about cipher lists on this URL:
    http://www.openssl.org/docs/apps/ciphers.html

-krb4level
Set the krb4 security level, this also enables krb4 awareness. This is a string, 'clear', 'safe', 'confidential' or 'private'. If the string is set but does not match one of these, 'private' will be used. Set the string to NULL to disable kerberos4. The kerberos support only works for FTP.

 

TclCurl own options

-headervar
Name of the Tcl array variable where TclCurl will store the headers returned by the server.

-bodyvar
Name of the Tcl variable where TclCurl will store the file requested, the file may contain text or binary data.

-canceltransvar
Name of a Tcl variable, in case you have defined a procedure to call with -progressproc setting this variable to '1' will cancel the transfer.

-command
Executes the given command after the transfer is done, since it only works with blocking transfers, it is pretty much useless.

 

NOT SUPPORTED

Some of the options libcurl offers are not supported, I don't think them worth supporting in TclCurl but if you need one of them don't forget to complain:

CURLOPT_PASSWDFUNCTION, CURLOPT_PASSWDDATA, CURLOPT_FRESH_CONNECT, CURLOPT_FORBID_REUSE, CURLOPT_PRIVATE, CURLOPT_SSL_CTX_FUNCTION, CURLOPT_SSL_CTX_DATA, CURLOPT_SSL_CTX_FUNCTION.

 

curlHandle perform

This procedure is called after the init and all the configure calls are made, and will perform the transfer as described in the options.

It must be called with the same curlHandle curl::init call 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.

RETURN VALUE
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
Very early initialization code failed. This is likely to be and internal error or problem.
3
URL malformat. The syntax was not correct.
4
URL user malformatted. The user-part of the URL syntax was not correct.
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 when trying to login to a FTP server or when trying to change working directory to the one given in the URL.
10
FTP user/password incorrect. Either one or both were not accepted by the server.
11
FTP weird PASS reply. TclCurl couldn't parse the reply sent to the PASS request.
12
FTP weird USER reply. TclCurl couldn't parse the reply sent to the USER request.
13
FTP weird PASV reply, TclCurl couldn't parse the reply sent to the PASV 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.
16
FTP can't reconnect. A bad return code on either PASV or EPSV was sent by the FTP server, preventing TclCurl from being able to continue.
17
FTP couldn't set binary. Couldn't change transfer method to binary.
18
Partial file. Only a part of the file was transfered, 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 a 'RETR' command or a zero byte transfer.
20
FTP write error. After a completed file transferm the FTP server did not respond properly.
21
FTP quote error. A custom 'QUOTE' returned error code 400 or higher from the server.
22
HTTP not found. The requested page was not found. This return code only appears if --fail is 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.
24
Malformat user. User name badly specified. Not in use anymore
25
FTP couldn't STOR file. The server denied the STOR operation, the error buffer will usually have the server explanation.
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.
29
FTP couldn't set ASCII. The server returned an unknown reply.
30
FTP PORT command failed, this usually happens when you haven't specified a good enough address for TclCurl to use.
31
FTP couldn't use REST. This should never happen is the server is sane.
32
FTP couldn't use the SIZE command. The command is an extension to the original FTP spec RFC 959, so not all servers support it.
33
HTTP 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
FTP bad download resume. Couldn't continue an earlier aborted download, probably because you are trying to resume beyond the file size.
37
A file given with FILE:// couldn't be read. Did you checked the permissions?
38
LDAP cannot bind. LDAP bind operation failed.
39
LDAP search failed.
40
Library not found. The LDAP library was not found.
41
A required LDAP 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.
44
Internal error. A function was called in a bad order.
45
Interface error. A specified outgoing interface could not be used.
46
Bad password entered. An error was signalled when the password was entered.
47
Too many redirects. When following redirects, TclCurl hit the maximum amount, set your limit with --maxredirs
48
Unknown TELNET option specified.
49
A telnet option string was illegally formatted.
50
Currently not used.
51
The remote peer's SSL certificate 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.
57
Share is in use (internal error)
58
Problem with the local certificate
59
Couldn't use specified SSL cipher
60
Problem with the CA cert (path? permission?)
61
Unrecognized transfer encoding

 

curlHandle getinfo option

Request internal information from the curl session with this procedure. This procedure is intended to get used *AFTER* a performed transfer, all results from this function are undefined until the transfer is completed. AVAILABLE INFORMATION These are informations that can be extracted:

effectiveurl
Returns the last used effective URL.

httpcode
Returns the last received HTTP code.

filetime
Returns the remote time of the retrieved document. If you get -1, TclCurl couldn't read it, which can be because of many reasons (unknown, the server hides it or the server doesn't support the command that tells document time, etc) and the time of the document is unknown.

In order for this to work you have to set the -filetime option before the transfer.

totaltime
Returns the total transaction time in seconds for the previous transfer.

namelookuptime
Returns the time, in seconds, it took from the start until the name resolving was completed.

connecttime
Returns the time, in seconds, it took from the start until the connect to the remote host (or proxy) was completed.

pretransfertime
Returns the time, in seconds, it took from the start until the file transfer is just about to begin. This includes all pre-transfer commands and negotiations that are specific to the particular protocol(s) involved.

starttransfertime
Returns the time, in seconds, it took from the start until the first byte is just about to be transfered. This includes the pretransfertime and also the time the server needs to calculate the result.

redirecttime
Returns the total time, in seconds, it took for all redirection steps including name lookup, connect, pretransfer and transfer before the final transaction was started, it returns the complete execution time for multiple redirections.

redirectcount
Returns the total number of redirections that were actually followed.

sizeupload
Returns the total amount of bytes that were uploaded.

sizedownload
Returns the total amount of bytes that were downloaded. The amount is only for the latest transfer and will be reset again for each new transfer.

speeddownload
Returns the average download speed that curl measured for the complete download.

speedupload
Returns the average upload speed that curl measured for the complete upload.

headersize
Returns the total size of all the headers received.

requestsize
Returns the total size of the issued requests. This is so far only for HTTP requests. Note that this may be more than one request if followLocation is true.

sslverifyresult
Returns the result of the certification verification that was requested (using the -sslverifypeer option to configure).

contentlengthdownload
Returns the content-length of the download. This is the value read from the Content-Length: field.

contentlengthupload
Returns the specified size of the upload.

contenttype
Returns the content-type of the downloaded object. This is the value read from the Content-Type: field. If you get an empty string, it means the server didn't send a valid Content-Type header or that the protocol used doesn't support this.

 

curlHandle duphandle

This procedure will return a new curl handle, a duplicate, using all the options previously set in the input curl handle. Both handles can subsequently be used independently and they must both be freed with cleanup. 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 cleanup

This procedure must be the last one to call for a curl session. It is the opposite of the curl::init procedure and must be called with the same curlhandle as input as the curl::init call returned. This will effectively close all connections TclCurl has used and possibly has kept open until now. Don't call this procedure if you intend to transfer more files.

 

curl::transfer

In case you do not want to use persistant 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.

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 OpenSSL version).
RETURN VALUE
The string with the version info.

 

curl::escape url

This procedure will convert the given input string to an URL encoded string and return 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)
RETURN VALUE
The converted string.
 

curl::unescape url

This procedure will convert the given URL encoded input string to a "plain string" and return that. All input characters that are URL encoded (%XX where XX is a two-digit hexadecimal number, or +) will be converted to their plain text versions (up to a ? letter, no letters to the right of a ? letter will be converted).
RETURN VALUE
The string unencoded.

 

curl::curlConfig option

Returns some information about how you have cURL installed.

NOTE: Not available in the Windows version.

OPTIONS
-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 include SSL, KRB4 or IPv6, do not assume any particular order.
-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 libcurl 7.7.4 would appear as 070704 and libcurl 12.13.14 would appear as 0c0d0e...

 

curl::versionInfo option

Returns information about various run-time features in TclCurl.

Applications should use this information to judge if things are possible to do or not, instead of using compile-time checks, as dynamic/DLL libraries can be changed independent of applications.

OPTIONS
-version
Returns the version of libcurl we are using.

-versionnum
Retuns the version of libcurl we are using in hexadecimal with 8 bits for each part; major, minor, patch. So that libcurl 7.7.4 would appear as 070704 and libcurl 12.13.14 would appear as 0c0d0e...

-host
Returns a string with the host information as discovered by a configure script or set by the build environment.

-features
Returns a list with the features compiled into libcurl, the possible elements are:
V6',

-sslversion
Returns a string with the OpenSSL version used, like 'OpenSSL/0.9.6b'.

-sslversionnum
Returns the numerical OpenSSL version value as defined by the OpenSSL project. If libcurl has no SSL support, this is 0.

-libzversion
Returns a string, there is no numerical version, for example: '1.1.3'.

-protocols
Returns a list with the protocols compiled into libcurl, 'ftp', 'http',...

 

SEE ALSO

curl, curl_formparse, The art of HTTP scripting, RFC 2396,


 

Index

NAME
SYNOPSIS
DESCRIPTION
curl::init
curlHandle configure ?options?
Behaviour options
Callback options
Error Options
Network options
Names and Passwords options
HTTP options
FTP options
Protocol options
Connection options
SSL and security options
TclCurl own options
NOT SUPPORTED
curlHandle perform
curlHandle getinfo option
curlHandle duphandle
curlHandle cleanup
curl::transfer
curl::version
curl::escape url
curl::unescape url
curl::curlConfig option
curl::versionInfo option
SEE ALSO

This document was created by man2html, using the manual pages.