curl.Easy
generated from ../src/mod_curl/easy.cppUse this class to create a libcurl easy session.
Constants
Class Methods
strerror
strerror(Code) : String
| Name | Type | Default | Description |
|---|---|---|---|
| Code | Integer |
Return string describing error code
Constructor
Easy
Easy()
This creates a new libcurl easy session. It is automatically cleaned up.
Properties
| Name | Type | Description |
|---|---|---|
| HttpContentDecoding | Boolean | If set to false, content decoding will be disabled. If set to true it is enabled. Note however that libcurl has no default content decoding but requires you to use encoding for that. |
| append | Boolean | Tells the library to append to the remote file instead of overwrite it. This is only useful when uploading to an ftp site. |
| autoReferer | Boolean | Set to true to enable this. When enabled, libcurl will automatically set the Referer: field in requests where it follows a Location: redirect. |
| bufferSize | Integer | Set the preferred size (in bytes) for the receive buffer in libcurl. The main point of this would be that the write callback gets called more often and with smaller chunks. This is the same as calling setopt with curl.Option.BUFFERSIZE. |
| cainfo | String | A String naming a file holding one or more certificates to verify the peer with. |
| capath | String | A String naming a directory holding multiple CA certificates to verify the peer with. |
| connectOnly | Boolean | A true value tells the library to perform any required proxy authentication and connection setup, but no data transfer. |
| connectTimeout | Integer | This should contain the 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. |
| connectTimeoutMS | Double | Like connectTimeout but takes number of milliseconds instead. |
| cookie | String |
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. |
| cookieFile | String |
The name of a file holding cookie data to read. 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 set this property multiple times, you just add more files to read. Subsequent files will add more cookies. |
| cookieJar | String | This will make curl write all internally known cookies to the specified file when curl is destroyed. 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. |
| cookieList | String | Cookie can be either in Netscape / Mozilla format or just regular HTTP-style header (Set-Cookie: ...) format. If cURL cookie engine was not enabled it will enable its cookie engine. Passing a magic string "ALL" will erase all cookies known by cURL. (Added in 7.14.1) Passing the special string "SESS" will only erase all session cookies known by cURL. (Added in 7.15.4) Passing the special string "FLUSH" will write all cookies known by cURL to the file specified by cookieJar. |
| cookieSession | Boolean | It will force libcurl to ignore all cookies it is about to load that are "session cookies" from the previous session. By default, libcurl always stores and loads all cookies, independent if they are session cookies are not. Session cookies are cookies without expiry date and they are meant to be alive and existing for this "session" only. |
| crlf | Boolean | Convert Unix newlines to CRLF newlines on transfers. |
| customRequest | String | This 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. |
| dirListOnly | Boolean | A true value tells the library 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. |
| dnsCacheTimeout | Integer | This sets the timeout in seconds. Name resolves will be kept in memory for this number of seconds. Set to zero (0) to completely disable caching, or set to -1 to make the cached entries remain forever. By default, libcurl caches this info for 60 seconds. This is the same as calling setopt with curl.Option.DNS_CACHE_TIMEOUT. |
effectiveUrl ![]() |
String | Returns the last used effective URL. |
| egdSocket | String | Path name to the Entropy Gathering Daemon socket. It will be used to seed the random engine for SSL. |
| encoding | String | Sets the contents of the Accept-Encoding: header sent in an HTTP request. |
error ![]() |
String | Returns the last error as a String |
| filetime | Boolean | When true, libcurl will attempt to get the modification date of the remote document in this operation. |
| followLocation | Boolean | True tells the library to follow any Location: header that the server sends as part of an HTTP header. |
| forbidReuse | Boolean | Set to true to make the next transfer explicitly close the connection when done. Normally, libcurl keep all connections alive when done with one transfer in case there comes a succeeding one that can re-use them. |
| freshConnect | Boolean | Set to true to make the next transfer use a new (fresh) connection by force. If the connection cache is full before this connection, one of the existing connections will be closed as according to the selected or default policy. |
| ftpAccount | String | 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. |
| ftpAlternativeToUser | String | A string which will be used to authenticate if the usual FTP "USER user" and "PASS password" negotiation fails |
| ftpCreateMissingDirs | Boolean | curl will attempt to create any remote directory that it fails to CWD into. CWD is the command that changes working directory. |
| ftpFileMethod | Integer | This option controls what method libcurl should use to reach a file on a FTP(S) server. See curl.FileMethod. |
| ftpPort | String | This 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, 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. |
| ftpResponseTimeout | Integer | Causes curl to set a 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. |
| ftpSSLAuth | Integer | See curl.FtpAuth |
| ftpSSLCCC | Integer | See curl.FtpSSL. 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. |
| ftpSkipPasvIp | Boolean | If set to a true value, it instructs libcurl to not use the IP address the server suggests in its 227-response to libcurl's PASV command when libcurl connects the data connection. Instead libcurl will re-use the same IP address it already uses for the control connection. But it will use the port number from the 227-response. |
| ftpUseEPRT | Boolean | Tells curl to use the EPRT (and LPRT) command when doing active FTP downloads. |
| ftpUseEPSV | Boolean | Tells curl to use the EPSV command when doing passive FTP downloads. |
| header | Boolean | Set this to true tells the library to include the header in the body output. This is the same as calling setopt with curl.Option.HEADER when set. |
| http200Aliases | Array | Pass an array with 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". |
| httpAuth | Integer | Tell libcurl what authentication method(s) to use. See curl.Auth |
| httpGet | Boolean |
When true, 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 setting httpGet to true, it will automatically set noBody. |
| httpHeader | Array | An array with String elements which are HTTP headers to pass to the server in your HTTP request. If you add a header that is otherwise generated and used by libcurl internally, your added one will be used instead. 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: "". The headers included in the array must not be CRLF-terminated, because curl adds CRLF after each header item. Failure to comply with this will result in strange bugs because the server will most likely ignore part of the headers you specified. |
| httpPost | Form | A multipart/formdata HTTP POST. |
| httpProxyTunnel | Boolean | Set the parameter to true to get the library to tunnel all operations through a given HTTP proxy. This is the same as calling setopt with curl.Option.HTTPPROXYTUNNEL. |
| httpTransferDecoding | Boolean | If set to false, transfer decoding will be disabled, if set to true it is enabled (default). libcurl does chunked transfer decoding by default unless this option is set to zero. |
| httpVersion | Integer | This forces libcurl to use the specific HTTP versions. This is not sensible to do unless you have a good reason. See curl.Http |
| ignoreContentLength | Boolean | Ignore the Content-Length header. This is useful for Apache 1.x (and similar servers) which will report incorrect content length for files over 2 gigabytes. If this option is used, curl will not be able to accurately report progress, and will simply stop the download when the server ends the connection. |
| inFileSize | Integer | When uploading a file to a remote site, this option should be used to tell libcurl what the expected size of the infile is. |
| interface | String | 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. This is the same as calling setopt with curl.Option.INTERFACE. |
| ipResolve | Integer | Allows an application to select what kind of IP addresses to use when resolving host names. This is only interesting when using host names that resolve addresses using more than one version of IP. See curl.IPResolve. |
| keyPasswd | String | It will be used as the password required to use the sslKey or sshPrivateKeyFile private key. |
| krbLevel | String | Set the kerberos security level for FTP; this also enables kerberos awareness. This is a string, 'clear', 'safe', 'confidential' or 'private'. If the string is set but doesn't match one of these, 'private' will be used. Set the property to null to disable kerberos support for FTP. |
| localPort | Integer | This sets the local port number of the socket used for connection. This is the same as calling setopt with curl.Option.LOCALPORT. |
| localPortRange | Integer | This is the number of attempts libcurl should do to find a working local port number. It starts with the given localPort and adds one to the number for each retry. Setting this value to 1 or below will make libcurl do only one try for exact port number. Note that port numbers by nature is a scarce resource that will be busy at times so setting this value to something too low might cause unnecessary connection setup failures. This is the same as calling setopt with curl.Option.LOCALPORTRANGE. |
| lowSpeedLimit | Integer | It contains the transfer speed in bytes per second that the transfer should be below during lowSpeedTime seconds for the library to consider it too slow and abort. |
| lowSpeedTime | Integer | It contains the time in seconds that the transfer should be below the lowSpeedLimit for the library to consider it too slow and abort. |
| maxConnects | Integer |
The set number will be the persistent connection cache size. The set amount
will be the maximum amount of simultaneously open connections that libcurl
may cache in this easy handle. Default is 5, and there isn't much point in
changing this value unless you are perfectly aware of how this work and
changes libcurl's behaviour. This concerns connection using any of the
protocols that support persistent connections.
When reaching the maximum limit, curl closes the oldest one in the cache to prevent the number of open connections to increase. |
| maxFileSize | Integer | This allows you to specify the maximum size (in bytes) of a file to download. If the file requested is larger than this value, the transfer will not start and curl.Error.FILESIZE_EXCEEDED will be returned. |
| maxRecvSpeed | Double | 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 property value. |
| maxRedirs | Integer | The redirection limit. |
| maxSendSpeed | Double | 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 this property. |
| netrc | Integer | This parameter controls the preference of libcurl between using user names and passwords from your ~/.netrc file, relative to user names and passwords in the URL supplied with url. See curl#Netrc for values. |
| netrcFile | String | Contains the full path name to the file you want libcurl to use as .netrc file. If this option is omitted, and netrc is set, libcurl will attempt to find the a .netrc file in the current user's home directory. |
| newDirectory | Integer | Permissions that will be assigned to newly created directories on the remote server. The default value is 0755, but any valid value can be used. |
| newFilePerms | Integer | Permissions that will be assigned to newly created files on the remote server. The default value is 0644, but any valid value can be used. |
| noBody | Boolean | Tells the library to not include the body-part in the output. |
| noProgress | Boolean | Set this to true tells the library to shut off the built-in progress meter completely. This is the same as calling setopt with curl.Option.NOPROGRESS when set. |
| port | Integer | Set the remote port number to connect to, instead of the one specified in the URL or the default port for the used protocol. This is the same as calling setopt with curl.Option.PORT. |
| post | Boolean | Tells the library to do a regular HTTP post. |
| postFields | wxMemoryBuffer | A buffer with t4he full data to post in an HTTP POST operation. Make sure that the data is formatted the way you want the server to receive it. libcurl will not convert or encode it for you. Most web servers will assume this data to be url-encoded. The buffer is not copied by the library: as a consequence, they must be preserved by the calling application until the transfer finishes. |
| postQuote | Array | An array with FTP or SFTP commands to pass to the server after your ftp transfer request. |
| preQuote | Array | An array with FTP commands to pass to the server after the transfer type is set. |
| proxy | String | Set HTTP proxy to use. This is the same as calling setopt with curl.Option.PROXY. |
| proxyAuth | Integer | Tells libcurl what authentication method(s) to use for the proxy authentication. |
| proxyPort | Integer | Set the proxy port to connect to unless it is specified in the proxy string. This is the same as calling setopt with curl.Option.PROXYPORT. |
| proxyUserPwd | String | |
| quote | Array | An array with 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). |
| randomFile | String | 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 the SSL connection will become. |
| range | String | A property 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 null to this option to disable the use of ranges. |
| referer | String | This 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. |
| resumeFrom | Integer | It contains 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 (useful to continue an interrupted upload). |
| sshAuthTypes | Integer | See curl.SSHAuth |
| sshHostPublicKeyMD5 | String | A string containing 32 hexadecimal digits. The string should be the 128 bit MD5 cheksum of the remote host's public key, and libcurl will reject the connection to the host unless the md5sums match. This option is only for SCP and SFTP transfers. |
| sshPrivateKeyFile | String | A file name for the private key. |
| sshPublicKeyFile | String | A file name for the public key. |
| sslCert | String | The string should be the file name of a certificate. |
| sslCertType | String | The string should be the format of the certificate. Supported formats are "PEM" and "DER" |
| sslCipherList | String | A String holding the list of ciphers to use for the SSL connection. The list must be syntactically correct, it 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. |
| sslEngine | String | It will be used as the identifier for the crypto engine you want to use for your private key. |
| sslEngineDefault | String | Sets the actual crypto engine as the default for (asymmetric) crypto operations. |
| sslKey | String | The string should be the file name of a private key. The default format is "PEM" and can be changed with sslKeyType. |
| sslKeyType | String | The string should be the format of the private key. Supported formats are "PEM", "DER" and "ENG". |
| sslSessionIdCache | Boolean | False disables libcurl's use of SSL session-ID caching. Set this to true to enable it. |
| sslVerifyHost | Integer | This option determines whether libcurl verifies that the server cert is for the server it is known as. |
| sslVerifyPeer | Boolean | This property determines whether curl verifies the authenticity of the peer's certificate. A true value means curl verifies. |
| sslVersion | Integer | See curl.SSLVersion |
| tcpNoDelay | Boolean | Setting this option to true will disable TCP's Nagle algorithm. The purpose of this algorithm is to try to minimize the number of small packets on the network (where "small packets" means TCP segments less than the Maximum Segment Size (MSS) for the network). This is the same as calling setopt with curl.Option.TCP_NODELAY |
| telnetOptions | Array | The elements should be in the format <option=value>. libcurl supports the options 'TTYPE', 'XDISPLOC' and 'NEW_ENV'. See the TELNET standard for details. |
| timeCondition | Integer | |
| timeValue | Double | |
| timeout | Integer | 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. |
| timeoutMs | Double | Like timeout but takes number of milliseconds instead. |
| transferText | Boolean | When true, it tells the library to use ASCII mode for ftp transfers, instead of the default binary transfer. For win32 systems it does not set the stdout to binary mode. |
| unrestrictedAuth | Boolean | True tells the library it can continue to send authentication (user+password) when following locations, even when hostname changed. |
| upload | Boolean | When true, it tells the library to prepare for an upload. |
| url | String | The actual URL to deal with. This is the same as calling setopt with curl.Option.URL. |
| useSSL | Integer | See curl.UseSSL |
| userPwd | String | A string which should be [user name]:[password] to use for the connection. |
| useragent | String | This 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. |
| verbose | Boolean | Set this to true to get the library to display a lot of verbose information about its operations. This is the same as calling setopt with curl.Option.VERBOSE. |
Methods
duphandle
duphandle() : Easy
This function will return a new Easy curl object, a duplicate, using all the options of this object. The new object will not inherit any state information, no connections, no SSL sessions and no cookies.
escape
escape(Str) : String
| Name | Type | Default | Description |
|---|---|---|---|
| Str | String |
URL encodes the given string. This function converts the given input string to an URL encoded string and returns that as a new 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).
escape
escape(Str) : String
| Name | Type | Default | Description |
|---|---|---|---|
| Str | String |
URL encodes the given string. This function converts the given input string to an URL encoded string and returns that as a new 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).
getinfo
getinfo(info) : Mixed
| Name | Type | Default | Description |
|---|---|---|---|
| info | Integer |
Request internal information from the curl session with this function.
perform
perform() : Integer
This function is called after all the setopt calls are made,
and will perform the transfer as described in the options.
You can do any amount of calls to perform while using the same object.
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
setopt between the invokes to set options for the
following perform.
You must never call this function simultaneously from two
places using the same object. Let the function return first before invoking
it another time. If you want parallel transfers, you must use several curl
objects.
reset
reset()
Re-initializes all options previously set on a specified CURL object to
the default values.
It does not change the following information kept in the object: live
connections, the Session ID cache, the DNS cache, the cookies and shares.
setopt
setopt(opt,
parameter) : Integer
| Name | Type | Default | Description |
|---|---|---|---|
| opt | Integer | An option | |
| parameter | Mixed |
setopt(Options) : Integer
| Name | Type | Default | Description |
|---|---|---|---|
| Options | Object |
Set options for curl. You can set properties using an object or by calling setopt several times.
var options = new Object();
options[curl.Option.URL] = "http://www.sitepoint.com";
options[curl.Option.HEADER] = 1;
var c = new curl.Easy();
c.setopt(options);
is the same as
var c = new curl.Easy();
c.setopt(curl.Option.URL, "http://www.sitepoint.com");
c.setopt(curl.Option.HEADER, 1);
unescape
unescape(Str) : String
| Name | Type | Default | Description |
|---|---|---|---|
| Str | String |
This function converts the given URL encoded input string to a plain string
Events
| onWrite | The function is called as soon as there is data received that needs to be saved. The data is passed as a wxMemoryBuffer. The return value should be the number of bytes actually used from the buffer. When this amount differs from the size of the buffer, curl will report an error and will abort the transfer. |
| onRead | This function gets called by libcurl as soon as it needs to read data in order to send it to the peer. This function must return a wxMemoryBuffer which contains the data. Return 'null' to stop the transfer. |
| onProgress | This function gets called by curl instead of its internal equivalent with a frequent interval during operation (roughly once per second) no matter if data is being transfered or not. Unknown/unused argument values passed to the callback will be set to zero (like if you only download data, the upload size will remain 0). Returning a non-zero value from this callback will cause libcurl to abort the transfer. Arguments are: download total, download now, upload total, upload now. |

© 2002 - 2007 Franky Braem.