libcurl class for Visual FoxPro 9
This class is a wrapper for the libcurl library easy interface. libcurl supports FTP, FTPS, HTTP, HTTPS, SCP, SFTP, TFTP, TELNET, DICT, LDAP, LDAPS and FILE. libcurl supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies, cookies, user+password authentication (Basic, Digest, NTLM, Negotiate, Kerberos4), file transfer resume, http proxy tunneling and more.
FTP over TLS/SSL
http://en.wikipedia.org/wiki/FTPSOften called 'FTPS' Often called 'Secure FTP' Plain FTP over TLS/SSL channel Password is encrypted Transfer is encrypted Runs over TCP port 21 or 990 Defined by RFC959, RFC1123, RFC4217 and RFC2228
STEP 1
Download the class here: libcurl.zip updated 2014-05-24 (includes EVERYTHING you need: vfp2c32.fll and libcurl files)libcurl info: http://curl.haxx.se/download.html The package I used is http://www.gknw.net/mirror/curl/win32/curl-7.19.0-ssl-sspi-zlib-static-bin-w32.zip Extract the files from the zip, copy libcurl.dll, libeay32.dll, libssl32.dll to your project/exe folder, or to the windows\system32 folder. Certificates file info: Optionally download cacert.pem from http://curl.haxx.se/docs/caextract.html copy it to the libcurl class folder, rename it to libcurl.crt Read about certificates here: http://curl.haxx.se/docs/sslcerts.html vfp2c32 info: This class uses vfp2c32.fll to set up callback functions for use with the libcurl api calls. The vfp2c32 home page is http://www.vfp2c.com/ NOTE: The class uses vfp2c32.fll version 2.0.0.4 This version has been updated to support some features required by libcurl.dll
STEP 2
Go here: http://curl.haxx.se/libcurl/c/libcurl-easy.html and read everything there is to know about libcurl and the easy interface. You can skip this step if you are not interested in understanding how libcurl works.
STEP 3
If you want to set up a complete solution for FTPS, or want to test the class, download the Filezilla Server from here:http://filezilla-project.org/ The Filezilla FTP server supports FTP over TLS/SSL. Install it and set it up, you can use this tutorial: Installing and configuring FileZilla Server to use with libcurl class
Quick Guide
Features:
The class wraps most of the libcurl api calls, for example: The CurlEasyPerform method, among other things, calls the curl_easy_perform function in libcurl. Most of the configuration of the libcurl handle is done with calls to the curl_easy_setopt function in libcurl. The most common setup options are already wrapped in class properties, for example: CurlOptUserPwd CurlOptUseSsl CurlOptVerbose For the options not wrapped, you can use the libcurl api CurlEasySetOptInteger, CurlEasySetOptInt64, and CurlEasySetOptString dll declares aliases.
Really Quick Guide
Forget about libcurl, just drag and drop the class into your form and then use the class methods, like FtpDownloadFile, FtpUploadFile, etc. You will have to set some optional properties that are not set by those methods. if you need them, like CurlOptUserPwd for example.
Examples
Properties, Events and Methods
Cancels the current active transfer.PARAMETERS None. DESCRIPTION - RETURN VALUE None. REMARKS - URL encodes the given string. PARAMETERS cString. Character. Specifies the string to escape. DESCRIPTION This method converts the given input string to an URL encoded string and returns that as a new allocated string. All input characters that are not a-z, A-Z or 0-9 are converted to their "URL escaped" version (%NN where NN is a two-digit hexadecimal number). RETURN VALUE Character. REMARKS Use CurlEasyUnescape to do the reverse. This property stores the curl easy handle that is created internally in the INIT method. VALUE TYPE Numeric DEFAULT VALUE 0 READ/WRITE Read only. REMARKS Under normal circumstances, you should not touch this property. Performs a transfer. PARAMETERS None. Internally the CurlEasyHandle property is used in the call to curl_easy_perform. DESCRIPTION
This method will perform the transfer as described in the options.
You can do any amount of calls to CurlEasyPerform. If you intend to transfer more than one file, you are even encouraged to do so. libcurl will then attempt to re-use the same connection for the following transfers, thus making the operations faster, less CPU intense and using less network resources. Just note that you will have to use the CtlOpt... properties between the invokes to set options for the following CurlEasyPerform.
RETURN VALUEnResultCode. Numeric. 0 means everything was ok, non-zero means an error occurred. You can use CurlEasyStrError(nResultCode) to get a readable error message. REMARKS Under normal circumstances you will not need to call this method directly, but instead use the Ftp/Http/File methods. Resets all options of a libcurl session handle. PARAMETERS None. Internally the CurlEasyHandle property is used in the call to curl_easy_reset. DESCRIPTION
Re-initializes all options previously set on a specified CURL handle to the default values. This puts back the handle to the same state as it was in when it was just created.
It does not change the following information kept in the handle: live connections, the Session ID cache, the DNS cache, the cookies and shares.
RETURN VALUENone. REMARKS Internally the class sets again the callbacks and the location of the certificates file. Returns a string describing the numeric error code passed. PARAMETERS nErrorNum. Numeric. Optional. A curl error code obtained by calling CurlEasyPerform or by calling CurlInfoPerformCode DESCRIPTION Returns a string describing the error code passed in the argument nErrorNum. RETURN VALUE Character. REMARKS If no error code is passed, the last return code from CurlEasyPerform is used (CurlInfoPerformCode) URL decodes the given string. PARAMETERS cString. Character. Specifies the string to url decode. DESCRIPTION This function converts the given URL encoded input string to a "plain string" and returns that in an allocated memory area. All input characters that are URL encoded (%XX where XX is a two-digit hexadecimal number) are converted to their binary versions. RETURN VALUE Character. REMARKS Use CurlEasyEscape to do the reverse. Returns the last used effective URL. PARAMETERS None. DESCRIPTION RETURN VALUE Character. REMARKS The last result code returned by CurlEasyPErform PARAMETERS None. DESCRIPTION RETURN VALUE Numeric. REMARKS This method does not wrap a libcurl function, it was added as a convenience to use with functions that do not return the result code from CurlEasyPerform. For example, FtpGetFileSize returns the size of the remote file or -1 if it fails, you can then get the result code from FtpGetFileSize with this method. See also CurlEasyStrError The last received HTTP or FTP code. This will be zero if no server response code has been received. PARAMETERS None DESCRIPTION RETURN VALUE Numeric. REMARKS - VALUE TYPE Logical DEFAULT VALUE FALSE READ/WRITE Yes REMARKS Set to TRUE to append to the remote file instead of overwriting it. This is only useful when uploading to an ftp site. There is no need to set this property directly, use the FtpAppendFile and FtpAppendString methods. VALUE TYPE Logical DEFAULT VALUE FALSE READ/WRITE Yes REMARKS When enabled, libcurl will automatically set the Referer: field in requests where it follows a Location: redirect. VALUE TYPE Character DEFAULT VALUE None READ/WRITE Yes REMARKS
It will be used to set a cookie in the http request. The format of the string should be NAME=CONTENTS, where NAME is the cookie name and CONTENTS is what the cookie should contain.
If you need to set multiple cookies, you need to set them all using a single option and thus you need to concatenate them all in one single string. Set multiple cookies in one string like this: "name1=content1; name2=content2;" etc.
Note that this option sets the cookie header explictly in the outgoing request(s). If multiple requests are done due to authentication, followed redirections or similar, they will all get this cookie passed on.
Using this option multiple times will only make the latest string override the previous ones.
Specifies a file that holds cookie data to read. VALUE TYPE Character DEFAULT VALUE None READ/WRITE Yes REMARKS
The cookie data may be in Netscape / Mozilla cookie data format or just regular HTTP-style headers dumped to a file.
Given an empty or non-existing file or by passing the empty string (""), this option will enable cookies for this curl handle, making it understand and parse received cookies and then use matching cookies in future request.
If you use this option multiple times, you just add more files to read. Subsequent files will add more cookies.
Specifies a file where libcurl will sotre known cookies when curl_easy_cleanup is called. VALUE TYPE Character DEFAULT VALUE None READ/WRITE Yes REMARKS libcurl will write all internally known cookies to the specified file when curl_easy_cleanup is called. If no cookies are known, no file will be created. Specify "-" to instead 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. If the cookie jar file can't be created or written to (when the curl_easy_cleanup(3) is called), libcurl will not and cannot report an error for this. Using CURLOPT_VERBOSE or CURLOPT_DEBUGFUNCTION will get a warning to display, but that is the only visible feedback you get about this possibly lethal situation. Specifies the full data to post in an HTTP POST operation. VALUE TYPE Character DEFAULT VALUE None READ/WRITE Yes REMARKS Use the HttpPostFile and HttpPostString methods. It behaves as the CURLOPT_POSTFIELDS option, but the original data is copied by the library, allowing the application to overwrite the original data after setting this option. Because data is copied, care must be taken when using this option in conjunction with CurlOptPostFieldSize or CURLOPT_POSTFIELDSIZE_LARGE: If the size has not been set prior to CurlOptCopyPostFields, the data are assumed to be a NUL-terminated string; else the stored size informs the library about the data byte count to copy. In any case, the size must not be changed after CurlOptCopyPostFields, unless another CURLOPT_POSTFIELDS or CurlOptCopyPostFields option is issued. (Added in 7.17.1) VALUE TYPE Logical DEFAULT VALUE FALSE READ/WRITE Yes REMARKS Convert Unix newlines to CRLF newlines on transfers. It seems that this is not working in libcurl. VALUE TYPE Character DEFAULT VALUE None READ/WRITE Yes REMARKS
It will be used instead of GET or HEAD when doing an HTTP request, or instead of LIST or NLST when doing an ftp directory listing. This is useful for doing DELETE or other more or less obscure HTTP requests. Don't do this at will, make sure your server supports the command first.
Note that libcurl will still act and assume the keyword it would use if you didn't set your custom one is the one in use and it will act according to that.
Restore to the internal default by setting this to "".
VALUE TYPE Logical. DEFAULT VALUE FALSE READ/WRITE Yes REMARKS
Used by FtpListDirectory, no need to use directly.
Set to TRUE to just list the names of files in a directory, instead of doing a full directory listing that would include file sizes, dates etc. This works for FTP and SFTP URLs.
This causes an FTP NLST command to be sent on an FTP server. Beware that some FTP servers list only files in their response to NLST; they might not include subdirectories and symbolic links.
VALUE TYPE Logical. DEFAULT VALUE FALSE READ/WRITE Yes REMARKS Used by FtpGetDateTimeStamp, no need to use directly. VALUE TYPE Logical. DEFAULT VALUE FALSE READ/WRITE Yes REMARKS
If TRUE, tells the library to follow any Location: header that the server sends as part of an HTTP header.
This means that the library 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. CurlOptMaxRedirs can be used to limit the number of redirects libcurl will follow.
Not used in FTP protocol.
Specifies the account data for FTP servers. VALUE TYPE Character. DEFAULT VALUE None READ/WRITE Yes REMARKS When an FTP server asks for "account data" after user name and password has been provided, this data is sent off using the ACCT command. VALUE TYPE Logical. DEFAULT VALUE FALSE READ/WRITE Yes REMARKS
If TRUE, libcurl will attempt to create any remote directory that it fails to CWD into. CWD is the command that changes working directory. (Added in 7.10.7)
This setting also applies to SFTP connections. libcurl will attempt to create the remote directory if it can't obtain a handle to the target-location. The creation will fail if a file of the same name as the directory to create already exists or lack of permissions prevents creation.
VALUE TYPE Numeric. DEFAULT VALUE FALSE READ/WRITE Yes REMARKS
This option controls what method libcurl should use to reach a file on a FTP(S) server. The argument should be one of the following alternatives:
CURLFTPMETHOD_MULTICWD (1)
libcurl does a single CWD operation for each path part in the given URL. For deep hierarchies this means very many commands. This is how RFC1738 says it should be done. This is the default but the slowest behavior.
CURLFTPMETHOD_NOCWD (2)
libcurl does no CWD at all. libcurl will do SIZE, RETR, STOR etc and give a full path to the server for all these commands. This is the fastest behavior.
CURLFTPMETHOD_SINGLECWD (3)
libcurl does one CWD with the full target directory and then operates on the file "normally" (like in the multicwd case). This is somewhat more standards compliant than 'nocwd' but without the full penalty of 'multicwd'.
Specifies the IP address to use for the ftp PORT instruction. VALUE TYPE Character DEFAULT VALUE None READ/WRITE Yes REMARKS
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, an network interface name (under Unix) or just a '-' letter to let the library use your systems default IP address. Default FTP operations are passive, and thus won't use PORT.
You disable PORT again and go back to using the passive version by setting this option to "".
VALUE TYPE Numeric. DEFAULT VALUE 0 READ/WRITE Yes REMARKS Specifies the timeout period (in seconds) on the amount of time that the server is allowed to take in order to generate a response message for a command before the session is considered hung. While curl is waiting for a response, this value overrides CurlOptTimeOut. It is recommended that if used in conjunction with CurlOptTimeOut, you set CurlOptFtpResponseTimeOut to a value smaller than CurlOptTimeOut. (Added in 7.10.8) VALUE TYPE Numeric DEFAULT VALUE 0 READ/WRITE Yes REMARKS
Set to one of the values from below, to alter how libcurl issues "AUTH TLS" or "AUTH SSL" when FTP over SSL is activated (see CurlOptUseSsl CURLOPT_FTP_SSL).
VALUE TYPE Numeric DEFAULT VALUE 0 READ/WRITE Yes REMARKS If enabled, this option makes libcurl use CCC (Clear Command Channel). It shuts down the SSL/TLS layer after authenticating. The rest of the control channel communication will be unencrypted. This allows NAT routers to follow the FTP transaction. Pass a long using one of the values below. (Added in 7.16.1)
VALUE TYPE Logical. DEFAULT VALUE FALSE READ/WRITE Yes REMARKS
If TRUE, lt tells the library to include the header in the body output. This is only relevant for protocols that actually have headers preceding the data (like HTTP).
VALUE TYPE Numeric DEFAULT VALUE 1 READ/WRITE Yes REMARKS
Tells libcurl what authentication method(s) you want it to use. The available bits are listed below. If more than one bit is set, libcurl will first query the site to see what authentication methods it supports and then pick the best one you allow it to use. For some methods, this will induce an extra network round-trip. Set the actual name and password with the CurlOptUserPwd option. (Added in 7.10.6)
CURLAUTH_BASIC (1)
HTTP Basic authentication. This is the default choice, and the only method that is in wide-spread use and supported virtually everywhere. This is sending the user name and password over the network in plain text, easily captured by others.
CURLAUTH_DIGEST (2)
HTTP Digest authentication. Digest authentication is defined in RFC2617 and is a more secure way to do authentication over public networks than the regular old-fashioned Basic method.
CURLAUTH_GSSNEGOTIATE (4)
HTTP GSS-Negotiate authentication. The GSS-Negotiate (also known as plain "Negotiate") method was designed by Microsoft and is used in their web applications. It is primarily meant as a support for Kerberos5 authentication but may be also used along with another authentication methods. For more information see IETF draft draft-brezak-spnego-http-04.txt.
You need to build libcurl with a suitable GSS-API library for this to work.
CURLAUTH_NTLM (8)
HTTP NTLM authentication. A proprietary protocol invented and used by Microsoft. It uses a challenge-response and hash concept similar to Digest, to prevent the password from being eavesdropped.
CURLAUTH_ANY (15)
This is a convenience macro that sets all bits and thus makes libcurl pick any it finds suitable. libcurl will automatically select the one it finds most secure.
CURLAUTH_ANYSAFE (14)
This is a convenience macro that sets all bits except Basic and thus makes libcurl pick any it finds suitable. libcurl will automatically select the one it finds most secure.
VALUE TYPE Logical DEFAULT VALUE FALSE READ/WRITE Yes REMARKS
This forces the HTTP request to get back to GET. usable if a POST, HEAD, PUT or a custom request have been used previously using the same curl handle.
When set to TRUE, it will automatically set CurlOptNoBody to FALSE.
List of HTTP headers to pass to the server in your HTTP request. (Separated by the "|" character) VALUE TYPE Character DEFAULT VALUE None READ/WRITE Yes REMARKS If you add a header with no contents as in 'Accept:' (no data on the right side of the colon), the internally used header will get disabled. Thus, using this option you can add new headers, replace internal headers and remove internal headers. To add a header with no contents, make the contents be two quotes: "". Pass a "" to this to reset back to no custom headers. The most commonly replaced headers have "shortcuts" in the options CurlOptCookie, CurlOptUserAgent and CurlOptReferer VALUE TYPE Logical DEFAULT VALUE FALSE READ/WRITE Yes REMARKS Set the parameter to TRUE to make the library tunnel all operations through a given HTTP proxy. There is a big difference between using a proxy and to tunnel through it. If you don't know what this means, you probably don't want this tunneling option. VALUE TYPE Character DEFAULT VALUE None READ/WRITE Yes REMARKS This sets the interface name to use as outgoing network interface. The name can be an interface name, an IP address or a host name. VALUE TYPE Numeric DEFAULT VALUE 0 READ/WRITE Yes REMARKS This sets the local port number of the socket used for connection. This can be used in combination with CurlOptInterface and you are recommended to use CurlOptLocalPortRange as well when this is set. Note that port numbers are only valid 1 - 65535. VALUE TYPE Numeric DEFAULT VALUE 0 READ/WRITE Yes REMARKS This is the number of attempts libcurl should do to find a working local port number. It starts with the given CurlOptLocalPort and adds one to the number for each retry. Setting this to 1 or below will make libcurl do only one try for the exact port number. Note that port numbers by nature are scarce resources that will be busy at times so setting this value to something too low might cause unnecessary connection setup failures. Specifies the maximum download speed. VALUE TYPE Numeric DEFAULT VALUE 0 READ/WRITE Yes REMARKS If a download exceeds this speed on cumulative average during the transfer, the transfer will pause to keep the average rate less than or equal to the parameter value. Defaults to unlimited speed. Specifies the limit of redirections. VALUE TYPE Numeric. DEFAULT VALUE -1 READ/WRITE Yes REMARKS The set number will be the redirection limit. If that many redirections have been followed, the next redirect will cause an error (CURLE_TOO_MANY_REDIRECTS). This option only makes sense if the CurlOptFollowLocation is used at the same time. Added in 7.15.1: Setting the limit to 0 will make libcurl refuse any redirect. Set it to -1 for an infinite number of redirects (which is the default) Specifies the maximum upload speed. VALUE TYPE Numeric DEFAULT VALUE 0 READ/WRITE Yes REMARKS If an upload exceeds this speed on cumulative average during the transfer, the transfer will pause to keep the average rate less than or equal to the parameter value. Defaults to unlimited speed. If TRUE, tells the library to not include the body-part in the output. VALUE TYPE Logical DEFAULT VALUE FALSE READ/WRITE Yes REMARKS This is only relevant for protocols that have separate header and body parts. On HTTP(S) servers, this will make libcurl do a HEAD request. Specifies the remote port number to connect to. VALUE TYPE Numeric DEFAULT VALUE 0 READ/WRITE Yes REMARKS Specifies the remote port number to connect to, instead of the one specified in the URL or the default port for the used protocol. If TRUE, tells the library to do a regular HTTP post. VALUE TYPE Logical DEFAULT VALUE TRUE READ/WRITE Yes REMARKS Use the HttpPostString and HttpPostFile methods instead of using this property directly. If TRUE, tells the library to do a regular HTTP post. This will also make the library use a "Content-Type: application/x-www-form-urlencoded" header. (This is by far the most commonly used POST method). Use one of CURLOPT_POSTFIELDS or CurlOptCopyPostFields options to specify what data to post and CurlOptPostFieldSize or CURLOPT_POSTFIELDSIZE_LARGE to set the data size. Optionally, you can provide data to POST using the CURLOPT_READFUNCTION and CURLOPT_READDATA options but then you must make sure to not set CURLOPT_POSTFIELDS to anything but NULL. When providing data with a callback, you must transmit it using chunked transfer-encoding or you must set the size of the data with the CurlOptPostFieldSize or CURLOPT_POSTFIELDSIZE_LARGE option. To enable chunked encoding, you simply pass in the appropriate Transfer-Encoding header, see the post-callback.c example. You can override the default POST Content-Type: header by setting your own with CurlOptHttpHeader. Using POST with HTTP 1.1 implies the use of a "Expect: 100-continue" header. You can disable this header with CurlOptHttpHeader as usual. If you use POST to a HTTP 1.1 server, you can send data without knowing the size before starting the POST if you use chunked encoding. You enable this by adding a header like "Transfer-Encoding: chunked" with CurlOptHttpHeader. With HTTP 1.0 or without chunked transfer, you must specify the size in the request. When setting CurlOptPost to TRUE, it will automatically set CurlOptNoBody to FALSE (since 7.14.1). If you issue a POST request and then want to make a HEAD or GET using the same re-used handle, you must explicitly set the new request type using CurlOptNoBody or CurlOptHttpGet or similar. Specifies if RFC 2616/10.3.2 should be followed in redirections. VALUE TYPE Logical DEFAULT VALUE TRUE READ/WRITE Yes REMARKS If TRUE tells the library to respect RFC 2616/10.3.2 and not convert POST requests into GET requests when following a 301 redirection. The non-RFC behaviour is ubiquitous in web browsers, so the library does the conversion by default to maintain consistency. However, a server may requires a POST to remain a POST after such a redirection. This option is meaningful only when setting CurlOptFollowLocation . Specifies the length of the CurlOptCopyPostFields property. VALUE TYPE Numeric DEFAULT VALUE 0 READ/WRITE Yes REMARKS If you want to post data to the server without letting libcurl do a strlen() to measure the data size, this option must be used. When this option is used you can post fully binary data, which otherwise is likely to fail. If this size is set to -1, the library will use strlen() to get the size. List of FTP or SFTP commands to pass to the server after your ftp transfer request. VALUE TYPE Character DEFAULT VALUE None READ/WRITE Yes REMARKS The commands should be separated by the ASCII character 124 "|". Disable this operation again by setting an empty string to this option. List of FTP commands to pass to the server after the transfer type is set. VALUE TYPE Character DEFAULT VALUE None READ/WRITE Yes REMARKS The commands should be separated by the ASCII character 124 "|". Disable this operation again by setting an empty string to this option. Specifies if the TransferProgress event should be fired. VALUE TYPE Logical DEFAULT VALUE FALSE READ/WRITE Yes REMARKS Set to TRUE to use the TransferProgress event. The original libcurl option is called CURLOPT_NOPROGRESS. I removed the negation to make things easier. Specifies the HTTP proxy to use. VALUE TYPE Character DEFAULT VALUE None READ/WRITE Yes REMARKS
Set HTTP proxy to use. The parameter should be a string holding the host name or dotted IP address. To specify port number in this string, append :[port] to the end of the host name. The proxy string may be prefixed with [protocol]:// since any such prefix will be ignored. The proxy's port number may optionally be specified with the separate option CurlOptProxyPort.
When you tell the library to use an HTTP proxy, libcurl will transparently convert operations to HTTP even if you specify an FTP URL etc. This may have an impact on what other features of the library you can use, such as CurlOptQuote and similar FTP specifics that don't work unless you tunnel through the HTTP proxy. Such tunneling is activated with CurlOptHttpProxyTunnel.
libcurl respects the environment variables http_proxy, ftp_proxy, all_proxy etc, if any of those is set. The CurlOptProxy option does however override any possibly set environment variables.
Setting the proxy string to "" (an empty string) will explicitly disable the use of a proxy, even if there is an environment variable set for it.
Since 7.14.1, the proxy host string given in environment variables can be specified the exact same way as the proxy can be set with CurlOptProxy, include protocol prefix (http://) and embedded user + password.
Specifies the proxy authentication method(s). VALUE TYPE Numeric DEFAULT VALUE ? READ/WRITE Yes REMARKS Pass a long as parameter, which is set to a bitmask, to tell libcurl what authentication method(s) you want it to use for your proxy authentication. If more than one bit is set, libcurl will first query the site to see what authentication methods it supports and then pick the best one you allow it to use. For some methods, this will induce an extra network round-trip. Set the actual name and password with the CurlOptProxyUserPwd option. The bitmask can be constructed by or'ing together the bits listed. As of this writing, only Basic, Digest and NTLM work.
Specifies the proxy port to connect to unless it is specified in the proxy string CurlOptProxy. VALUE TYPE Numeric DEFAULT VALUE 0 READ/WRITE Yes REMARKS - Specifies the type of the proxy. VALUE TYPE Numeric DEFAULT VALUE 0 READ/WRITE Yes REMARKS Available options for this are
Specifies the user name and password fot the HTTP proxy. Should be in the form "user:password" VALUE TYPE Character DEFAULT VALUE None READ/WRITE Yes REMARKS String, which should be "user name:password" to use for the connection to the HTTP proxy. Use CurlOptProxyAuth to decide authentication method. Commands to execute before any other commands are issued. VALUE TYPE Character DEFAULT VALUE None READ/WRITE Yes REMARKS Pass a string list of FTP or SFTP commands to pass to the server prior to your ftp request. This will be done before any other commands are issued (even before the CWD command for FTP). The commands should be separated by the ASCII character 124 "|" The set of valid FTP commands depends on the server (see RFC959 for a list of mandatory commands). The valid SFTP commands are: chgrp, chmod, chown, ln, mkdir, pwd, rename, rm, rmdir, symlink (see curl (1)) (SFTP support added in 7.16.3) Specifies the range in bytes to transfer. VALUE TYPE Character DEFAULT VALUE None READ/WRITE Yes REMARKS
String, 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 (using standard MIME separation techniques). Pass a "" to this option to disable the use of ranges.
Ranges work on HTTP, FTP and FILE (since 7.18.0) transfers only.
Specifies the Referer: header in the http request sent to the remote server. VALUE TYPE Character DEFAULT VALUE None READ/WRITE Yes REMARKS
This can be used to fool servers or scripts. You can also set any custom header with CurlOptHttpHeader.
Offset in number of bytes that you want the transfer to start from. VALUE TYPE Numeric DEFAULT VALUE 0 READ/WRITE: Yes REMARKS Set this option to 0 to make the transfer start from the beginning of the file(effectively disabling resume). For FTP, set this option to -1 to make the transfer start from the end of the target file (useful to continue an interrupted upload). Specifies if the server certificate Common Name field should match the host name in the URL. VALUE TYPE Numeric DEFAULT VALUE 2 READ/WRITE Yes REMARKS
This option determines whether libcurl verifies that the server cert is for the server it is known as. When negotiating an SSL connection, the server sends a certificate indicating its identity. When CurlOptSslVerifyHost is 2, that certificate must indicate that the server is the server to which you meant to connect, or the connection fails.
Curl considers the server the intended one when the Common Name field or a Subject Alternate Name field in the certificate matches the host name in the URL to which you told Curl to connect.
When the value is 1, the certificate must contain a Common Name field, but it doesn't matter what name it says. (This is not ordinarily a useful setting).
When the value is 0, the connection succeeds regardless of the names in the certificate.
The DEFAULT VALUE: is 2.
The checking this option controls is of the identity that the server claims. The server could be lying. To control lying, see CurlOptSslVerifyPeer.
NOTE: If using a self-signed certificate, just set this to 0 if you are not shure if the host name matches the name in the certificate.
Basically specifies if the server certificate should be verified. Set to FALSE for self-signed certificates. VALUE TYPE Logical DEFAULT VALUE TRUE READ/WRITE Yes REMARKS
This option determines whether curl verifies the authenticity of the peer's certificate. A value of TRUE means curl verifies; FALSE means it doesn't. The default is TRUE.
When negotiating an SSL connection, the server sends a certificate indicating its identity. Curl verifies whether the certificate is authentic, i.e. that you can trust that the server is who the certificate says it is. This trust is based on a chain of digital signatures, rooted in certification authority (CA) certificates you supply.
When CurlOptSslVerifyPeer is TRUE, and the verification fails to prove that the certificate is authentic, the connection fails. When the option is FALSE, the connection succeeds regardless.
Authenticating the certificate is not by itself very useful. You typically want to ensure that the server, as authentically identified by its certificate, is the server you mean to be talking to. Use CurlOptVerifyHost to control that.
NOTE: If using a self-signed certificate, set this to FALSE
Specifies the version of SSL/TLS to attempt to use. VALUE TYPE Numeric DEFAULT VALUE 0 READ/WRITE Yes REMARKS
The available options are:
Specifies the maximum time in seconds that you allow the libcurl transfer operation to take. VALUE TYPE Numeric DEFAULT VALUE 0 READ/WRITE: Yes REMARKS
Pass a long as parameter containing the maximum time in seconds that you allow the libcurl transfer operation to take. Normally, name lookups can take a considerable time and limiting operations to less than a few minutes risk aborting perfectly normal operations. This option will cause curl to use the SIGALRM to enable time-outing system calls.
Specifies if ASCII mode or BINARY mode should be used for FTP transfers VALUE TYPE Logical DEFAULT VALUE: FALSE READ/WRITE Yes REMARKS If TRUE, tells the library to use ASCII mode for ftp transfers, instead of the default binary transfer. libcurl does not do a complete ASCII conversion when doing ASCII transfers over FTP. This is a known limitation/flaw that nobody has rectified. libcurl simply sets the mode to ascii and performs a standard transfer. VALUE TYPE Logical DEFAULT VALUE FALSE READ/WRITE Yes REMARKS - Specifies if the connection should atempt an upload. VALUE TYPE: Logical DEFAULT VALUE: FALSE READ/WRITE: Yes REMARKS A parameter set to TRUE tells the library to prepare for an upload. Under normal circumstances, there is no need to set this property, since each method will set it to the desired value. For example FtpDownloadFile, FtpUploadFile, etc. Specifies the URL to use. VALUE TYPE Character DEFAULT VALUE None READ/WRITE: Yes REMARKS
The actual URL to deal with. The parameter should be a string.
If the given URL lacks the protocol part ("http://" or "ftp://" etc), it will attempt to guess which protocol to use based on the given host name. If the given protocol of the set URL is not supported, libcurl will return on error (CURLE_UNSUPPORTED_PROTOCOL) when you call CurlEasyPerform . Use curl_version_info(3) for detailed info on which protocols that are supported.
The string given to CurlOptUrl must be url-encoded and following the RFC 2396 (http://curl.haxx.se/rfc/rfc2396.txt).
CurlOptUrl is the only option that must be set before CurlEasyPerform is called.
Specifies the string to use in the User-Agent header. VALUE TYPE Character DEFAULT VALUE None READ/WRITE Yes REMARKS String. 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 CURLOPT_HTTPHEADER. This is an example User Agent string: "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)" Specifies the user name and password to use for the connection. The format is "user:password" VALUE TYPE Character DEFAULT VALUE None READ/WRITE Yes REMARKS
String, which should be "user name:password" to use for the connection. Use CURLOPT_HTTPAUTH to decide authentication method.
When using NTLM, you can set domain by prepending it to the user name and separating the domain and name with a forward (/) or backward slash (\). Like this: "domain/user:password" or "domain\user:password". Some HTTP servers (on Windows) support this style even for Basic authentication.
When using HTTP and CURLOPT_FOLLOWLOCATION, libcurl might perform several requests to possibly different hosts. libcurl will only send this user and password information to hosts using the initial host name (unless CURLOPT_UNRESTRICTED_AUTH is set), so if libcurl follows locations to other hosts it will not send the user and password to those. This is enforced to prevent accidental information leakage.
VALUE TYPE Numeric DEFAULT VALUE 0 READ/WRITE Yes REMARKS Pass a number using one of the values from below, to make libcurl use your desired level of SSL for the ftp transfer.
VALUE TYPE Logical DEFAULT VALUE FALSE READ/WRITE Yes REMARKS
Set the parameter to TRUE to get the library to display a lot of verbose information about its operations. Very useful for libcurl and/or protocol debugging and understanding. The verbose information will be sent to the CurlDebugBuffer property
You hardly ever want this set in production use, you will almost always want this when you debug/report problems.
Returns the libcurl version in a human readable form. PARAMETERS None. DESCRIPTION
-
RETURN VALUECharacter. REMARKS - Downloads a remote file to a local file using the FILE protocol. REMARKS See FtpDownloadFile Downloads a remote file, returns the contents as a character string using the FILE protocol. REMARKS See FtpDownloadString Uploads a local file to a remote file using the FILE protocol. REMARKS See FtpUploadFile Uploads a string to a remote file. REMARKS See FtpUploadString Pass a numeric value of Bytes, returns a character string formatted as Bytes, KB, MB, GB, TB PARAMETERS nBytes. Numeric. DESCRIPTION
-
RETURN VALUECharacter. REMARKS Can be used to show info to the user, in the FtpProgressEvent. Pass a numeric value in seconds, returns a character string in the format 99 h 99 m 99 s PARAMETERS nSeconds. Numeric. DESCRIPTION
-
RETURN VALUECharacter. REMARKS Can be used to show info to the user, in the FtpProgressEvent. Represents the FTP command APPE that is used to append a file to an exisiting remote file. PARAMETERS cRemoteFile. Character. Specifies the full URL of the remote file. cLocalFile. Character. Specifies the name of the local file. DESCRIPTION
This method always appends the local file to the end of the remote file.
RETURN VALUEnResultCode. Numeric. REMARKS Specify the full URL of the remote file, i.e. ftp://ftp.example.com/directory/file.txt Represents the FTP command APPE that is used to append a file to an exisiting remote file. PARAMETERS cRemoteFile. Character. Specifies the URL of the remote file. cString. Character. Specifies the data to append. DESCRIPTION
Append the character string cString to the end of the remote file.
RETURN VALUEnResultCode. Numeric. REMARKS - Represents the FTP command DELE used to delete files on an FTP server. PARAMETERS cRemoteFile. Character. Specifies the URL of the remote file. DESCRIPTION
Deletes a remote file from an FTP server. The full URL to the file should be passed.
RETURN VALUEnResultCode. Numeric. REMARKS - Downloads a remote file to a local file using the FTP/FTPS protocol. PARAMETERS cRemoteFile. Character. Specifies the URL of the remote file. cLocalFile. Character. Specifies the name of the local file. nResumeFrom. Numeric. Optional. Specifies the offset in number of bytes that you want the transfer to start from. Set this option to 0 to make the transfer start from the beginning (effectively disabling resume). For FTP, set this option to -1 to make the transfer start from the end of the target file. cRange. Character. Optional. This 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 (using standard MIME separation techniques). DESCRIPTION
Downloads a file from an FTP server to a local file.
RETURN VALUEnResultCode. Numeric. REMARKS You can use the CurlOptResumeFrom property instead of the nResumeFrom parameter. While the file is downloading, you can call FtpCancel to cancel the transfer in progress. When using the FileDownloadFile method, there is no need to specify the file protocol in the url (file://) Downloads a remote file, returns the contents as a character string. using the FTP/FTPS protocol. PARAMETERS cRemoteFile. Character. Specifies the URL of the remote file. nResumeFrom. Numeric. Optional. Specifies the offset in number of bytes that you want the transfer to start from. Set this option to 0 to make the transfer start from the beginning (effectively disabling resume). For FTP, set this option to -1 to make the transfer start from the end of the target file. cRange. Character. Optional. This 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 (using standard MIME separation techniques). DESCRIPTION
Downloads a remote file and returns the downloaded file data as a string.
RETURN VALUEString REMARKS Do not use with files larger than 16777184 bytes due to a VFP limitation. In fact, with files larger than a few KB FtpDownloadFile is the way to go. When using the FileDownloadString method, there is no need to specify the file protocol in the url (file://) VALUE TYPE Numeric DEFAULT VALUE 0 READ/WRITE Read only. REMARKS Specifies the number of files and directories returned by the last FtpList method call. VALUE TYPE Array DEFAULT VALUE ? READ/WRITE Read only. REMARKS This array has FtpFileCount rows and four columns, contains information on the last call to FtpList: Column 1 File name, Character Column 2 File size, Numeric Column 3 DateTime last modified, DateTime Column 4 File attributes, Character, "A" for file or "D" for directory Attempts to retrieve the date-time stamp of a remote file using the FTP/FTPS protocol. PARAMETERS cRemoteFile. Character. Specifies the URL of the remote file. DESCRIPTION
Gets the date and time of a remote file. This is GMT time.
RETURN VALUEDateTime. REMARKS On failure, returns an empty DateTime value. Represents the FTP command FEAT that is used to retrieve the features of an FT server. PARAMETERS cURL. Character. DESCRIPTION
Returns a list of "|" separated features, for example:
"MDTM|REST STREAM|SIZE|MLST type*;size*;modify*;|MLSD|AUTH SSL|AUTH TLS|UTF8|CLNT|MFMT"
RETURN VALUECharacter. REMARKS Used by the class itself to find out if the remote server supports MLST. Attempts to get the size of a remote file using the FTP/FTPS protocol. PARAMETERS cRemoteFile. Character. Specifies the URL of the remote file. DESCRIPTION
Get the size of a remote file.
RETURN VALUENumeric REMARKS Returns -1 on failure. Fills the FtpFiles array property with information about the contents of an FTP directory PARAMETERS String URL DESCRIPTION
This method first calls the FtpGetFeatures method to find out if the FTP server supports the MLSD command. If it does, it then sends an MLSD command and parses the result, filling the FtpFiles array property.
If the FTP server does not support the MLSD command, then the FtpListDirectory method is called to get the list of files and folders, and then FtpListDirectoryDetails is called, just to identify files from directories. Then FtpGetFileSize and FtpGetDateTimeStamp is called for each file/directory, and the FtpFiles array property is filled. All this can take quite some time.
RETURN VALUENumeric. The total number of files and directories found. REMARKS The class makes some assumptions about the format of the replies of the MLST, LIST and NLST commands. This may be wrong. Represents the FTP command NLIST that gets a short listing of the files. PARAMETERS String URL DESCRIPTION
This command just returns the raw directory listing sent from the FTP server as a character string. No parsing is done by the class.
RETURN VALUECharacter. REMARKS The URL should point to a directory, not a file. Represents the FTP command LIST that gets a detailed listing of the files. PARAMETERS String URL DESCRIPTION
This command just returns the raw directory listing sent from the FTP server as a character string. No parsing is done by the class.
RETURN VALUECharacter. REMARKS The URL should point to a directory, not a file. Represents the FTP command MKD that creates a directory. PARAMETERS cRemoteDir. Character. Specifies the URL of the remote directory. DESCRIPTION
Creates a remote directory in an FTP server.
RETURN VALUEnResultCode. Numeric. REMARKS - Represents the FTP command NOOP PARAMETERS String DESCRIPTION
Just sends a NOOP command to an FTP server.
RETURN VALUEnResultCode. Numeric. REMARKS Can be used to keep a connection alive. Represents the FTP command RMD that removes a directory PARAMETERS String DESCRIPTION
Deletes a remote directory in an FTP server.
RETURN VALUEnResultCode. Numeric. REMARKS - Represents the FTP commands RNFR and RNTO that rename a file. PARAMETERS cRemoteFileOldName. Character. Specifies the old URL of the remote file. cRemoteFileNewName. Character. Specifies the new URL of the remote file. DESCRIPTION
Renames a remote FTP server file.
RETURN VALUEnResultCode. Numeric. REMARKS - Uploads a local file to a remote file using the FTP/FTPS protocol. PARAMETERS cRemoteFile. Character. Specifies the URL of the remote file. cLocalFile. Character. Specifies the name of the local file. nResumeFrom. Numeric. Optional. Specifies the offset in number of bytes that you want the transfer to start from. Set this option to 0 to make the transfer start from the beginning (effectively disabling resume). For FTP, set this option to -1 to make the transfer start from the end of the target file. DESCRIPTION
Uploads a local file to an FTP server file.
RETURN VALUEnResultCode. Numeric. REMARKS For FTP, pass -1 in nResumeFrom to make the transfer start from the end of the target file (useful to continue an interrupted upload). When using the FileUploadFile method, there is no need to specify the file protocol in the url (file://) Uploads a string to a remote file using the FTP/FTPS protocol. PARAMETERS cRemoteFile. Character. Specifies the URL of the remote file. cString. Character. Specifies the data to append. nResumeFrom. Numeric. Optional. Specifies the offset in number of bytes that you want the transfer to start from. Set this option to 0 to make the transfer start from the beginning (effectively disabling resume). For FTP, set this option to -1 to make the transfer start from the end of the target file. DESCRIPTION
Uploads a string to an FTP server file.
RETURN VALUEnResultCode. Numeric. REMARKS When using the FileUploadString method, there is no need to specify the file protocol in the url (file://) Downloads a remote file to a local file using the HTTP/HTTPS protocol. REMARKS See FtpDownloadFile Downloads a remote file using the HTTP/HTTPS protocol, returns the contents as a character string. REMARKS See FtpDownloadString Attempts to retrieve the date-time stamp of a remote file using the HTTP/HTTPS protocol. REMARKS See FtpGetDateTimeStamp Attempts to get the size of a remote file using the HTTP/HTTPS protocol. REMARKS See FtpGetFileSize
HttpPostFile(cUrl, cLocalFile)
Posts a local file to a remote server using the HTTP/HTTPS protocol.REMARKS This is not tested, since I don´t have the need for it. If you need to use POST, contact me to explain your needs so I can finish this.
HttpPostString(cUrl, cString)
Posts a string to a remote server using the HTTP/HTTPS protocol.REMARKS This is not tested, since I don´t have the need for it. If you need to use POST, contact me to explain your needs so I can finish this. Uploads a local file to a remote file using the HTTP/HTTPS protocol PUT method. REMARKS See FtpUploadFile Uploads a string to a remote file using the HTTP/HTTPS protocol PUT method. REMARKS See FtpUploadString This property stores the name of the file where verbose information about libcurl operations will be stored. The DEFAULT VALUE: is "libcurl.log" CurlOptVerbose must be TRUE to output debug info to this file. If empty, the DEFAULT VALUE is libcurl.log VALUE TYPE Character. DEFAULT VALUE None READ/WRITE Yes. REMARKS The log file is never deleted by the class, and debug information is always appended to it. Set CurlOptVerbose to TRUE to log debug information to this file. Each line starts with a code that indicates the type of information of the line. Possible values are:
If the line contains the PASS ftp command, the password is masked. You hardly ever want CurlOptVerbose set to TRUE in production use, you will almost always want this when you debug/report problems. Deletes the log file. PARAMETERS None DESCRIPTION
-
REMARKS- This event gets fired about once every second when CurlOptProgress is TRUE and a transfer is in progress. PARAMETERS nBytesTotal, nBytesDone, nBytesLeft, nSpeed, nTimeTotal, nTimeDone, nTimeLeft DESCRIPTION
-
REMARKSUse this event to update the user interface with info about the current process. |
Carlos Alloatti
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
This is a mirror of what was originally at www.ctl32.com.ar by CARLOS ALLOATTI, rescued by the webarchive.org - Fantastic VFP Classes, like the CTL32 ActiveX: Scrollable container, BalloonTip, ScrollBars, DatePicker, FormState, Gripper, ProgressBar, StatusBar, TrackBar, Animation, ContextMenu, Month Calendar, Raw Print, Registry, SizeBox, FormState, FTP, LibCurl
Ctl32 LibCurl wrapper class
Subscribe to:
Posts (Atom)
No comments:
Post a Comment