Command:  tsNetCABundle

 

Sets a CA bundle to be used for SSL connections within the tsNet external.

tsNetCABundle <pCAFile>

 

Operating Systems supported: Mac OS X, Windows, Linux, iOS and Android

Platforms supported:  Desktop, Server and Mobile

Example:

   tsNetCABundle “/etc/ssl/ca-bundle.crt”

Parameters:

  • pCAFile: The path to the file to be used as the CA bundle.

 

Command:  tsNetClose

 

Closes all open connections and disables the tsNet external.

tsNetClose

 

Operating Systems supported: Mac OS X, Windows, Linux, iOS and Android

Platforms supported:  Desktop, Server and Mobile

Example:

   tsNetClose

 

Command:  tsNetCloseConn

 

Removes the specified connection from memory.

tsNetCloseConn <pConnectionID>

 

Operating Systems supported: Mac OS X, Windows, Linux, iOS and Android

Platforms supported:  Desktop, Server and Mobile

Example:

   tsNetCloseConn “myConnID”

Parameters:

  • pConnectionID: The identifier of the transfer to remove.

The result:

The tsNetCloseConn command sets the result to empty if the connection was found. If the connection identifier is invalid an error will be returned that starts with “tsneterr:”.

 

Command:  tsNetCreateMissingDirs

 

Enable or disable automatic creation of missing directories when uploading files via FTP or SFTP.

tsNetCreateMissingDirs <pEnable>

 

Operating Systems supported: Mac OS X, Windows, Linux, iOS and Android

Platforms supported:  Desktop, Server and Mobile

Example:

   tsNetCreateMissingDirs true

Parameters:

  • pEnable: Set to either true or false. The default value is false.

 

Function:  tsNetCustom

 

Send an asynchronous custom request to a server.

tsNetCustom(<pConnectionID>, <pURL>, <pRequest>, <pHeaders>, <pCallback>, [<pSettings>])

 

Operating Systems supported: Mac OS X, Windows, Linux, iOS and Android

Platforms supported:  Desktop, Server and Mobile

Example 1:

   local tHeaders, tResult
   put tsNetCustom(“1”, “http://www.livecode.com/file.dat”, “DELETE”, \
      tHeaders, “transferComplete”) into tResult

Example 2:

   local tHeaders, tResult
   put tsNetCustom(“1”, “ftp://user:pass@ftp.example.com/”, “NLST”, \
      tHeaders, “transferComplete”) into tResult

Example 3:

   on transferComplete pID, pResult, pBytes, pCurlCode
      local tData, tHeaders
      if pCurlCode is not 0 then
         answer tsNetRetrError(pID)
      end if
      put tsNetRetrData(pID, tError) into tData
      tsNetCloseConn pID
      answer “Server returned:” & tData
   end transferComplete

Parameters:

  • pConnectionID: A arbitrary user-defined label for the connection that is used when retrieving any details of the transfer.
  • pURL: The URL formatted as ‘scheme://host:port/path’ and URL-encoded as outlined in [RFC 3986](http://www.ietf.org/rfc/rfc3986.txt). The following schemes are supported: ‘tftp’, ‘ftp’, ‘ftps’, ‘http’, ‘https’ and ‘sftp’. For SFTP connections (Business Edition only), the path is not relative to the user’s home directory, but must be the full system path.
  • pRequest: For HTTP transfers, specify the custom HTTP method to be sent in the request. This is useful particularly for sending HTTP DELETE requests. For FTP/SFTP transfers, this is the raw command (e.g. NLST) that should be used to send a specialised directory listing command. SFTP commands are only supported in the Business Edition of LiveCode.
  • pHeaders: For HTTP(s) connections, the headers to be sent to the server. For all other protocols, leave this blank.
  • pCallback: Specify a callback message to be sent to the current object when the transfer is complete.
  • pSettings: An array of additional settings that control how the transfer is initiated.

Returns:

The tsNetCustom function returns empty on success. On error, the return value will be a string containing the error starting with “tsneterr:”.

Description:

This function sends a callback message on completion. Use tsNetRetrData to access the returned data. To save memory, it is recommended to call tsNetCloseConn when the connection is no longer needed.

The callback message will be sent with four parameters: the connection identifier, the status code sent back by the server, the number of bytes transferred and the cURL result code.

The cURL result code parameter in the callback message will be 0 for successful transfers. For any errors, further information can be
retrieved by calling the tsNetRetrError function.

The settings array can consist of the following elements (not all of the settings make sense for every possible transfer type): 

"byte_range": (Introduced in tsNet version 1.4.0) Specify the range of data to be downloaded. This can be in the format of “X-Y”, “X-“, “-Y” or “X-Y,N-M” where X, Y, N and M and byte indexes. Some HTTP servers may ignore this request.

"cookie_file": (Introduced in tsNet version 1.4.0) Specify a filename to load cookies from. If this setting is present, the internal cookie engine will be enabled and the cookies stored in the file loaded into the engine.

"cookies": (Introduced in tsNet version 1.4.0) The contents of this setting will be used to set a cookie in a HTTP request. It should be in the format of COOKIE_NAME=COOKIE_CONTENTS. Specify multiple cookies by separating them with a semi-colon. This setting does not enable the internal cookie engine of tsNet.

"cookie_jar": (Introduced in tsNet version 1.4.0) Specify a filename to write all known cookies to. If this setting is present, the internal cookie engine of tsNet will be enabled. Note that this file will only be written to at unspecified times. Use the “cookie_list” setting below to force the file to be updated.

"cookie_list": (Introduced in tsNet version 1.4.0) Set this to a list of cookies (one per line) in Netscape / Mozilla format or regular HTTP (Set-Cookie:) style format to add to the internal cookie engine. There are also several strings that when passed to this setting will perform additional actions. Passing in the string “ALL” will erase all cookies held in memory. “SESS” will erase all session cookies in memory. “FLUSH” will write all cookies stored in memory to the file specified by the “cookie_jar” setting. “RELOAD” will reload all cookies from file specified by “cookie_file”.

"disable_eprt": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from using the EPRT command when performing active FTP transfers.

"disable_epsv": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from using the EPSV command when performing passive FTP transfers.

"dont_modify_path": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from squashing “/../” and “/./” components from the URL path. RFC 3986 specifies that these should be removed.

“enable_tcp_keepalive”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to send TCP keepalive probes.

“expect100_timeout”: (Introduced in tsNet version 1.4.0) Specify the number of milliseconds to wait for a response with a HTTP 100 (Continue) or HTTP 417 (Expectation Failed) status after setting a HTTP request containing an Expect: 100-continue header. The default is 1000ms.

"fail_on_http_error": Set to true to specify that HTTP status codes greater than 400 should be considered an error.

"force_basic_auth": (Introduced in tsNet version 1.3.1) Set to true to force HTTP basic authentication rather than allow tsNet to detect what authentication methods are supported by the server.

"force_digest_auth": (Introduced in tsNet version 1.3.5) Set to true to force HTTP digest authentication rather than allow tsNet to detect what authentication methods are supported by the server.

“ftp_filemethod”: (Introduced in tsNet version 1.4.0) Set this to “nocwd” or “singlecwd” to change the method used by FTP to reach a particular file. Using “nocwd” will ensure all FTP commands use the full path to the file on the server. Using “singlecwd” will make tsNet issue a single CWD command to change to the directory that the file resides in before performing any other action on the file. The default is to issue a CWD command for each path part in the URL prior to performing any other action on the file in accordance with RFC 1738.

“ftp_ssl_ccc”: (Introduced in tsNet version 1.4.0) Set this to “passive” or “active” to disable the SSL/TLS encryption after authenticating with the FTP server. All further communication on the command channel with the FTP server will be unencrypted. Use “passive” to only disable the encryption after the server requests it. Setting this to “active” will initiate the encryption shutdown.

“ftp_user_alt”: (Introduced in tsNet version 1.4.0) Specify an alternate string to use for authentication if the standard FTP username and password negotiation fails.

“if_mod_since”: (Introduced in tsNet version 1.4.0) If the last modified time (in seconds since 1 Jan 1970) of the file is later than this, then download the file.

“if_unmod_since”: (Introduced in tsNet version 1.4.0) If the last modified time (in seconds since 1 Jan 1970) of the file is earlier than this, then download the file.

“ignore_content_length”: (Introduced in tsNet version 1.4.0) Set this option to true to ignore the content length specified in HTTP or FTP transfers. tsNet will complete the download when the server ends the connection.

“interface”: (Introduced in tsNet version 1.4.0) Specify the interface, IP address or host name to be used for the outgoing connection.

“junk_session_cookies”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to ignore all cookies loaded via the “cookie_file” setting that are session cookies.

“keepalive_idle”: (Introduced in tsNet version 1.4.0) When “enable_tcp_keepalive” is set to true, use this setting to specify the number of second to wait while the connection is idle before sending keepalive probes. The default is 60 seconds.

“keepalive_interval”: (Introduced in tsNet version 1.4.0) When “enable_tcp_keepalive” is set to true, use this setting to specify the number of seconds to wait between sending keepalive probes. The default is 60 seconds.

“local_port_range”: (Introduced in tsNet version 1.4.0) Set the number of consecutive ports above the port specified by the “local_port_start” setting to try when finding an available port for a connection.

“local_port_start”: (Introduced in tsNet version 1.4.0) Set the local port number of the socket to be used for the connection. It is recommended to also set “local_port_range” if you use this setting.

“max_file_size”: (Introduced in tsNet version 1.4.0) Specify the maximum size of a file to download. If the file exceeds this value, the transfer will not start. This option has no affect is the file size is not known prior to the download.

“max_recv_speed”: (Introduced in tsNet version 1.4.0) This option specifies the number of bytes per second to limit a download transfer to. Setting this to 0 disables any limiting.

“max_send_speed”: (Introduced in tsNet version 1.4.0) This option specifies the number of bytes per second to limit an upload transfer to. Setting this to 0 disables any limiting.

"no_reuse": Set to true to specify that the connection to the server should be disconnected and not left open for any future connections.

"no_transfer": Set to true to connect to the server but not perform any transfer.

"password": Set to a string containing the password to be used in any authentication requests from the server.

"post_commands": (Business Edition only) Set to a list of raw FTP/SFTP commands (one per line) that should be executed on the server directly after any transfer.

“post_on_301”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 301 response.

“post_on_302”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 302 response.

“post_on_303”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 303 response.

"pre_commands": (Business Edition only) Set to a list of raw FTP/SFTP commands (one per line) that should be executed on the server prior to any transfer.

“proxy_auth_basic”: (Introduced in tsNet version 1.4.0) Set this option to true to force tsNet to use basic authentication when authenticating with a proxy server.

“proxy_auth_digest”: (Introduced in tsNet version 1.4.0) Set this option to true to force tsNet to use digest authentication when authenticating with a proxy server.

"proxy_headers": Set to a list of headers (one per line) that should be sent to any proxy server that is being used.

“proxy_http_10”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to use HTTP/1.0 for any CONNECT tunnelling.

“referer”: (Introduced in tsNet version 1.4.0) The contents of this setting will be used as the HTTP Referer: header sent as part of a HTTP request.

“resolve_hosts”: (Introduced in tsNet version 1.4.0) Specify a list (one per line) of host to IP addresses to use when resolving host name for a request. Each line must be in the format of “HOSTNAME:PORT:ADDRESS”.

“resume_from”: (Introduced in tsNet version 1.4.0) Specify the number of bytes at which you want a transfer to start downloading or uploading.

"save_sent_headers": Set to true to specify that external should store a copy of all the headers that it sends to the server. This must be set to true to use the tsNetRetrSentHeaders function.

“skip_pasv_ip”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to ignore the IP address from the server’s 227 response message. tsNet will connect the data connection via the same IP address it used to set up the control connection.

“ssl_ciphers”: (Introduced in tsNet version 1.4.0) Use this setting to specify a list of SSL ciphers (separated by colons) to be used when negotiating SSL connections.

“ssl_client_cert”: (Introduced in tsNet version 1.4.1) Specify the filename of a client SSL certificate to use for authentication to the server.

“ssl_client_cert_type”: (Introduced in tsNet version 1.4.1) Set to the format of the client SSL certificate. Supported formats are “PEM”, “DER” and “P12”.

“ssl_client_key”: (Introduced in tsNet version 1.4.1) Specify the filename of a SSL private key file that matches the client SSL certificate.

“ssl_client_key_pass”: (Introduced in tsNet version 1.4.1) Set to the password for the SSL private key.

“ssl_client_key_type”: (Introduced in tsNet version 1.4.1) Set to the format of the SSL private key. Supported formats are “PEM” and “DER”.

“ssl_proxy_client_cert”: (Introduced in tsNet version 1.4.1) Specify the filename of a proxy client SSL certificate to use for authentication to the HTTP proxy.

“ssl_proxy_client_cert_type”: (Introduced in tsNet version 1.4.1) Set to the format of the proxy client SSL certificate. Supported formats are “PEM”, “DER” and “P12”.

“ssl_proxy_client_key”: (Introduced in tsNet version 1.4.1) Specify the filename of a SSL private key file that matches the proxy client SSL certificate.

“ssl_proxy_client_key_pass”: (Introduced in tsNet version 1.4.1) Set to the password for the SSL private key.

“ssl_proxy_client_key_type”: (Introduced in tsNet version 1.4.1) Set to the format of the SSL private key. Supported formats are “PEM” and “DER”.

"ssh_host_public_key": Set to the 128 bit MD5 checksum of the remote host's public key. The connection will be rejected unless they match.

"ssh_passphrase": (Business Edition only) Set to the passphrase for any included private key.

"ssh_private_key": (Business Edition only) Set to the private key file (including full system path) to be used in SFTP transfers.

“trace”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to include all inbound and outbound data when using tsNetSetDebugCallback() rather than just header and informational data. When this option is set, a third parameter will be posted to the debug callback function specifying the type of data that is being passed to the callback function.

“transfer_encoding”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to request the response be sent in a compressed Transfer-Encoding (if the server supports it) that will be automatically uncompressed by tsNet when it is received.

“trust_location_auth”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to continue to send authentication details when following any HTTP redirects.

“try_ssl”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to try to connect via SSL. If the connection fails to establish via SSL, connect without using SSL.

“tunnel_http_proxy”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to tunnel all operations (all protocols) through the HTTP proxy.

“use_ascii_transfer”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to use ASCII mode for FTP transfers.

“use_pret”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to send a PRET command before sending PASV/EPSV when performing passive FTP transfers.

"use_ssl": Set to true to connect using Transport Layer Security (TLS) for SMTPS and FTPS (explicit) connections.

"username": Set to a string containing the username to be used in any authentication requests from the server.

“use_ssl_control”: (Introduced in tsNet version 1.4.0) Set this option to true to ensure all control communication is encrypted.

“user_agent”: (Introduced in tsNet version 1.4.0) The contents of this setting will be used as the HTTP User-Agent: header sent as part of a HTTP request.

Function:  tsNetCustomSync

 

Send a synchronous custom request to a server.

tsNetCustomSync(<pURL>, <pRequest>, <xHeaders>, <rOutHeaders>, <rResult>, <rBytes>, [<pSettings>])

 

Operating Systems supported: Mac OS X, Windows, Linux, iOS and Android

Platforms supported:  Desktop, Server and Mobile

Example 1:

   local tHeaders, tRecvHeaders, tResultCode, tBytes, tData
   put tsNetCustomSync(“http://www.livecode.com/file.dat”, “DELETE”, \
      tHeaders, tRecvHeaders, tResultCode, tBytes) into tData

Example 2:

   local tHeaders, tRecvHeaders, tResultCode, tBytes, tData
   put tsNetCustomSync(“ftp://user:pass@ftp.example.com/”, “NLST”, \
      tHeaders, tRecvHeaders, tResultCode, tBytes) into tData

Parameters:

  • pURL: The URL formatted as ‘scheme://host:port/path’ and URL-encoded as outlined in [RFC 3986](http://www.ietf.org/rfc/rfc3986.txt). The following schemes are supported: ‘tftp’, ‘ftp’, ‘ftps’, ‘http’, ‘https’ and ‘sftp’. For SFTP connections, the path is not relative to the user’s home directory, but must be the full system path.
  • pRequest: For HTTP transfers, specify the custom HTTP method to be sent in the request. This is useful particularly for sending HTTP DELETE requests. For FTP/SFTP transfers, this is the raw command (e.g. NLST) that should be used to send a specialised directory listing command.
  • xHeaders: For HTTP(s) connections, the headers to be sent to the server. For all other protocols, leave this blank. The contents of this variable will be replaced when the function returns with the headers that were sent to the server if the “save_sent_headers” array setting is specified below.
  • rOutHeaders: This variable will contain the headers that were returned from the server on completion.
  • rResult: This variable will contain the status code sent by the server to the last command that was issued during the transfer. For SFTP connections, this will always be 0. On error, the return value will be a string containing the error starting with “tsneterr:”.
  • rBytes: This variable will contain the number of bytes that were downloaded during the connection.
  • pSettings: An array of additional settings that control how the transfer is initiated.

Returns:

The tsNetCustomSync function returns the data retrieved from the server on success.

Description:

The settings array can consist of the following elements (not all of the settings make sense for every possible transfer type): 

"byte_range": (Introduced in tsNet version 1.4.0) Specify the range of data to be downloaded. This can be in the format of “X-Y”, “X-“, “-Y” or “X-Y,N-M” where X, Y, N and M and byte indexes. Some HTTP servers may ignore this request.

"cookie_file": (Introduced in tsNet version 1.4.0) Specify a filename to load cookies from. If this setting is present, the internal cookie engine will be enabled and the cookies stored in the file loaded into the engine.

"cookies": (Introduced in tsNet version 1.4.0) The contents of this setting will be used to set a cookie in a HTTP request. It should be in the format of COOKIE_NAME=COOKIE_CONTENTS. Specify multiple cookies by separating them with a semi-colon. This setting does not enable the internal cookie engine of tsNet.

"cookie_jar": (Introduced in tsNet version 1.4.0) Specify a filename to write all known cookies to. If this setting is present, the internal cookie engine of tsNet will be enabled. Note that this file will only be written to at unspecified times. Use the “cookie_list” setting below to force the file to be updated.

"cookie_list": (Introduced in tsNet version 1.4.0) Set this to a list of cookies (one per line) in Netscape / Mozilla format or regular HTTP (Set-Cookie:) style format to add to the internal cookie engine. There are also several strings that when passed to this setting will perform additional actions. Passing in the string “ALL” will erase all cookies held in memory. “SESS” will erase all session cookies in memory. “FLUSH” will write all cookies stored in memory to the file specified by the “cookie_jar” setting. “RELOAD” will reload all cookies from file specified by “cookie_file”.

"disable_eprt": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from using the EPRT command when performing active FTP transfers.

"disable_epsv": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from using the EPSV command when performing passive FTP transfers.

"dont_modify_path": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from squashing “/../” and “/./” components from the URL path. RFC 3986 specifies that these should be removed.

“enable_tcp_keepalive”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to send TCP keepalive probes.

“expect100_timeout”: (Introduced in tsNet version 1.4.0) Specify the number of milliseconds to wait for a response with a HTTP 100 (Continue) or HTTP 417 (Expectation Failed) status after setting a HTTP request containing an Expect: 100-continue header. The default is 1000ms.

"fail_on_http_error": Set to true to specify that HTTP status codes greater than 400 should be considered an error.

"force_basic_auth": (Introduced in tsNet version 1.3.1) Set to true to force HTTP basic authentication rather than allow tsNet to detect what authentication methods are supported by the server.

"force_digest_auth": (Introduced in tsNet version 1.3.5) Set to true to force HTTP digest authentication rather than allow tsNet to detect what authentication methods are supported by the server.

“ftp_filemethod”: (Introduced in tsNet version 1.4.0) Set this to “nocwd” or “singlecwd” to change the method used by FTP to reach a particular file. Using “nocwd” will ensure all FTP commands use the full path to the file on the server. Using “singlecwd” will make tsNet issue a single CWD command to change to the directory that the file resides in before performing any other action on the file. The default is to issue a CWD command for each path part in the URL prior to performing any other action on the file in accordance with RFC 1738.

“ftp_ssl_ccc”: (Introduced in tsNet version 1.4.0) Set this to “passive” or “active” to disable the SSL/TLS encryption after authenticating with the FTP server. All further communication on the command channel with the FTP server will be unencrypted. Use “passive” to only disable the encryption after the server requests it. Setting this to “active” will initiate the encryption shutdown.

“ftp_user_alt”: (Introduced in tsNet version 1.4.0) Specify an alternate string to use for authentication if the standard FTP username and password negotiation fails.

“if_mod_since”: (Introduced in tsNet version 1.4.0) If the last modified time (in seconds since 1 Jan 1970) of the file is later than this, then download the file.

“if_unmod_since”: (Introduced in tsNet version 1.4.0) If the last modified time (in seconds since 1 Jan 1970) of the file is earlier than this, then download the file.

“ignore_content_length”: (Introduced in tsNet version 1.4.0) Set this option to true to ignore the content length specified in HTTP or FTP transfers. tsNet will complete the download when the server ends the connection.

“interface”: (Introduced in tsNet version 1.4.0) Specify the interface, IP address or host name to be used for the outgoing connection.

“junk_session_cookies”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to ignore all cookies loaded via the “cookie_file” setting that are session cookies.

“keepalive_idle”: (Introduced in tsNet version 1.4.0) When “enable_tcp_keepalive” is set to true, use this setting to specify the number of second to wait while the connection is idle before sending keepalive probes. The default is 60 seconds.

“keepalive_interval”: (Introduced in tsNet version 1.4.0) When “enable_tcp_keepalive” is set to true, use this setting to specify the number of seconds to wait between sending keepalive probes. The default is 60 seconds.

“local_port_range”: (Introduced in tsNet version 1.4.0) Set the number of consecutive ports above the port specified by the “local_port_start” setting to try when finding an available port for a connection.

“local_port_start”: (Introduced in tsNet version 1.4.0) Set the local port number of the socket to be used for the connection. It is recommended to also set “local_port_range” if you use this setting.

“max_file_size”: (Introduced in tsNet version 1.4.0) Specify the maximum size of a file to download. If the file exceeds this value, the transfer will not start. This option has no affect is the file size is not known prior to the download.

“max_recv_speed”: (Introduced in tsNet version 1.4.0) This option specifies the number of bytes per second to limit a download transfer to. Setting this to 0 disables any limiting.

“max_send_speed”: (Introduced in tsNet version 1.4.0) This option specifies the number of bytes per second to limit an upload transfer to. Setting this to 0 disables any limiting.

"no_reuse": Set to true to specify that the connection to the server should be disconnected and not left open for any future connections.

"no_transfer": Set to true to connect to the server but not perform any transfer.

"password": Set to a string containing the password to be used in any authentication requests from the server.

"post_commands": (Business Edition only) Set to a list of raw FTP/SFTP commands (one per line) that should be executed on the server directly after any transfer.

“post_on_301”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 301 response.

“post_on_302”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 302 response.

“post_on_303”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 303 response.

"pre_commands": (Business Edition only) Set to a list of raw FTP/SFTP commands (one per line) that should be executed on the server prior to any transfer.

“proxy_auth_basic”: (Introduced in tsNet version 1.4.0) Set this option to true to force tsNet to use basic authentication when authenticating with a proxy server.

“proxy_auth_digest”: (Introduced in tsNet version 1.4.0) Set this option to true to force tsNet to use digest authentication when authenticating with a proxy server.

"proxy_headers": Set to a list of headers (one per line) that should be sent to any proxy server that is being used.

“proxy_http_10”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to use HTTP/1.0 for any CONNECT tunnelling.

“referer”: (Introduced in tsNet version 1.4.0) The contents of this setting will be used as the HTTP Referer: header sent as part of a HTTP request.

“resolve_hosts”: (Introduced in tsNet version 1.4.0) Specify a list (one per line) of host to IP addresses to use when resolving host name for a request. Each line must be in the format of “HOSTNAME:PORT:ADDRESS”.

“resume_from”: (Introduced in tsNet version 1.4.0) Specify the number of bytes at which you want a transfer to start downloading or uploading.

"save_sent_headers": Set to true to specify that external should store a copy of all the headers that it sends to the server. This must be set to true to use the tsNetRetrSentHeaders function.

“skip_pasv_ip”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to ignore the IP address from the server’s 227 response message. tsNet will connect the data connection via the same IP address it used to set up the control connection.

“ssl_ciphers”: (Introduced in tsNet version 1.4.0) Use this setting to specify a list of SSL ciphers (separated by colons) to be used when negotiating SSL connections.

“ssl_client_cert”: (Introduced in tsNet version 1.4.1) Specify the filename of a client SSL certificate to use for authentication to the server.

“ssl_client_cert_type”: (Introduced in tsNet version 1.4.1) Set to the format of the client SSL certificate. Supported formats are “PEM”, “DER” and “P12”.

“ssl_client_key”: (Introduced in tsNet version 1.4.1) Specify the filename of a SSL private key file that matches the client SSL certificate.

“ssl_client_key_pass”: (Introduced in tsNet version 1.4.1) Set to the password for the SSL private key.

“ssl_client_key_type”: (Introduced in tsNet version 1.4.1) Set to the format of the SSL private key. Supported formats are “PEM” and “DER”.

“ssl_proxy_client_cert”: (Introduced in tsNet version 1.4.1) Specify the filename of a proxy client SSL certificate to use for authentication to the HTTP proxy.

“ssl_proxy_client_cert_type”: (Introduced in tsNet version 1.4.1) Set to the format of the proxy client SSL certificate. Supported formats are “PEM”, “DER” and “P12”.

“ssl_proxy_client_key”: (Introduced in tsNet version 1.4.1) Specify the filename of a SSL private key file that matches the proxy client SSL certificate.

“ssl_proxy_client_key_pass”: (Introduced in tsNet version 1.4.1) Set to the password for the SSL private key.

“ssl_proxy_client_key_type”: (Introduced in tsNet version 1.4.1) Set to the format of the SSL private key. Supported formats are “PEM” and “DER”.

"ssh_host_public_key": Set to the 128 bit MD5 checksum of the remote host's public key. The connection will be rejected unless they match.

"ssh_passphrase": (Business Edition only) Set to the passphrase for any included private key.

"ssh_private_key": (Business Edition only) Set to the private key file (including full system path) to be used in SFTP transfers.

“trace”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to include all inbound and outbound data when using tsNetSetDebugCallback() rather than just header and informational data. When this option is set, a third parameter will be posted to the debug callback function specifying the type of data that is being passed to the callback function.

“transfer_encoding”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to request the response be sent in a compressed Transfer-Encoding (if the server supports it) that will be automatically uncompressed by tsNet when it is received.

“trust_location_auth”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to continue to send authentication details when following any HTTP redirects.

“try_ssl”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to try to connect via SSL. If the connection fails to establish via SSL, connect without using SSL.

“tunnel_http_proxy”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to tunnel all operations (all protocols) through the HTTP proxy.

“use_ascii_transfer”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to use ASCII mode for FTP transfers.

“use_pret”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to send a PRET command before sending PASV/EPSV when performing passive FTP transfers.

"use_ssl": Set to true to connect using Transport Layer Security (TLS) for SMTPS and FTPS (explicit) connections.

"username": Set to a string containing the username to be used in any authentication requests from the server.

“use_ssl_control”: (Introduced in tsNet version 1.4.0) Set this option to true to ensure all control communication is encrypted.

“user_agent”: (Introduced in tsNet version 1.4.0) The contents of this setting will be used as the HTTP User-Agent: header sent as part of a HTTP request.

Function:  tsNetCustomUpload

(introduced in tsNet version 1.3.1)

Send an asynchronous upload request to a server using a custom request method.

tsNetCustomUpload(<pConnectionID>, <pURL>, <pRequest>, <pHeaders>, <pCallback>, <pData>, [<pSettings>])

 

Operating Systems supported: Mac OS X, Windows, Linux, iOS and Android

Platforms supported:  Desktop, Server and Mobile

Example 1:

   local tHeaders, tResult, tFilePath, tData
   put specialFolderPath(“documents”) & “/user/bob.dat” into tFilePath
   put URL(“file:” & tFilePath) into tData
   put tsNetCustomUpload(“1”, “http://www.example.com/admin/user/bob.dat”, \
      “PATCH”, tHeaders, “transferComplete”, tData) into tResult

Example 2:

   on transferComplete pID, pResult, pBytes, pCurlCode
      local tData, tHeaders
      if pCurlCode is not 0 then
         answer tsNetRetrError(pID)
      else
         answer “User updated successfully”
      end if
      tsNetCloseConn pID
   end transferComplete

Parameters:

  • pConnectionID: A arbitrary user-defined label for the connection that is used when retrieving any details of the transfer.
  • pURL: The URL formatted as ‘scheme://host:port/path’ and URL-encoded as outlined in [RFC 3986](http://www.ietf.org/rfc/rfc3986.txt). The following schemes are supported: ‘tftp’, ‘ftp’, ‘ftps’, ‘http’, ‘https’ and ‘sftp’. For SFTP connections (Business Edition only), the path is
    not relative to the user’s home directory, but must be the full system path.
  • pRequest: For HTTP transfers, specify the custom HTTP method to be sent in the request. This is useful particularly for sending HTTP DELETE requests. For FTP/SFTP transfers, this is the raw command (e.g. NLST) that should be used to send a specialised directory listing command. SFTP commands are only supported in the Business Edition of LiveCode.
  • pHeaders: For HTTP(s) connections, the headers to be sent to the server. For all other protocols, leave this blank.
  • pCallback: Specify a callback message to be sent to the current object when the transfer is complete.
  • pData: The data that is to be sent to the server.
  • pSettings: An array of additional settings that control how the transfer is initiated.

Returns:

The tsNetCustomUpload function returns empty on success. On error, the return value will be a string containing the error starting with “tsneterr:”.

Description:

This function sends a callback message on completion. Use tsNetRetrData to access any returned data. To save memory, it is recommended to call tsNetCloseConn when the connection is no longer needed.

The callback message will be sent with four parameters: the connection identifier, the status code sent back by the server, the number of bytes transferred and the cURL result code.

The cURL result code parameter in the callback message will be 0 for successful transfers. For any errors, further information can be
retrieved by calling the tsNetRetrError function.

The settings array can consist of the following elements (not all of the settings make sense for every possible transfer type): 

"byte_range": (Introduced in tsNet version 1.4.0) Specify the range of data to be downloaded. This can be in the format of “X-Y”, “X-“, “-Y” or “X-Y,N-M” where X, Y, N and M and byte indexes. Some HTTP servers may ignore this request.

"cookie_file": (Introduced in tsNet version 1.4.0) Specify a filename to load cookies from. If this setting is present, the internal cookie engine will be enabled and the cookies stored in the file loaded into the engine.

"cookies": (Introduced in tsNet version 1.4.0) The contents of this setting will be used to set a cookie in a HTTP request. It should be in the format of COOKIE_NAME=COOKIE_CONTENTS. Specify multiple cookies by separating them with a semi-colon. This setting does not enable the internal cookie engine of tsNet.

"cookie_jar": (Introduced in tsNet version 1.4.0) Specify a filename to write all known cookies to. If this setting is present, the internal cookie engine of tsNet will be enabled. Note that this file will only be written to at unspecified times. Use the “cookie_list” setting below to force the file to be updated.

"cookie_list": (Introduced in tsNet version 1.4.0) Set this to a list of cookies (one per line) in Netscape / Mozilla format or regular HTTP (Set-Cookie:) style format to add to the internal cookie engine. There are also several strings that when passed to this setting will perform additional actions. Passing in the string “ALL” will erase all cookies held in memory. “SESS” will erase all session cookies in memory. “FLUSH” will write all cookies stored in memory to the file specified by the “cookie_jar” setting. “RELOAD” will reload all cookies from file specified by “cookie_file”.

"disable_eprt": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from using the EPRT command when performing active FTP transfers.

"disable_epsv": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from using the EPSV command when performing passive FTP transfers.

"dont_modify_path": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from squashing “/../” and “/./” components from the URL path. RFC 3986 specifies that these should be removed.

“enable_tcp_keepalive”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to send TCP keepalive probes.

“expect100_timeout”: (Introduced in tsNet version 1.4.0) Specify the number of milliseconds to wait for a response with a HTTP 100 (Continue) or HTTP 417 (Expectation Failed) status after setting a HTTP request containing an Expect: 100-continue header. The default is 1000ms.

"fail_on_http_error": Set to true to specify that HTTP status codes greater than 400 should be considered an error.

"force_basic_auth": (Introduced in tsNet version 1.3.1) Set to true to force HTTP basic authentication rather than allow tsNet to detect what authentication methods are supported by the server.

"force_digest_auth": (Introduced in tsNet version 1.3.5) Set to true to force HTTP digest authentication rather than allow tsNet to detect what authentication methods are supported by the server.

“ftp_filemethod”: (Introduced in tsNet version 1.4.0) Set this to “nocwd” or “singlecwd” to change the method used by FTP to reach a particular file. Using “nocwd” will ensure all FTP commands use the full path to the file on the server. Using “singlecwd” will make tsNet issue a single CWD command to change to the directory that the file resides in before performing any other action on the file. The default is to issue a CWD command for each path part in the URL prior to performing any other action on the file in accordance with RFC 1738.

“ftp_ssl_ccc”: (Introduced in tsNet version 1.4.0) Set this to “passive” or “active” to disable the SSL/TLS encryption after authenticating with the FTP server. All further communication on the command channel with the FTP server will be unencrypted. Use “passive” to only disable the encryption after the server requests it. Setting this to “active” will initiate the encryption shutdown.

“ftp_user_alt”: (Introduced in tsNet version 1.4.0) Specify an alternate string to use for authentication if the standard FTP username and password negotiation fails.

“if_mod_since”: (Introduced in tsNet version 1.4.0) If the last modified time (in seconds since 1 Jan 1970) of the file is later than this, then download the file.

“if_unmod_since”: (Introduced in tsNet version 1.4.0) If the last modified time (in seconds since 1 Jan 1970) of the file is earlier than this, then download the file.

“ignore_content_length”: (Introduced in tsNet version 1.4.0) Set this option to true to ignore the content length specified in HTTP or FTP transfers. tsNet will complete the download when the server ends the connection.

“interface”: (Introduced in tsNet version 1.4.0) Specify the interface, IP address or host name to be used for the outgoing connection.

“junk_session_cookies”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to ignore all cookies loaded via the “cookie_file” setting that are session cookies.

“keepalive_idle”: (Introduced in tsNet version 1.4.0) When “enable_tcp_keepalive” is set to true, use this setting to specify the number of second to wait while the connection is idle before sending keepalive probes. The default is 60 seconds.

“keepalive_interval”: (Introduced in tsNet version 1.4.0) When “enable_tcp_keepalive” is set to true, use this setting to specify the number of seconds to wait between sending keepalive probes. The default is 60 seconds.

“local_port_range”: (Introduced in tsNet version 1.4.0) Set the number of consecutive ports above the port specified by the “local_port_start” setting to try when finding an available port for a connection.

“local_port_start”: (Introduced in tsNet version 1.4.0) Set the local port number of the socket to be used for the connection. It is recommended to also set “local_port_range” if you use this setting.

“max_file_size”: (Introduced in tsNet version 1.4.0) Specify the maximum size of a file to download. If the file exceeds this value, the transfer will not start. This option has no affect is the file size is not known prior to the download.

“max_recv_speed”: (Introduced in tsNet version 1.4.0) This option specifies the number of bytes per second to limit a download transfer to. Setting this to 0 disables any limiting.

“max_send_speed”: (Introduced in tsNet version 1.4.0) This option specifies the number of bytes per second to limit an upload transfer to. Setting this to 0 disables any limiting.

"no_reuse": Set to true to specify that the connection to the server should be disconnected and not left open for any future connections.

"no_transfer": Set to true to connect to the server but not perform any transfer.

"password": Set to a string containing the password to be used in any authentication requests from the server.

"post_commands": (Business Edition only) Set to a list of raw FTP/SFTP commands (one per line) that should be executed on the server directly after any transfer.

“post_on_301”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 301 response.

“post_on_302”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 302 response.

“post_on_303”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 303 response.

"pre_commands": (Business Edition only) Set to a list of raw FTP/SFTP commands (one per line) that should be executed on the server prior to any transfer.

“proxy_auth_basic”: (Introduced in tsNet version 1.4.0) Set this option to true to force tsNet to use basic authentication when authenticating with a proxy server.

“proxy_auth_digest”: (Introduced in tsNet version 1.4.0) Set this option to true to force tsNet to use digest authentication when authenticating with a proxy server.

"proxy_headers": Set to a list of headers (one per line) that should be sent to any proxy server that is being used.

“proxy_http_10”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to use HTTP/1.0 for any CONNECT tunnelling.

“referer”: (Introduced in tsNet version 1.4.0) The contents of this setting will be used as the HTTP Referer: header sent as part of a HTTP request.

“resolve_hosts”: (Introduced in tsNet version 1.4.0) Specify a list (one per line) of host to IP addresses to use when resolving host name for a request. Each line must be in the format of “HOSTNAME:PORT:ADDRESS”.

“resume_from”: (Introduced in tsNet version 1.4.0) Specify the number of bytes at which you want a transfer to start downloading or uploading.

"save_sent_headers": Set to true to specify that external should store a copy of all the headers that it sends to the server. This must be set to true to use the tsNetRetrSentHeaders function.

“skip_pasv_ip”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to ignore the IP address from the server’s 227 response message. tsNet will connect the data connection via the same IP address it used to set up the control connection.

“ssl_ciphers”: (Introduced in tsNet version 1.4.0) Use this setting to specify a list of SSL ciphers (separated by colons) to be used when negotiating SSL connections.

“ssl_client_cert”: (Introduced in tsNet version 1.4.1) Specify the filename of a client SSL certificate to use for authentication to the server.

“ssl_client_cert_type”: (Introduced in tsNet version 1.4.1) Set to the format of the client SSL certificate. Supported formats are “PEM”, “DER” and “P12”.

“ssl_client_key”: (Introduced in tsNet version 1.4.1) Specify the filename of a SSL private key file that matches the client SSL certificate.

“ssl_client_key_pass”: (Introduced in tsNet version 1.4.1) Set to the password for the SSL private key.

“ssl_client_key_type”: (Introduced in tsNet version 1.4.1) Set to the format of the SSL private key. Supported formats are “PEM” and “DER”.

“ssl_proxy_client_cert”: (Introduced in tsNet version 1.4.1) Specify the filename of a proxy client SSL certificate to use for authentication to the HTTP proxy.

“ssl_proxy_client_cert_type”: (Introduced in tsNet version 1.4.1) Set to the format of the proxy client SSL certificate. Supported formats are “PEM”, “DER” and “P12”.

“ssl_proxy_client_key”: (Introduced in tsNet version 1.4.1) Specify the filename of a SSL private key file that matches the proxy client SSL certificate.

“ssl_proxy_client_key_pass”: (Introduced in tsNet version 1.4.1) Set to the password for the SSL private key.

“ssl_proxy_client_key_type”: (Introduced in tsNet version 1.4.1) Set to the format of the SSL private key. Supported formats are “PEM” and “DER”.

"ssh_host_public_key": Set to the 128 bit MD5 checksum of the remote host's public key. The connection will be rejected unless they match.

"ssh_passphrase": (Business Edition only) Set to the passphrase for any included private key.

"ssh_private_key": (Business Edition only) Set to the private key file (including full system path) to be used in SFTP transfers.

“trace”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to include all inbound and outbound data when using tsNetSetDebugCallback() rather than just header and informational data. When this option is set, a third parameter will be posted to the debug callback function specifying the type of data that is being passed to the callback function.

“transfer_encoding”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to request the response be sent in a compressed Transfer-Encoding (if the server supports it) that will be automatically uncompressed by tsNet when it is received.

“trust_location_auth”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to continue to send authentication details when following any HTTP redirects.

“try_ssl”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to try to connect via SSL. If the connection fails to establish via SSL, connect without using SSL.

“tunnel_http_proxy”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to tunnel all operations (all protocols) through the HTTP proxy.

“use_ascii_transfer”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to use ASCII mode for FTP transfers.

“use_pret”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to send a PRET command before sending PASV/EPSV when performing passive FTP transfers.

"use_ssl": Set to true to connect using Transport Layer Security (TLS) for SMTPS and FTPS (explicit) connections.

"username": Set to a string containing the username to be used in any authentication requests from the server.

“use_ssl_control”: (Introduced in tsNet version 1.4.0) Set this option to true to ensure all control communication is encrypted.

“user_agent”: (Introduced in tsNet version 1.4.0) The contents of this setting will be used as the HTTP User-Agent: header sent as part of a HTTP request.

Function:  tsNetCustomUploadFile

(introduced in 1.3.1)

Send an asynchronous upload request to a server which retrieves the data to be sent directly from a file using a custom request method.

tsNetCustomUploadFile(<pConnectionID>, <pFile>, <pURL>, <pRequest>, <pHeaders>, <pCallback>, [<pSettings>])

 

Operating Systems supported: Mac OS X, Windows, Linux, iOS and Android

Platforms supported:  Desktop, Server and Mobile

Example 1:

   local tHeaders, tResult
   put tsNetCustomUploadFile(“1”, “/upload/user/bob.dat”, \
      “http://www.example.com/admin/user/bob.dat”, “PATCH”, tHeaders, \
      “transferComplete”) into tResult

Example 2:

   on transferComplete pID, pResult, pBytes, pCurlCode
      local tData, tHeaders
      if pCurlCode is not 0 then
         answer tsNetRetrError(pID)
      else
         answer “User updated successfully”
      end if
      tsNetCloseConn pID
   end transferComplete

Parameters:

  • pConnectionID: A arbitrary user-defined label for the connection that is  used when retrieving any details of the transfer.
  • pFile: The full path and filename that contains the data to be sent to the server.
  • pURL: The URL formatted as ‘scheme://host:port/path’ and URL-encoded as outlined in [RFC 3986](http://www.ietf.org/rfc/rfc3986.txt). The following schemes are supported: ‘tftp’, ‘ftp’, ‘ftps’, ‘http’, ‘https’ and ‘sftp’. For SFTP connections (Business Edition only), the path is not relative to the user’s home directory, but must be the full system path.
  • pRequest: For HTTP transfers, specify the custom HTTP method to be sent in the request. This is useful particularly for sending HTTP DELETE requests. For FTP/SFTP transfers, this is the raw command (e.g. NLST) that should be used to send a specialised directory listing command. SFTP commands are only supported in the Business Edition of LiveCode.
  • pHeaders: For HTTP(s) connections, the headers to be sent to the server. For all other protocols, leave this blank.
  • pCallback: Specify a callback message to be sent to the current object when the transfer is complete.
  • pSettings: An array of additional settings that control how the transfer is initiated.

Returns:

The tsNetCustomUploadFile function returns empty on success. On error, the return value will be a string containing the error starting with “tsneterr:”.

Description:

This function sends a callback message on completion. To save memory, it is recommended to call tsNetCloseConn when the connection is no longer needed.

The callback message will be sent with four parameters: the connection identifier, the status code sent back by the server, the number of bytes transferred and the cURL result code.

The cURL result code parameter in the callback message will be 0 for successful transfers. For any errors, further information can be
retrieved by calling the tsNetRetrError function.

The settings array can consist of the following elements (not all of the settings make sense for every possible transfer type): 

"byte_range": (Introduced in tsNet version 1.4.0) Specify the range of data to be downloaded. This can be in the format of “X-Y”, “X-“, “-Y” or “X-Y,N-M” where X, Y, N and M and byte indexes. Some HTTP servers may ignore this request.

"cookie_file": (Introduced in tsNet version 1.4.0) Specify a filename to load cookies from. If this setting is present, the internal cookie engine will be enabled and the cookies stored in the file loaded into the engine.

"cookies": (Introduced in tsNet version 1.4.0) The contents of this setting will be used to set a cookie in a HTTP request. It should be in the format of COOKIE_NAME=COOKIE_CONTENTS. Specify multiple cookies by separating them with a semi-colon. This setting does not enable the internal cookie engine of tsNet.

"cookie_jar": (Introduced in tsNet version 1.4.0) Specify a filename to write all known cookies to. If this setting is present, the internal cookie engine of tsNet will be enabled. Note that this file will only be written to at unspecified times. Use the “cookie_list” setting below to force the file to be updated.

"cookie_list": (Introduced in tsNet version 1.4.0) Set this to a list of cookies (one per line) in Netscape / Mozilla format or regular HTTP (Set-Cookie:) style format to add to the internal cookie engine. There are also several strings that when passed to this setting will perform additional actions. Passing in the string “ALL” will erase all cookies held in memory. “SESS” will erase all session cookies in memory. “FLUSH” will write all cookies stored in memory to the file specified by the “cookie_jar” setting. “RELOAD” will reload all cookies from file specified by “cookie_file”.

"disable_eprt": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from using the EPRT command when performing active FTP transfers.

"disable_epsv": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from using the EPSV command when performing passive FTP transfers.

"dont_modify_path": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from squashing “/../” and “/./” components from the URL path. RFC 3986 specifies that these should be removed.

“enable_tcp_keepalive”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to send TCP keepalive probes.

“expect100_timeout”: (Introduced in tsNet version 1.4.0) Specify the number of milliseconds to wait for a response with a HTTP 100 (Continue) or HTTP 417 (Expectation Failed) status after setting a HTTP request containing an Expect: 100-continue header. The default is 1000ms.

"fail_on_http_error": Set to true to specify that HTTP status codes greater than 400 should be considered an error.

"force_basic_auth": (Introduced in tsNet version 1.3.1) Set to true to force HTTP basic authentication rather than allow tsNet to detect what authentication methods are supported by the server.

"force_digest_auth": (Introduced in tsNet version 1.3.5) Set to true to force HTTP digest authentication rather than allow tsNet to detect what authentication methods are supported by the server.

“ftp_filemethod”: (Introduced in tsNet version 1.4.0) Set this to “nocwd” or “singlecwd” to change the method used by FTP to reach a particular file. Using “nocwd” will ensure all FTP commands use the full path to the file on the server. Using “singlecwd” will make tsNet issue a single CWD command to change to the directory that the file resides in before performing any other action on the file. The default is to issue a CWD command for each path part in the URL prior to performing any other action on the file in accordance with RFC 1738.

“ftp_ssl_ccc”: (Introduced in tsNet version 1.4.0) Set this to “passive” or “active” to disable the SSL/TLS encryption after authenticating with the FTP server. All further communication on the command channel with the FTP server will be unencrypted. Use “passive” to only disable the encryption after the server requests it. Setting this to “active” will initiate the encryption shutdown.

“ftp_user_alt”: (Introduced in tsNet version 1.4.0) Specify an alternate string to use for authentication if the standard FTP username and password negotiation fails.

“if_mod_since”: (Introduced in tsNet version 1.4.0) If the last modified time (in seconds since 1 Jan 1970) of the file is later than this, then download the file.

“if_unmod_since”: (Introduced in tsNet version 1.4.0) If the last modified time (in seconds since 1 Jan 1970) of the file is earlier than this, then download the file.

“ignore_content_length”: (Introduced in tsNet version 1.4.0) Set this option to true to ignore the content length specified in HTTP or FTP transfers. tsNet will complete the download when the server ends the connection.

“interface”: (Introduced in tsNet version 1.4.0) Specify the interface, IP address or host name to be used for the outgoing connection.

“junk_session_cookies”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to ignore all cookies loaded via the “cookie_file” setting that are session cookies.

“keepalive_idle”: (Introduced in tsNet version 1.4.0) When “enable_tcp_keepalive” is set to true, use this setting to specify the number of second to wait while the connection is idle before sending keepalive probes. The default is 60 seconds.

“keepalive_interval”: (Introduced in tsNet version 1.4.0) When “enable_tcp_keepalive” is set to true, use this setting to specify the number of seconds to wait between sending keepalive probes. The default is 60 seconds.

“local_port_range”: (Introduced in tsNet version 1.4.0) Set the number of consecutive ports above the port specified by the “local_port_start” setting to try when finding an available port for a connection.

“local_port_start”: (Introduced in tsNet version 1.4.0) Set the local port number of the socket to be used for the connection. It is recommended to also set “local_port_range” if you use this setting.

“max_file_size”: (Introduced in tsNet version 1.4.0) Specify the maximum size of a file to download. If the file exceeds this value, the transfer will not start. This option has no affect is the file size is not known prior to the download.

“max_recv_speed”: (Introduced in tsNet version 1.4.0) This option specifies the number of bytes per second to limit a download transfer to. Setting this to 0 disables any limiting.

“max_send_speed”: (Introduced in tsNet version 1.4.0) This option specifies the number of bytes per second to limit an upload transfer to. Setting this to 0 disables any limiting.

"no_reuse": Set to true to specify that the connection to the server should be disconnected and not left open for any future connections.

"no_transfer": Set to true to connect to the server but not perform any transfer.

"password": Set to a string containing the password to be used in any authentication requests from the server.

"post_commands": (Business Edition only) Set to a list of raw FTP/SFTP commands (one per line) that should be executed on the server directly after any transfer.

“post_on_301”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 301 response.

“post_on_302”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 302 response.

“post_on_303”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 303 response.

"pre_commands": (Business Edition only) Set to a list of raw FTP/SFTP commands (one per line) that should be executed on the server prior to any transfer.

“proxy_auth_basic”: (Introduced in tsNet version 1.4.0) Set this option to true to force tsNet to use basic authentication when authenticating with a proxy server.

“proxy_auth_digest”: (Introduced in tsNet version 1.4.0) Set this option to true to force tsNet to use digest authentication when authenticating with a proxy server.

"proxy_headers": Set to a list of headers (one per line) that should be sent to any proxy server that is being used.

“proxy_http_10”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to use HTTP/1.0 for any CONNECT tunnelling.

“referer”: (Introduced in tsNet version 1.4.0) The contents of this setting will be used as the HTTP Referer: header sent as part of a HTTP request.

“resolve_hosts”: (Introduced in tsNet version 1.4.0) Specify a list (one per line) of host to IP addresses to use when resolving host name for a request. Each line must be in the format of “HOSTNAME:PORT:ADDRESS”.

“resume_from”: (Introduced in tsNet version 1.4.0) Specify the number of bytes at which you want a transfer to start downloading or uploading.

"save_sent_headers": Set to true to specify that external should store a copy of all the headers that it sends to the server. This must be set to true to use the tsNetRetrSentHeaders function.

“skip_pasv_ip”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to ignore the IP address from the server’s 227 response message. tsNet will connect the data connection via the same IP address it used to set up the control connection.

“ssl_ciphers”: (Introduced in tsNet version 1.4.0) Use this setting to specify a list of SSL ciphers (separated by colons) to be used when negotiating SSL connections.

“ssl_client_cert”: (Introduced in tsNet version 1.4.1) Specify the filename of a client SSL certificate to use for authentication to the server.

“ssl_client_cert_type”: (Introduced in tsNet version 1.4.1) Set to the format of the client SSL certificate. Supported formats are “PEM”, “DER” and “P12”.

“ssl_client_key”: (Introduced in tsNet version 1.4.1) Specify the filename of a SSL private key file that matches the client SSL certificate.

“ssl_client_key_pass”: (Introduced in tsNet version 1.4.1) Set to the password for the SSL private key.

“ssl_client_key_type”: (Introduced in tsNet version 1.4.1) Set to the format of the SSL private key. Supported formats are “PEM” and “DER”.

“ssl_proxy_client_cert”: (Introduced in tsNet version 1.4.1) Specify the filename of a proxy client SSL certificate to use for authentication to the HTTP proxy.

“ssl_proxy_client_cert_type”: (Introduced in tsNet version 1.4.1) Set to the format of the proxy client SSL certificate. Supported formats are “PEM”, “DER” and “P12”.

“ssl_proxy_client_key”: (Introduced in tsNet version 1.4.1) Specify the filename of a SSL private key file that matches the proxy client SSL certificate.

“ssl_proxy_client_key_pass”: (Introduced in tsNet version 1.4.1) Set to the password for the SSL private key.

“ssl_proxy_client_key_type”: (Introduced in tsNet version 1.4.1) Set to the format of the SSL private key. Supported formats are “PEM” and “DER”.

"ssh_host_public_key": Set to the 128 bit MD5 checksum of the remote host's public key. The connection will be rejected unless they match.

"ssh_passphrase": (Business Edition only) Set to the passphrase for any included private key.

"ssh_private_key": (Business Edition only) Set to the private key file (including full system path) to be used in SFTP transfers.

“trace”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to include all inbound and outbound data when using tsNetSetDebugCallback() rather than just header and informational data. When this option is set, a third parameter will be posted to the debug callback function specifying the type of data that is being passed to the callback function.

“transfer_encoding”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to request the response be sent in a compressed Transfer-Encoding (if the server supports it) that will be automatically uncompressed by tsNet when it is received.

“trust_location_auth”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to continue to send authentication details when following any HTTP redirects.

“try_ssl”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to try to connect via SSL. If the connection fails to establish via SSL, connect without using SSL.

“tunnel_http_proxy”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to tunnel all operations (all protocols) through the HTTP proxy.

“use_ascii_transfer”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to use ASCII mode for FTP transfers.

“use_pret”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to send a PRET command before sending PASV/EPSV when performing passive FTP transfers.

"use_ssl": Set to true to connect using Transport Layer Security (TLS) for SMTPS and FTPS (explicit) connections.

"username": Set to a string containing the username to be used in any authentication requests from the server.

“use_ssl_control”: (Introduced in tsNet version 1.4.0) Set this option to true to ensure all control communication is encrypted.

“user_agent”: (Introduced in tsNet version 1.4.0) The contents of this setting will be used as the HTTP User-Agent: header sent as part of a HTTP request.

Function:  tsNetCustomUploadFileSync

(Introduced in 1.3.1)

Send a synchronous upload request to a server which retrieves the data to be sent directly from a file using a custom request method.

tsNetCustomUploadFileSync(<pFile>, <pURL>, <pRequest>, <xHeaders>, <rOutHeaders>, <rResult>, <rBytes>, [<pSettings>])

 

Operating Systems supported: Mac OS X, Windows, Linux, iOS and Android

Platforms supported:  Desktop, Server and Mobile

Example:

   local tHeaders, tResultCode, tBytes, tRecvHeaders, tResult
   put tsNetCustomUploadFileSync(“/upload/user/bob.dat”, \
      “http://www.example.com/admin/user/bob.dat”, “PATCH”, tHeaders, \
      tRecvHeaders, tResultCode, tBytes) into tResult

Parameters:

  • pFile: The full path and filename that contains the data to be sent to the server.
  • pURL: The URL formatted as ‘scheme://host:port/path’ and URL-encoded as outlined in [RFC 3986](http://www.ietf.org/rfc/rfc3986.txt). The following schemes are supported: ‘tftp’, ‘ftp’, ‘ftps’, ‘http’, ‘https’ and ‘sftp’. For SFTP connections (Business Edition only), the path is not relative to the user’s home directory, but must be the full system path.
  • pRequest: For HTTP transfers, specify the custom HTTP method to be sent in the request. This is useful particularly for sending HTTP DELETE requests. For FTP/SFTP transfers, this is the raw command (e.g. NLST) that should be used to send a  specialised directory listing command. SFTP commands are only supported in the Business Edition of LiveCode.
  • xHeaders: For HTTP(s) connections, the headers to be sent to the server. For all other protocols, leave this blank. The contents of this variable will be replaced when the function returns with the headers that were sent to the server if the “save_sent_headers” array setting is specified below.
  • rOutHeaders: This variable will contain the headers that were returnedfrom the server on completion.
  • rResult: This variable will contain the status code sent by the serverto the last command that was issued during the transfer. For SFTPconnections, this will always be 0. On error, the return value will bea string containing the error starting with “tsneterr:”.
  • rBytes: This variable will contain the number of bytes that were downloaded during the connection.
  • pSettings: An array of additional settings that control how the transfer is initiated.

Returns:

The tsNetCustomUploadFileSync function returns the data retrieved from the server on success.

Description:

The settings array can consist of the following elements (not all of the settings make sense for every possible transfer type): 

"byte_range": (Introduced in tsNet version 1.4.0) Specify the range of data to be downloaded. This can be in the format of “X-Y”, “X-“, “-Y” or “X-Y,N-M” where X, Y, N and M and byte indexes. Some HTTP servers may ignore this request.

"cookie_file": (Introduced in tsNet version 1.4.0) Specify a filename to load cookies from. If this setting is present, the internal cookie engine will be enabled and the cookies stored in the file loaded into the engine.

"cookies": (Introduced in tsNet version 1.4.0) The contents of this setting will be used to set a cookie in a HTTP request. It should be in the format of COOKIE_NAME=COOKIE_CONTENTS. Specify multiple cookies by separating them with a semi-colon. This setting does not enable the internal cookie engine of tsNet.

"cookie_jar": (Introduced in tsNet version 1.4.0) Specify a filename to write all known cookies to. If this setting is present, the internal cookie engine of tsNet will be enabled. Note that this file will only be written to at unspecified times. Use the “cookie_list” setting below to force the file to be updated.

"cookie_list": (Introduced in tsNet version 1.4.0) Set this to a list of cookies (one per line) in Netscape / Mozilla format or regular HTTP (Set-Cookie:) style format to add to the internal cookie engine. There are also several strings that when passed to this setting will perform additional actions. Passing in the string “ALL” will erase all cookies held in memory. “SESS” will erase all session cookies in memory. “FLUSH” will write all cookies stored in memory to the file specified by the “cookie_jar” setting. “RELOAD” will reload all cookies from file specified by “cookie_file”.

"disable_eprt": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from using the EPRT command when performing active FTP transfers.

"disable_epsv": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from using the EPSV command when performing passive FTP transfers.

"dont_modify_path": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from squashing “/../” and “/./” components from the URL path. RFC 3986 specifies that these should be removed.

“enable_tcp_keepalive”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to send TCP keepalive probes.

“expect100_timeout”: (Introduced in tsNet version 1.4.0) Specify the number of milliseconds to wait for a response with a HTTP 100 (Continue) or HTTP 417 (Expectation Failed) status after setting a HTTP request containing an Expect: 100-continue header. The default is 1000ms.

"fail_on_http_error": Set to true to specify that HTTP status codes greater than 400 should be considered an error.

"force_basic_auth": (Introduced in tsNet version 1.3.1) Set to true to force HTTP basic authentication rather than allow tsNet to detect what authentication methods are supported by the server.

"force_digest_auth": (Introduced in tsNet version 1.3.5) Set to true to force HTTP digest authentication rather than allow tsNet to detect what authentication methods are supported by the server.

“ftp_filemethod”: (Introduced in tsNet version 1.4.0) Set this to “nocwd” or “singlecwd” to change the method used by FTP to reach a particular file. Using “nocwd” will ensure all FTP commands use the full path to the file on the server. Using “singlecwd” will make tsNet issue a single CWD command to change to the directory that the file resides in before performing any other action on the file. The default is to issue a CWD command for each path part in the URL prior to performing any other action on the file in accordance with RFC 1738.

“ftp_ssl_ccc”: (Introduced in tsNet version 1.4.0) Set this to “passive” or “active” to disable the SSL/TLS encryption after authenticating with the FTP server. All further communication on the command channel with the FTP server will be unencrypted. Use “passive” to only disable the encryption after the server requests it. Setting this to “active” will initiate the encryption shutdown.

“ftp_user_alt”: (Introduced in tsNet version 1.4.0) Specify an alternate string to use for authentication if the standard FTP username and password negotiation fails.

“if_mod_since”: (Introduced in tsNet version 1.4.0) If the last modified time (in seconds since 1 Jan 1970) of the file is later than this, then download the file.

“if_unmod_since”: (Introduced in tsNet version 1.4.0) If the last modified time (in seconds since 1 Jan 1970) of the file is earlier than this, then download the file.

“ignore_content_length”: (Introduced in tsNet version 1.4.0) Set this option to true to ignore the content length specified in HTTP or FTP transfers. tsNet will complete the download when the server ends the connection.

“interface”: (Introduced in tsNet version 1.4.0) Specify the interface, IP address or host name to be used for the outgoing connection.

“junk_session_cookies”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to ignore all cookies loaded via the “cookie_file” setting that are session cookies.

“keepalive_idle”: (Introduced in tsNet version 1.4.0) When “enable_tcp_keepalive” is set to true, use this setting to specify the number of second to wait while the connection is idle before sending keepalive probes. The default is 60 seconds.

“keepalive_interval”: (Introduced in tsNet version 1.4.0) When “enable_tcp_keepalive” is set to true, use this setting to specify the number of seconds to wait between sending keepalive probes. The default is 60 seconds.

“local_port_range”: (Introduced in tsNet version 1.4.0) Set the number of consecutive ports above the port specified by the “local_port_start” setting to try when finding an available port for a connection.

“local_port_start”: (Introduced in tsNet version 1.4.0) Set the local port number of the socket to be used for the connection. It is recommended to also set “local_port_range” if you use this setting.

“max_file_size”: (Introduced in tsNet version 1.4.0) Specify the maximum size of a file to download. If the file exceeds this value, the transfer will not start. This option has no affect is the file size is not known prior to the download.

“max_recv_speed”: (Introduced in tsNet version 1.4.0) This option specifies the number of bytes per second to limit a download transfer to. Setting this to 0 disables any limiting.

“max_send_speed”: (Introduced in tsNet version 1.4.0) This option specifies the number of bytes per second to limit an upload transfer to. Setting this to 0 disables any limiting.

"no_reuse": Set to true to specify that the connection to the server should be disconnected and not left open for any future connections.

"no_transfer": Set to true to connect to the server but not perform any transfer.

"password": Set to a string containing the password to be used in any authentication requests from the server.

"post_commands": (Business Edition only) Set to a list of raw FTP/SFTP commands (one per line) that should be executed on the server directly after any transfer.

“post_on_301”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 301 response.

“post_on_302”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 302 response.

“post_on_303”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 303 response.

"pre_commands": (Business Edition only) Set to a list of raw FTP/SFTP commands (one per line) that should be executed on the server prior to any transfer.

“proxy_auth_basic”: (Introduced in tsNet version 1.4.0) Set this option to true to force tsNet to use basic authentication when authenticating with a proxy server.

“proxy_auth_digest”: (Introduced in tsNet version 1.4.0) Set this option to true to force tsNet to use digest authentication when authenticating with a proxy server.

"proxy_headers": Set to a list of headers (one per line) that should be sent to any proxy server that is being used.

“proxy_http_10”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to use HTTP/1.0 for any CONNECT tunnelling.

“referer”: (Introduced in tsNet version 1.4.0) The contents of this setting will be used as the HTTP Referer: header sent as part of a HTTP request.

“resolve_hosts”: (Introduced in tsNet version 1.4.0) Specify a list (one per line) of host to IP addresses to use when resolving host name for a request. Each line must be in the format of “HOSTNAME:PORT:ADDRESS”.

“resume_from”: (Introduced in tsNet version 1.4.0) Specify the number of bytes at which you want a transfer to start downloading or uploading.

"save_sent_headers": Set to true to specify that external should store a copy of all the headers that it sends to the server. This must be set to true to use the tsNetRetrSentHeaders function.

“skip_pasv_ip”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to ignore the IP address from the server’s 227 response message. tsNet will connect the data connection via the same IP address it used to set up the control connection.

“ssl_ciphers”: (Introduced in tsNet version 1.4.0) Use this setting to specify a list of SSL ciphers (separated by colons) to be used when negotiating SSL connections.

“ssl_client_cert”: (Introduced in tsNet version 1.4.1) Specify the filename of a client SSL certificate to use for authentication to the server.

“ssl_client_cert_type”: (Introduced in tsNet version 1.4.1) Set to the format of the client SSL certificate. Supported formats are “PEM”, “DER” and “P12”.

“ssl_client_key”: (Introduced in tsNet version 1.4.1) Specify the filename of a SSL private key file that matches the client SSL certificate.

“ssl_client_key_pass”: (Introduced in tsNet version 1.4.1) Set to the password for the SSL private key.

“ssl_client_key_type”: (Introduced in tsNet version 1.4.1) Set to the format of the SSL private key. Supported formats are “PEM” and “DER”.

“ssl_proxy_client_cert”: (Introduced in tsNet version 1.4.1) Specify the filename of a proxy client SSL certificate to use for authentication to the HTTP proxy.

“ssl_proxy_client_cert_type”: (Introduced in tsNet version 1.4.1) Set to the format of the proxy client SSL certificate. Supported formats are “PEM”, “DER” and “P12”.

“ssl_proxy_client_key”: (Introduced in tsNet version 1.4.1) Specify the filename of a SSL private key file that matches the proxy client SSL certificate.

“ssl_proxy_client_key_pass”: (Introduced in tsNet version 1.4.1) Set to the password for the SSL private key.

“ssl_proxy_client_key_type”: (Introduced in tsNet version 1.4.1) Set to the format of the SSL private key. Supported formats are “PEM” and “DER”.

"ssh_host_public_key": Set to the 128 bit MD5 checksum of the remote host's public key. The connection will be rejected unless they match.

"ssh_passphrase": (Business Edition only) Set to the passphrase for any included private key.

"ssh_private_key": (Business Edition only) Set to the private key file (including full system path) to be used in SFTP transfers.

“trace”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to include all inbound and outbound data when using tsNetSetDebugCallback() rather than just header and informational data. When this option is set, a third parameter will be posted to the debug callback function specifying the type of data that is being passed to the callback function.

“transfer_encoding”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to request the response be sent in a compressed Transfer-Encoding (if the server supports it) that will be automatically uncompressed by tsNet when it is received.

“trust_location_auth”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to continue to send authentication details when following any HTTP redirects.

“try_ssl”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to try to connect via SSL. If the connection fails to establish via SSL, connect without using SSL.

“tunnel_http_proxy”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to tunnel all operations (all protocols) through the HTTP proxy.

“use_ascii_transfer”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to use ASCII mode for FTP transfers.

“use_pret”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to send a PRET command before sending PASV/EPSV when performing passive FTP transfers.

"use_ssl": Set to true to connect using Transport Layer Security (TLS) for SMTPS and FTPS (explicit) connections.

"username": Set to a string containing the username to be used in any authentication requests from the server.

“use_ssl_control”: (Introduced in tsNet version 1.4.0) Set this option to true to ensure all control communication is encrypted.

“user_agent”: (Introduced in tsNet version 1.4.0) The contents of this setting will be used as the HTTP User-Agent: header sent as part of a HTTP request.

Function:  tsNetCustomUploadSync

(Introduced in 1.3.1)

Send a synchronous upload request to a server using a custom request method.

tsNetCustomUploadSync(<pURL>, <pRequest>, <xHeaders>, <pData>, <rOutHeaders>, <rResult>, <rBytes>, [<pSettings>])

 

Operating Systems supported: Mac OS X, Windows, Linux, iOS and Android

Platforms supported:  Desktop, Server and Mobile

Example:

   local tHeaders, tResult, tBytes, tRecvHeaders, tData, tOutputData
   put specialFolderPath(“documents”) & “/user/bob.dat” into tFilePath
   put URL(“file:” & tFilePath) into tData
   put tsNetCustomUploadSync(“http://www.example.com/admin/user/bob.dat”, \
      “PATCH”, tHeaders, tData, tRecvHeaders, tResult, tBytes) into tOutputData

Parameters:

  • pURL: The URL formatted as ‘scheme://host:port/path’ and URL-encoded as outlined in [RFC 3986](http://www.ietf.org/rfc/rfc3986.txt). The following schemes are supported: ‘tftp’, ‘ftp’, ‘ftps’, ‘http’, ‘https’ and ‘sftp’. For SFTP connections, the path is not relative to the user’s home directory, but must be the full system path.
  • pRequest: For HTTP transfers, specify the custom HTTP method to be sent in the request. This is useful particularly for sending HTTP DELETE requests. For FTP/SFTP transfers, this is the raw command (e.g. NLST) that should be used to send a specialised directory listing command.
  • xHeaders: For HTTP(s) connections, the headers to be sent to the server. For all other protocols, leave this blank. The contents of this variable will be replaced when the function returns with the headers that were sent to the server if the “save_sent_headers” array setting is specified below.
  • pData: The data that is to be sent to the server.
  • rOutHeaders: This variable will contain the headers that were returned from the server on completion.
  • rResult: This variable will contain the status code sent by the server to the last command that was issued during the transfer. For SFTP connections, this will always be 0. On error, the return value will be a string containing the error starting with “tsneterr:”.
  • rBytes: This variable will contain the number of bytes that were downloaded during the connection.
  • pSettings: An array of additional settings that control how the transfer is initiated.

Returns:

The tsNetCustomUploadSync function returns the data retrieved from the server on success.

Description:

The settings array can consist of the following elements (not all of the settings make sense for every possible transfer type): 

"byte_range": (Introduced in tsNet version 1.4.0) Specify the range of data to be downloaded. This can be in the format of “X-Y”, “X-“, “-Y” or “X-Y,N-M” where X, Y, N and M and byte indexes. Some HTTP servers may ignore this request.

"cookie_file": (Introduced in tsNet version 1.4.0) Specify a filename to load cookies from. If this setting is present, the internal cookie engine will be enabled and the cookies stored in the file loaded into the engine.

"cookies": (Introduced in tsNet version 1.4.0) The contents of this setting will be used to set a cookie in a HTTP request. It should be in the format of COOKIE_NAME=COOKIE_CONTENTS. Specify multiple cookies by separating them with a semi-colon. This setting does not enable the internal cookie engine of tsNet.

"cookie_jar": (Introduced in tsNet version 1.4.0) Specify a filename to write all known cookies to. If this setting is present, the internal cookie engine of tsNet will be enabled. Note that this file will only be written to at unspecified times. Use the “cookie_list” setting below to force the file to be updated.

"cookie_list": (Introduced in tsNet version 1.4.0) Set this to a list of cookies (one per line) in Netscape / Mozilla format or regular HTTP (Set-Cookie:) style format to add to the internal cookie engine. There are also several strings that when passed to this setting will perform additional actions. Passing in the string “ALL” will erase all cookies held in memory. “SESS” will erase all session cookies in memory. “FLUSH” will write all cookies stored in memory to the file specified by the “cookie_jar” setting. “RELOAD” will reload all cookies from file specified by “cookie_file”.

"disable_eprt": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from using the EPRT command when performing active FTP transfers.

"disable_epsv": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from using the EPSV command when performing passive FTP transfers.

"dont_modify_path": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from squashing “/../” and “/./” components from the URL path. RFC 3986 specifies that these should be removed.

“enable_tcp_keepalive”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to send TCP keepalive probes.

“expect100_timeout”: (Introduced in tsNet version 1.4.0) Specify the number of milliseconds to wait for a response with a HTTP 100 (Continue) or HTTP 417 (Expectation Failed) status after setting a HTTP request containing an Expect: 100-continue header. The default is 1000ms.

"fail_on_http_error": Set to true to specify that HTTP status codes greater than 400 should be considered an error.

"force_basic_auth": (Introduced in tsNet version 1.3.1) Set to true to force HTTP basic authentication rather than allow tsNet to detect what authentication methods are supported by the server.

"force_digest_auth": (Introduced in tsNet version 1.3.5) Set to true to force HTTP digest authentication rather than allow tsNet to detect what authentication methods are supported by the server.

“ftp_filemethod”: (Introduced in tsNet version 1.4.0) Set this to “nocwd” or “singlecwd” to change the method used by FTP to reach a particular file. Using “nocwd” will ensure all FTP commands use the full path to the file on the server. Using “singlecwd” will make tsNet issue a single CWD command to change to the directory that the file resides in before performing any other action on the file. The default is to issue a CWD command for each path part in the URL prior to performing any other action on the file in accordance with RFC 1738.

“ftp_ssl_ccc”: (Introduced in tsNet version 1.4.0) Set this to “passive” or “active” to disable the SSL/TLS encryption after authenticating with the FTP server. All further communication on the command channel with the FTP server will be unencrypted. Use “passive” to only disable the encryption after the server requests it. Setting this to “active” will initiate the encryption shutdown.

“ftp_user_alt”: (Introduced in tsNet version 1.4.0) Specify an alternate string to use for authentication if the standard FTP username and password negotiation fails.

“if_mod_since”: (Introduced in tsNet version 1.4.0) If the last modified time (in seconds since 1 Jan 1970) of the file is later than this, then download the file.

“if_unmod_since”: (Introduced in tsNet version 1.4.0) If the last modified time (in seconds since 1 Jan 1970) of the file is earlier than this, then download the file.

“ignore_content_length”: (Introduced in tsNet version 1.4.0) Set this option to true to ignore the content length specified in HTTP or FTP transfers. tsNet will complete the download when the server ends the connection.

“interface”: (Introduced in tsNet version 1.4.0) Specify the interface, IP address or host name to be used for the outgoing connection.

“junk_session_cookies”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to ignore all cookies loaded via the “cookie_file” setting that are session cookies.

“keepalive_idle”: (Introduced in tsNet version 1.4.0) When “enable_tcp_keepalive” is set to true, use this setting to specify the number of second to wait while the connection is idle before sending keepalive probes. The default is 60 seconds.

“keepalive_interval”: (Introduced in tsNet version 1.4.0) When “enable_tcp_keepalive” is set to true, use this setting to specify the number of seconds to wait between sending keepalive probes. The default is 60 seconds.

“local_port_range”: (Introduced in tsNet version 1.4.0) Set the number of consecutive ports above the port specified by the “local_port_start” setting to try when finding an available port for a connection.

“local_port_start”: (Introduced in tsNet version 1.4.0) Set the local port number of the socket to be used for the connection. It is recommended to also set “local_port_range” if you use this setting.

“max_file_size”: (Introduced in tsNet version 1.4.0) Specify the maximum size of a file to download. If the file exceeds this value, the transfer will not start. This option has no affect is the file size is not known prior to the download.

“max_recv_speed”: (Introduced in tsNet version 1.4.0) This option specifies the number of bytes per second to limit a download transfer to. Setting this to 0 disables any limiting.

“max_send_speed”: (Introduced in tsNet version 1.4.0) This option specifies the number of bytes per second to limit an upload transfer to. Setting this to 0 disables any limiting.

"no_reuse": Set to true to specify that the connection to the server should be disconnected and not left open for any future connections.

"no_transfer": Set to true to connect to the server but not perform any transfer.

"password": Set to a string containing the password to be used in any authentication requests from the server.

"post_commands": (Business Edition only) Set to a list of raw FTP/SFTP commands (one per line) that should be executed on the server directly after any transfer.

“post_on_301”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 301 response.

“post_on_302”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 302 response.

“post_on_303”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 303 response.

"pre_commands": (Business Edition only) Set to a list of raw FTP/SFTP commands (one per line) that should be executed on the server prior to any transfer.

“proxy_auth_basic”: (Introduced in tsNet version 1.4.0) Set this option to true to force tsNet to use basic authentication when authenticating with a proxy server.

“proxy_auth_digest”: (Introduced in tsNet version 1.4.0) Set this option to true to force tsNet to use digest authentication when authenticating with a proxy server.

"proxy_headers": Set to a list of headers (one per line) that should be sent to any proxy server that is being used.

“proxy_http_10”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to use HTTP/1.0 for any CONNECT tunnelling.

“referer”: (Introduced in tsNet version 1.4.0) The contents of this setting will be used as the HTTP Referer: header sent as part of a HTTP request.

“resolve_hosts”: (Introduced in tsNet version 1.4.0) Specify a list (one per line) of host to IP addresses to use when resolving host name for a request. Each line must be in the format of “HOSTNAME:PORT:ADDRESS”.

“resume_from”: (Introduced in tsNet version 1.4.0) Specify the number of bytes at which you want a transfer to start downloading or uploading.

"save_sent_headers": Set to true to specify that external should store a copy of all the headers that it sends to the server. This must be set to true to use the tsNetRetrSentHeaders function.

“skip_pasv_ip”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to ignore the IP address from the server’s 227 response message. tsNet will connect the data connection via the same IP address it used to set up the control connection.

“ssl_ciphers”: (Introduced in tsNet version 1.4.0) Use this setting to specify a list of SSL ciphers (separated by colons) to be used when negotiating SSL connections.

“ssl_client_cert”: (Introduced in tsNet version 1.4.1) Specify the filename of a client SSL certificate to use for authentication to the server.

“ssl_client_cert_type”: (Introduced in tsNet version 1.4.1) Set to the format of the client SSL certificate. Supported formats are “PEM”, “DER” and “P12”.

“ssl_client_key”: (Introduced in tsNet version 1.4.1) Specify the filename of a SSL private key file that matches the client SSL certificate.

“ssl_client_key_pass”: (Introduced in tsNet version 1.4.1) Set to the password for the SSL private key.

“ssl_client_key_type”: (Introduced in tsNet version 1.4.1) Set to the format of the SSL private key. Supported formats are “PEM” and “DER”.

“ssl_proxy_client_cert”: (Introduced in tsNet version 1.4.1) Specify the filename of a proxy client SSL certificate to use for authentication to the HTTP proxy.

“ssl_proxy_client_cert_type”: (Introduced in tsNet version 1.4.1) Set to the format of the proxy client SSL certificate. Supported formats are “PEM”, “DER” and “P12”.

“ssl_proxy_client_key”: (Introduced in tsNet version 1.4.1) Specify the filename of a SSL private key file that matches the proxy client SSL certificate.

“ssl_proxy_client_key_pass”: (Introduced in tsNet version 1.4.1) Set to the password for the SSL private key.

“ssl_proxy_client_key_type”: (Introduced in tsNet version 1.4.1) Set to the format of the SSL private key. Supported formats are “PEM” and “DER”.

"ssh_host_public_key": Set to the 128 bit MD5 checksum of the remote host's public key. The connection will be rejected unless they match.

"ssh_passphrase": (Business Edition only) Set to the passphrase for any included private key.

"ssh_private_key": (Business Edition only) Set to the private key file (including full system path) to be used in SFTP transfers.

“trace”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to include all inbound and outbound data when using tsNetSetDebugCallback() rather than just header and informational data. When this option is set, a third parameter will be posted to the debug callback function specifying the type of data that is being passed to the callback function.

“transfer_encoding”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to request the response be sent in a compressed Transfer-Encoding (if the server supports it) that will be automatically uncompressed by tsNet when it is received.

“trust_location_auth”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to continue to send authentication details when following any HTTP redirects.

“try_ssl”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to try to connect via SSL. If the connection fails to establish via SSL, connect without using SSL.

“tunnel_http_proxy”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to tunnel all operations (all protocols) through the HTTP proxy.

“use_ascii_transfer”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to use ASCII mode for FTP transfers.

“use_pret”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to send a PRET command before sending PASV/EPSV when performing passive FTP transfers.

"use_ssl": Set to true to connect using Transport Layer Security (TLS) for SMTPS and FTPS (explicit) connections.

"username": Set to a string containing the username to be used in any authentication requests from the server.

“use_ssl_control”: (Introduced in tsNet version 1.4.0) Set this option to true to ensure all control communication is encrypted.

“user_agent”: (Introduced in tsNet version 1.4.0) The contents of this setting will be used as the HTTP User-Agent: header sent as part of a HTTP request.

Function:  tsNetGenerateKey

 

Generates an RSA public/private key for use with SFTP transfers.

tsNetGenerateKey(<pKeyLength>, <rPrivateKey>, <rPublicKey>, <pPassphrase>, [<pFormat])

 

Operating Systems supported: Mac OS X, Windows, Linux, iOS and Android

Platforms supported:  Desktop, Server and Mobile

Example:

   local tPrivKey, tPubKey, tResult
   put tsNetGenerateKey(2048, tPrivKey, tPubKey, “secretkey”, “PKCS#8”) into tResult
   if tResult is not empty then
      answer “Failed to generate RSA key”
   end if

Parameters:

  • pKeyLength: The length of the RSA key to generate.
  • rPrivateKey: A variable to store the RSA private key in.
  • rPublicKey: A variable to store the RSA public key in.
  • pPassphrase: The passphrase to protect the RSA private key with. Can be blank.
  • pFormat: Specifies the format that the generated keys are returned it. Accepts “PKCS#8” or “PKCS#1”, the default is “PKCS#1”.

Returns:

The tsNetGenerateKey function returns an empty string if successful, otherwise an error string will be returned.

 

Function:  tsNetGet

 

Send an asynchronous GET request to a server.

tsNetGet(<pConnectionID>, <pURL>, <pHeaders>, <pCallback>, [<pSettings>])

 

Operating Systems supported: Mac OS X, Windows, Linux, iOS and Android

Platforms supported:  Desktop, Server and Mobile

Example 1:

   local tHeaders, tResult
   put tsNetGet(“1”, “http://www.livecode.com”, tHeaders, \
      “transferComplete”) into tResult

Example 2:

   local tHeaders, tResult
   put tsNetGet(“1”, “ftp://user:pass@ftp.example.com/file.dat”, \
      tHeaders, “transferComplete”) into tResult

Example 3:

   on transferComplete pID, pResult, pBytes, pCurlCode
      local tData, tHeaders
      if pCurlCode is not 0 then
         answer tsNetRetrError(pID)
      end if
      put tsNetRetrData(pID, tError) into tData
      tsNetCloseConn pID
      answer “Server data returned:” & tData
   end transferComplete

Parameters:

  • pConnectionID: A arbitrary user-defined label for the connection that is used when retrieving any details of the transfer.
  • pURL: The URL formatted as ‘scheme://host:port/path’ and URL-encoded as outlined in [RFC 3986](http://www.ietf.org/rfc/rfc3986.txt). The following schemes are supported: ‘tftp’, ‘ftp’, ‘ftps’, ‘http’, ‘https’ and ‘sftp’. For SFTP connections (Business Edition only), the path is not relative to the user’s home directory, but must be the full system path.
  • pHeaders: For HTTP(s) connections, the headers to be sent to the server. For all other protocols, leave this blank.
  • pCallback: Specify a callback message to be sent to the current object when the transfer is complete.
  • pSettings: An array of additional settings that control how the transfer is initiated.

Returns:

The tsNetGet function returns empty on success. On error, the return value will be a string containing the error starting with
“tsneterr:”.

Description:

This function sends a callback message on completion. Use tsNetRetrData to access the returned data. To save memory, it is recommended to call tsNetCloseConn when the connection is no longer needed.

The callback message will be sent with four parameters: the connection identifier, the status code sent back by the server, the number of bytes transferred and the cURL result code.

The cURL result code parameter in the callback message will be 0 for successful transfers. For any errors, further information can be
retrieved by calling the tsNetRetrError function.

The settings array can consist of the following elements (not all of the settings make sense for every possible transfer type): 

"byte_range": (Introduced in tsNet version 1.4.0) Specify the range of data to be downloaded. This can be in the format of “X-Y”, “X-“, “-Y” or “X-Y,N-M” where X, Y, N and M and byte indexes. Some HTTP servers may ignore this request.

"cookie_file": (Introduced in tsNet version 1.4.0) Specify a filename to load cookies from. If this setting is present, the internal cookie engine will be enabled and the cookies stored in the file loaded into the engine.

"cookies": (Introduced in tsNet version 1.4.0) The contents of this setting will be used to set a cookie in a HTTP request. It should be in the format of COOKIE_NAME=COOKIE_CONTENTS. Specify multiple cookies by separating them with a semi-colon. This setting does not enable the internal cookie engine of tsNet.

"cookie_jar": (Introduced in tsNet version 1.4.0) Specify a filename to write all known cookies to. If this setting is present, the internal cookie engine of tsNet will be enabled. Note that this file will only be written to at unspecified times. Use the “cookie_list” setting below to force the file to be updated.

"cookie_list": (Introduced in tsNet version 1.4.0) Set this to a list of cookies (one per line) in Netscape / Mozilla format or regular HTTP (Set-Cookie:) style format to add to the internal cookie engine. There are also several strings that when passed to this setting will perform additional actions. Passing in the string “ALL” will erase all cookies held in memory. “SESS” will erase all session cookies in memory. “FLUSH” will write all cookies stored in memory to the file specified by the “cookie_jar” setting. “RELOAD” will reload all cookies from file specified by “cookie_file”.

"disable_eprt": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from using the EPRT command when performing active FTP transfers.

"disable_epsv": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from using the EPSV command when performing passive FTP transfers.

"dont_modify_path": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from squashing “/../” and “/./” components from the URL path. RFC 3986 specifies that these should be removed.

“enable_tcp_keepalive”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to send TCP keepalive probes.

“expect100_timeout”: (Introduced in tsNet version 1.4.0) Specify the number of milliseconds to wait for a response with a HTTP 100 (Continue) or HTTP 417 (Expectation Failed) status after setting a HTTP request containing an Expect: 100-continue header. The default is 1000ms.

"fail_on_http_error": Set to true to specify that HTTP status codes greater than 400 should be considered an error.

"force_basic_auth": (Introduced in tsNet version 1.3.1) Set to true to force HTTP basic authentication rather than allow tsNet to detect what authentication methods are supported by the server.

"force_digest_auth": (Introduced in tsNet version 1.3.5) Set to true to force HTTP digest authentication rather than allow tsNet to detect what authentication methods are supported by the server.

“ftp_filemethod”: (Introduced in tsNet version 1.4.0) Set this to “nocwd” or “singlecwd” to change the method used by FTP to reach a particular file. Using “nocwd” will ensure all FTP commands use the full path to the file on the server. Using “singlecwd” will make tsNet issue a single CWD command to change to the directory that the file resides in before performing any other action on the file. The default is to issue a CWD command for each path part in the URL prior to performing any other action on the file in accordance with RFC 1738.

“ftp_ssl_ccc”: (Introduced in tsNet version 1.4.0) Set this to “passive” or “active” to disable the SSL/TLS encryption after authenticating with the FTP server. All further communication on the command channel with the FTP server will be unencrypted. Use “passive” to only disable the encryption after the server requests it. Setting this to “active” will initiate the encryption shutdown.

“ftp_user_alt”: (Introduced in tsNet version 1.4.0) Specify an alternate string to use for authentication if the standard FTP username and password negotiation fails.

“if_mod_since”: (Introduced in tsNet version 1.4.0) If the last modified time (in seconds since 1 Jan 1970) of the file is later than this, then download the file.

“if_unmod_since”: (Introduced in tsNet version 1.4.0) If the last modified time (in seconds since 1 Jan 1970) of the file is earlier than this, then download the file.

“ignore_content_length”: (Introduced in tsNet version 1.4.0) Set this option to true to ignore the content length specified in HTTP or FTP transfers. tsNet will complete the download when the server ends the connection.

“interface”: (Introduced in tsNet version 1.4.0) Specify the interface, IP address or host name to be used for the outgoing connection.

“junk_session_cookies”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to ignore all cookies loaded via the “cookie_file” setting that are session cookies.

“keepalive_idle”: (Introduced in tsNet version 1.4.0) When “enable_tcp_keepalive” is set to true, use this setting to specify the number of second to wait while the connection is idle before sending keepalive probes. The default is 60 seconds.

“keepalive_interval”: (Introduced in tsNet version 1.4.0) When “enable_tcp_keepalive” is set to true, use this setting to specify the number of seconds to wait between sending keepalive probes. The default is 60 seconds.

“local_port_range”: (Introduced in tsNet version 1.4.0) Set the number of consecutive ports above the port specified by the “local_port_start” setting to try when finding an available port for a connection.

“local_port_start”: (Introduced in tsNet version 1.4.0) Set the local port number of the socket to be used for the connection. It is recommended to also set “local_port_range” if you use this setting.

“max_file_size”: (Introduced in tsNet version 1.4.0) Specify the maximum size of a file to download. If the file exceeds this value, the transfer will not start. This option has no affect is the file size is not known prior to the download.

“max_recv_speed”: (Introduced in tsNet version 1.4.0) This option specifies the number of bytes per second to limit a download transfer to. Setting this to 0 disables any limiting.

“max_send_speed”: (Introduced in tsNet version 1.4.0) This option specifies the number of bytes per second to limit an upload transfer to. Setting this to 0 disables any limiting.

"no_reuse": Set to true to specify that the connection to the server should be disconnected and not left open for any future connections.

"no_transfer": Set to true to connect to the server but not perform any transfer.

"password": Set to a string containing the password to be used in any authentication requests from the server.

"post_commands": (Business Edition only) Set to a list of raw FTP/SFTP commands (one per line) that should be executed on the server directly after any transfer.

“post_on_301”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 301 response.

“post_on_302”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 302 response.

“post_on_303”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 303 response.

"pre_commands": (Business Edition only) Set to a list of raw FTP/SFTP commands (one per line) that should be executed on the server prior to any transfer.

“proxy_auth_basic”: (Introduced in tsNet version 1.4.0) Set this option to true to force tsNet to use basic authentication when authenticating with a proxy server.

“proxy_auth_digest”: (Introduced in tsNet version 1.4.0) Set this option to true to force tsNet to use digest authentication when authenticating with a proxy server.

"proxy_headers": Set to a list of headers (one per line) that should be sent to any proxy server that is being used.

“proxy_http_10”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to use HTTP/1.0 for any CONNECT tunnelling.

“referer”: (Introduced in tsNet version 1.4.0) The contents of this setting will be used as the HTTP Referer: header sent as part of a HTTP request.

“resolve_hosts”: (Introduced in tsNet version 1.4.0) Specify a list (one per line) of host to IP addresses to use when resolving host name for a request. Each line must be in the format of “HOSTNAME:PORT:ADDRESS”.

“resume_from”: (Introduced in tsNet version 1.4.0) Specify the number of bytes at which you want a transfer to start downloading or uploading.

"save_sent_headers": Set to true to specify that external should store a copy of all the headers that it sends to the server. This must be set to true to use the tsNetRetrSentHeaders function.

“skip_pasv_ip”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to ignore the IP address from the server’s 227 response message. tsNet will connect the data connection via the same IP address it used to set up the control connection.

“ssl_ciphers”: (Introduced in tsNet version 1.4.0) Use this setting to specify a list of SSL ciphers (separated by colons) to be used when negotiating SSL connections.

“ssl_client_cert”: (Introduced in tsNet version 1.4.1) Specify the filename of a client SSL certificate to use for authentication to the server.

“ssl_client_cert_type”: (Introduced in tsNet version 1.4.1) Set to the format of the client SSL certificate. Supported formats are “PEM”, “DER” and “P12”.

“ssl_client_key”: (Introduced in tsNet version 1.4.1) Specify the filename of a SSL private key file that matches the client SSL certificate.

“ssl_client_key_pass”: (Introduced in tsNet version 1.4.1) Set to the password for the SSL private key.

“ssl_client_key_type”: (Introduced in tsNet version 1.4.1) Set to the format of the SSL private key. Supported formats are “PEM” and “DER”.

“ssl_proxy_client_cert”: (Introduced in tsNet version 1.4.1) Specify the filename of a proxy client SSL certificate to use for authentication to the HTTP proxy.

“ssl_proxy_client_cert_type”: (Introduced in tsNet version 1.4.1) Set to the format of the proxy client SSL certificate. Supported formats are “PEM”, “DER” and “P12”.

“ssl_proxy_client_key”: (Introduced in tsNet version 1.4.1) Specify the filename of a SSL private key file that matches the proxy client SSL certificate.

“ssl_proxy_client_key_pass”: (Introduced in tsNet version 1.4.1) Set to the password for the SSL private key.

“ssl_proxy_client_key_type”: (Introduced in tsNet version 1.4.1) Set to the format of the SSL private key. Supported formats are “PEM” and “DER”.

"ssh_host_public_key": Set to the 128 bit MD5 checksum of the remote host's public key. The connection will be rejected unless they match.

"ssh_passphrase": (Business Edition only) Set to the passphrase for any included private key.

"ssh_private_key": (Business Edition only) Set to the private key file (including full system path) to be used in SFTP transfers.

“trace”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to include all inbound and outbound data when using tsNetSetDebugCallback() rather than just header and informational data. When this option is set, a third parameter will be posted to the debug callback function specifying the type of data that is being passed to the callback function.

“transfer_encoding”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to request the response be sent in a compressed Transfer-Encoding (if the server supports it) that will be automatically uncompressed by tsNet when it is received.

“trust_location_auth”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to continue to send authentication details when following any HTTP redirects.

“try_ssl”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to try to connect via SSL. If the connection fails to establish via SSL, connect without using SSL.

“tunnel_http_proxy”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to tunnel all operations (all protocols) through the HTTP proxy.

“use_ascii_transfer”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to use ASCII mode for FTP transfers.

“use_pret”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to send a PRET command before sending PASV/EPSV when performing passive FTP transfers.

"use_ssl": Set to true to connect using Transport Layer Security (TLS) for SMTPS and FTPS (explicit) connections.

"username": Set to a string containing the username to be used in any authentication requests from the server.

“use_ssl_control”: (Introduced in tsNet version 1.4.0) Set this option to true to ensure all control communication is encrypted.

“user_agent”: (Introduced in tsNet version 1.4.0) The contents of this setting will be used as the HTTP User-Agent: header sent as part of a HTTP request.

Function:  tsNetGetFile

 

Send an asynchronous GET request to a server which stores the returned data directly to a file.

tsNetGetFile(<pConnectionID>, <pFile>, <pURL>, <pHeaders>, <pCallback>, [<pSettings>])

 

Operating Systems supported: Mac OS X, Windows, Linux, iOS and Android

Platforms supported:  Desktop, Server and Mobile

Example 1:

   local tHeaders, tResult
   put tsNetGetFile(“1”, “/path/to/downloaded/file.dat”, \
      “ftp://user:pass@ftp.example.com/file.dat”, tHeaders, \
      “transferComplete”) into tResult

Example 2:

   on transferComplete pID, pResult, pBytes, pCurlCode
      local tData, tHeaders
      if pCurlCode is not 0 then
         answer tsNetRetrError(pID)
      else
         answer “File has been downloaded”
      end if
      tsNetCloseConn pID
   end transferComplete

Parameters:

  • pConnectionID: A arbitrary user-defined label for the connection that is used when retrieving any details of the transfer.
  • pFile: The full path and filename to store the retrieve data in.
  • pURL: The URL formatted as ‘scheme://host:port/path’ and URL-encoded as outlined in [RFC 3986](http://www.ietf.org/rfc/rfc3986.txt). The following schemes are supported: ‘tftp’, ‘ftp’, ‘ftps’, ‘http’, ‘https’ and ‘sftp’. For SFTP connections (Business Edition only), the path is not relative to the user’s home directory, but must be the full system path.
  • pHeaders: For HTTP(s) connections, the headers to be sent to the server. For all other protocols, leave this blank.
  • pCallback: Specify a callback message to be sent to the current object when the transfer is complete.
  • pSettings: An array of additional settings that control how the transfer is initiated.

Returns:

The tsNetGetFile function returns empty on success. On error, the return value will be a string containing the error starting with
“tsneterr:”.

Description:

This function sends a callback message on completion. To save memory, it is recommended to call tsNetCloseConn when the connection is no longer needed.

The callback message will be sent with four parameters: the connection identifier, the status code sent back by the server, the number of bytes transferred and the cURL result code.

The cURL result code parameter in the callback message will be 0 for successful transfers. For any errors, further information can be
retrieved by calling the tsNetRetrError function.

The settings array can consist of the following elements (not all of the settings make sense for every possible transfer type): 

"byte_range": (Introduced in tsNet version 1.4.0) Specify the range of data to be downloaded. This can be in the format of “X-Y”, “X-“, “-Y” or “X-Y,N-M” where X, Y, N and M and byte indexes. Some HTTP servers may ignore this request.

"cookie_file": (Introduced in tsNet version 1.4.0) Specify a filename to load cookies from. If this setting is present, the internal cookie engine will be enabled and the cookies stored in the file loaded into the engine.

"cookies": (Introduced in tsNet version 1.4.0) The contents of this setting will be used to set a cookie in a HTTP request. It should be in the format of COOKIE_NAME=COOKIE_CONTENTS. Specify multiple cookies by separating them with a semi-colon. This setting does not enable the internal cookie engine of tsNet.

"cookie_jar": (Introduced in tsNet version 1.4.0) Specify a filename to write all known cookies to. If this setting is present, the internal cookie engine of tsNet will be enabled. Note that this file will only be written to at unspecified times. Use the “cookie_list” setting below to force the file to be updated.

"cookie_list": (Introduced in tsNet version 1.4.0) Set this to a list of cookies (one per line) in Netscape / Mozilla format or regular HTTP (Set-Cookie:) style format to add to the internal cookie engine. There are also several strings that when passed to this setting will perform additional actions. Passing in the string “ALL” will erase all cookies held in memory. “SESS” will erase all session cookies in memory. “FLUSH” will write all cookies stored in memory to the file specified by the “cookie_jar” setting. “RELOAD” will reload all cookies from file specified by “cookie_file”.

"disable_eprt": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from using the EPRT command when performing active FTP transfers.

"disable_epsv": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from using the EPSV command when performing passive FTP transfers.

"dont_modify_path": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from squashing “/../” and “/./” components from the URL path. RFC 3986 specifies that these should be removed.

“enable_tcp_keepalive”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to send TCP keepalive probes.

“expect100_timeout”: (Introduced in tsNet version 1.4.0) Specify the number of milliseconds to wait for a response with a HTTP 100 (Continue) or HTTP 417 (Expectation Failed) status after setting a HTTP request containing an Expect: 100-continue header. The default is 1000ms.

"fail_on_http_error": Set to true to specify that HTTP status codes greater than 400 should be considered an error.

"force_basic_auth": (Introduced in tsNet version 1.3.1) Set to true to force HTTP basic authentication rather than allow tsNet to detect what authentication methods are supported by the server.

"force_digest_auth": (Introduced in tsNet version 1.3.5) Set to true to force HTTP digest authentication rather than allow tsNet to detect what authentication methods are supported by the server.

“ftp_filemethod”: (Introduced in tsNet version 1.4.0) Set this to “nocwd” or “singlecwd” to change the method used by FTP to reach a particular file. Using “nocwd” will ensure all FTP commands use the full path to the file on the server. Using “singlecwd” will make tsNet issue a single CWD command to change to the directory that the file resides in before performing any other action on the file. The default is to issue a CWD command for each path part in the URL prior to performing any other action on the file in accordance with RFC 1738.

“ftp_ssl_ccc”: (Introduced in tsNet version 1.4.0) Set this to “passive” or “active” to disable the SSL/TLS encryption after authenticating with the FTP server. All further communication on the command channel with the FTP server will be unencrypted. Use “passive” to only disable the encryption after the server requests it. Setting this to “active” will initiate the encryption shutdown.

“ftp_user_alt”: (Introduced in tsNet version 1.4.0) Specify an alternate string to use for authentication if the standard FTP username and password negotiation fails.

“if_mod_since”: (Introduced in tsNet version 1.4.0) If the last modified time (in seconds since 1 Jan 1970) of the file is later than this, then download the file.

“if_unmod_since”: (Introduced in tsNet version 1.4.0) If the last modified time (in seconds since 1 Jan 1970) of the file is earlier than this, then download the file.

“ignore_content_length”: (Introduced in tsNet version 1.4.0) Set this option to true to ignore the content length specified in HTTP or FTP transfers. tsNet will complete the download when the server ends the connection.

“interface”: (Introduced in tsNet version 1.4.0) Specify the interface, IP address or host name to be used for the outgoing connection.

“junk_session_cookies”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to ignore all cookies loaded via the “cookie_file” setting that are session cookies.

“keepalive_idle”: (Introduced in tsNet version 1.4.0) When “enable_tcp_keepalive” is set to true, use this setting to specify the number of second to wait while the connection is idle before sending keepalive probes. The default is 60 seconds.

“keepalive_interval”: (Introduced in tsNet version 1.4.0) When “enable_tcp_keepalive” is set to true, use this setting to specify the number of seconds to wait between sending keepalive probes. The default is 60 seconds.

“local_port_range”: (Introduced in tsNet version 1.4.0) Set the number of consecutive ports above the port specified by the “local_port_start” setting to try when finding an available port for a connection.

“local_port_start”: (Introduced in tsNet version 1.4.0) Set the local port number of the socket to be used for the connection. It is recommended to also set “local_port_range” if you use this setting.

“max_file_size”: (Introduced in tsNet version 1.4.0) Specify the maximum size of a file to download. If the file exceeds this value, the transfer will not start. This option has no affect is the file size is not known prior to the download.

“max_recv_speed”: (Introduced in tsNet version 1.4.0) This option specifies the number of bytes per second to limit a download transfer to. Setting this to 0 disables any limiting.

“max_send_speed”: (Introduced in tsNet version 1.4.0) This option specifies the number of bytes per second to limit an upload transfer to. Setting this to 0 disables any limiting.

"no_reuse": Set to true to specify that the connection to the server should be disconnected and not left open for any future connections.

"no_transfer": Set to true to connect to the server but not perform any transfer.

"password": Set to a string containing the password to be used in any authentication requests from the server.

"post_commands": (Business Edition only) Set to a list of raw FTP/SFTP commands (one per line) that should be executed on the server directly after any transfer.

“post_on_301”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 301 response.

“post_on_302”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 302 response.

“post_on_303”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 303 response.

"pre_commands": (Business Edition only) Set to a list of raw FTP/SFTP commands (one per line) that should be executed on the server prior to any transfer.

“proxy_auth_basic”: (Introduced in tsNet version 1.4.0) Set this option to true to force tsNet to use basic authentication when authenticating with a proxy server.

“proxy_auth_digest”: (Introduced in tsNet version 1.4.0) Set this option to true to force tsNet to use digest authentication when authenticating with a proxy server.

"proxy_headers": Set to a list of headers (one per line) that should be sent to any proxy server that is being used.

“proxy_http_10”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to use HTTP/1.0 for any CONNECT tunnelling.

“referer”: (Introduced in tsNet version 1.4.0) The contents of this setting will be used as the HTTP Referer: header sent as part of a HTTP request.

“resolve_hosts”: (Introduced in tsNet version 1.4.0) Specify a list (one per line) of host to IP addresses to use when resolving host name for a request. Each line must be in the format of “HOSTNAME:PORT:ADDRESS”.

“resume_from”: (Introduced in tsNet version 1.4.0) Specify the number of bytes at which you want a transfer to start downloading or uploading.

"save_sent_headers": Set to true to specify that external should store a copy of all the headers that it sends to the server. This must be set to true to use the tsNetRetrSentHeaders function.

“skip_pasv_ip”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to ignore the IP address from the server’s 227 response message. tsNet will connect the data connection via the same IP address it used to set up the control connection.

“ssl_ciphers”: (Introduced in tsNet version 1.4.0) Use this setting to specify a list of SSL ciphers (separated by colons) to be used when negotiating SSL connections.

“ssl_client_cert”: (Introduced in tsNet version 1.4.1) Specify the filename of a client SSL certificate to use for authentication to the server.

“ssl_client_cert_type”: (Introduced in tsNet version 1.4.1) Set to the format of the client SSL certificate. Supported formats are “PEM”, “DER” and “P12”.

“ssl_client_key”: (Introduced in tsNet version 1.4.1) Specify the filename of a SSL private key file that matches the client SSL certificate.

“ssl_client_key_pass”: (Introduced in tsNet version 1.4.1) Set to the password for the SSL private key.

“ssl_client_key_type”: (Introduced in tsNet version 1.4.1) Set to the format of the SSL private key. Supported formats are “PEM” and “DER”.

“ssl_proxy_client_cert”: (Introduced in tsNet version 1.4.1) Specify the filename of a proxy client SSL certificate to use for authentication to the HTTP proxy.

“ssl_proxy_client_cert_type”: (Introduced in tsNet version 1.4.1) Set to the format of the proxy client SSL certificate. Supported formats are “PEM”, “DER” and “P12”.

“ssl_proxy_client_key”: (Introduced in tsNet version 1.4.1) Specify the filename of a SSL private key file that matches the proxy client SSL certificate.

“ssl_proxy_client_key_pass”: (Introduced in tsNet version 1.4.1) Set to the password for the SSL private key.

“ssl_proxy_client_key_type”: (Introduced in tsNet version 1.4.1) Set to the format of the SSL private key. Supported formats are “PEM” and “DER”.

"ssh_host_public_key": Set to the 128 bit MD5 checksum of the remote host's public key. The connection will be rejected unless they match.

"ssh_passphrase": (Business Edition only) Set to the passphrase for any included private key.

"ssh_private_key": (Business Edition only) Set to the private key file (including full system path) to be used in SFTP transfers.

“trace”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to include all inbound and outbound data when using tsNetSetDebugCallback() rather than just header and informational data. When this option is set, a third parameter will be posted to the debug callback function specifying the type of data that is being passed to the callback function.

“transfer_encoding”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to request the response be sent in a compressed Transfer-Encoding (if the server supports it) that will be automatically uncompressed by tsNet when it is received.

“trust_location_auth”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to continue to send authentication details when following any HTTP redirects.

“try_ssl”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to try to connect via SSL. If the connection fails to establish via SSL, connect without using SSL.

“tunnel_http_proxy”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to tunnel all operations (all protocols) through the HTTP proxy.

“use_ascii_transfer”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to use ASCII mode for FTP transfers.

“use_pret”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to send a PRET command before sending PASV/EPSV when performing passive FTP transfers.

"use_ssl": Set to true to connect using Transport Layer Security (TLS) for SMTPS and FTPS (explicit) connections.

"username": Set to a string containing the username to be used in any authentication requests from the server.

“use_ssl_control”: (Introduced in tsNet version 1.4.0) Set this option to true to ensure all control communication is encrypted.

“user_agent”: (Introduced in tsNet version 1.4.0) The contents of this setting will be used as the HTTP User-Agent: header sent as part of a HTTP request.

Function:  tsNetGetFileSync

 

Send a synchronous GET request to a server which stores the returned data directly to a file.

tsNetGetFileSync(<pFile>, <pURL>, <xHeaders>, <rOutHeaders>, <rBytes>, [<pSettings>])

 

Operating Systems supported: Mac OS X, Windows, Linux, iOS and Android

Platforms supported:  Desktop, Server and Mobile

Example:

   local tHeaders, tResult, tBytes, tRecvHeaders
   put tsNetGetFileSync(“/path/to/downloaded/file.dat”, \
      “ftp://user:pass@ftp.example.com/file.dat”, tHeaders, \
      tRecvHeaders, tBytes) into tResult

Parameters:

  • pFile: The full path and filename to store the retrieve data in.
  • pURL: The URL formatted as ‘scheme://host:port/path’ and URL-encoded as outlined in [RFC 3986](http://www.ietf.org/rfc/rfc3986.txt). The following schemes are supported: ‘tftp’, ‘ftp’, ‘ftps’, ‘http’, ‘https’ and ‘sftp’. For SFTP connections (Business Edition only), the path is not relative to the user’s home directory, but must be the full system path.
  • xHeaders: For HTTP(s) connections, the headers to be sent to the server. For all other protocols, leave this blank. The contents of this variable will be replaced when the function returns with the headers that were sent to the server if the “save_sent_headers” array setting is specified below.
  • rOutHeaders: This variable will contain the headers that were returned from the server on completion.
  • rBytes: This variable will contain the number of bytes that were downloaded during the connection.
  • pSettings: An array of additional settings that control how the transfer is initiated.

Returns:

The tsNetGetFileSync function returns the status code sent by the server to the last command that was issued during the transfer on
success. For SFTP connections, this will always be 0. On error, the return value will be a string containing the error starting with “tsneterr:”.

Description:

The settings array can consist of the following elements (not all of the settings make sense for every possible transfer type): 

"byte_range": (Introduced in tsNet version 1.4.0) Specify the range of data to be downloaded. This can be in the format of “X-Y”, “X-“, “-Y” or “X-Y,N-M” where X, Y, N and M and byte indexes. Some HTTP servers may ignore this request.

"cookie_file": (Introduced in tsNet version 1.4.0) Specify a filename to load cookies from. If this setting is present, the internal cookie engine will be enabled and the cookies stored in the file loaded into the engine.

"cookies": (Introduced in tsNet version 1.4.0) The contents of this setting will be used to set a cookie in a HTTP request. It should be in the format of COOKIE_NAME=COOKIE_CONTENTS. Specify multiple cookies by separating them with a semi-colon. This setting does not enable the internal cookie engine of tsNet.

"cookie_jar": (Introduced in tsNet version 1.4.0) Specify a filename to write all known cookies to. If this setting is present, the internal cookie engine of tsNet will be enabled. Note that this file will only be written to at unspecified times. Use the “cookie_list” setting below to force the file to be updated.

"cookie_list": (Introduced in tsNet version 1.4.0) Set this to a list of cookies (one per line) in Netscape / Mozilla format or regular HTTP (Set-Cookie:) style format to add to the internal cookie engine. There are also several strings that when passed to this setting will perform additional actions. Passing in the string “ALL” will erase all cookies held in memory. “SESS” will erase all session cookies in memory. “FLUSH” will write all cookies stored in memory to the file specified by the “cookie_jar” setting. “RELOAD” will reload all cookies from file specified by “cookie_file”.

"disable_eprt": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from using the EPRT command when performing active FTP transfers.

"disable_epsv": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from using the EPSV command when performing passive FTP transfers.

"dont_modify_path": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from squashing “/../” and “/./” components from the URL path. RFC 3986 specifies that these should be removed.

“enable_tcp_keepalive”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to send TCP keepalive probes.

“expect100_timeout”: (Introduced in tsNet version 1.4.0) Specify the number of milliseconds to wait for a response with a HTTP 100 (Continue) or HTTP 417 (Expectation Failed) status after setting a HTTP request containing an Expect: 100-continue header. The default is 1000ms.

"fail_on_http_error": Set to true to specify that HTTP status codes greater than 400 should be considered an error.

"force_basic_auth": (Introduced in tsNet version 1.3.1) Set to true to force HTTP basic authentication rather than allow tsNet to detect what authentication methods are supported by the server.

"force_digest_auth": (Introduced in tsNet version 1.3.5) Set to true to force HTTP digest authentication rather than allow tsNet to detect what authentication methods are supported by the server.

“ftp_filemethod”: (Introduced in tsNet version 1.4.0) Set this to “nocwd” or “singlecwd” to change the method used by FTP to reach a particular file. Using “nocwd” will ensure all FTP commands use the full path to the file on the server. Using “singlecwd” will make tsNet issue a single CWD command to change to the directory that the file resides in before performing any other action on the file. The default is to issue a CWD command for each path part in the URL prior to performing any other action on the file in accordance with RFC 1738.

“ftp_ssl_ccc”: (Introduced in tsNet version 1.4.0) Set this to “passive” or “active” to disable the SSL/TLS encryption after authenticating with the FTP server. All further communication on the command channel with the FTP server will be unencrypted. Use “passive” to only disable the encryption after the server requests it. Setting this to “active” will initiate the encryption shutdown.

“ftp_user_alt”: (Introduced in tsNet version 1.4.0) Specify an alternate string to use for authentication if the standard FTP username and password negotiation fails.

“if_mod_since”: (Introduced in tsNet version 1.4.0) If the last modified time (in seconds since 1 Jan 1970) of the file is later than this, then download the file.

“if_unmod_since”: (Introduced in tsNet version 1.4.0) If the last modified time (in seconds since 1 Jan 1970) of the file is earlier than this, then download the file.

“ignore_content_length”: (Introduced in tsNet version 1.4.0) Set this option to true to ignore the content length specified in HTTP or FTP transfers. tsNet will complete the download when the server ends the connection.

“interface”: (Introduced in tsNet version 1.4.0) Specify the interface, IP address or host name to be used for the outgoing connection.

“junk_session_cookies”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to ignore all cookies loaded via the “cookie_file” setting that are session cookies.

“keepalive_idle”: (Introduced in tsNet version 1.4.0) When “enable_tcp_keepalive” is set to true, use this setting to specify the number of second to wait while the connection is idle before sending keepalive probes. The default is 60 seconds.

“keepalive_interval”: (Introduced in tsNet version 1.4.0) When “enable_tcp_keepalive” is set to true, use this setting to specify the number of seconds to wait between sending keepalive probes. The default is 60 seconds.

“local_port_range”: (Introduced in tsNet version 1.4.0) Set the number of consecutive ports above the port specified by the “local_port_start” setting to try when finding an available port for a connection.

“local_port_start”: (Introduced in tsNet version 1.4.0) Set the local port number of the socket to be used for the connection. It is recommended to also set “local_port_range” if you use this setting.

“max_file_size”: (Introduced in tsNet version 1.4.0) Specify the maximum size of a file to download. If the file exceeds this value, the transfer will not start. This option has no affect is the file size is not known prior to the download.

“max_recv_speed”: (Introduced in tsNet version 1.4.0) This option specifies the number of bytes per second to limit a download transfer to. Setting this to 0 disables any limiting.

“max_send_speed”: (Introduced in tsNet version 1.4.0) This option specifies the number of bytes per second to limit an upload transfer to. Setting this to 0 disables any limiting.

"no_reuse": Set to true to specify that the connection to the server should be disconnected and not left open for any future connections.

"no_transfer": Set to true to connect to the server but not perform any transfer.

"password": Set to a string containing the password to be used in any authentication requests from the server.

"post_commands": (Business Edition only) Set to a list of raw FTP/SFTP commands (one per line) that should be executed on the server directly after any transfer.

“post_on_301”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 301 response.

“post_on_302”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 302 response.

“post_on_303”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 303 response.

"pre_commands": (Business Edition only) Set to a list of raw FTP/SFTP commands (one per line) that should be executed on the server prior to any transfer.

“proxy_auth_basic”: (Introduced in tsNet version 1.4.0) Set this option to true to force tsNet to use basic authentication when authenticating with a proxy server.

“proxy_auth_digest”: (Introduced in tsNet version 1.4.0) Set this option to true to force tsNet to use digest authentication when authenticating with a proxy server.

"proxy_headers": Set to a list of headers (one per line) that should be sent to any proxy server that is being used.

“proxy_http_10”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to use HTTP/1.0 for any CONNECT tunnelling.

“referer”: (Introduced in tsNet version 1.4.0) The contents of this setting will be used as the HTTP Referer: header sent as part of a HTTP request.

“resolve_hosts”: (Introduced in tsNet version 1.4.0) Specify a list (one per line) of host to IP addresses to use when resolving host name for a request. Each line must be in the format of “HOSTNAME:PORT:ADDRESS”.

“resume_from”: (Introduced in tsNet version 1.4.0) Specify the number of bytes at which you want a transfer to start downloading or uploading.

"save_sent_headers": Set to true to specify that external should store a copy of all the headers that it sends to the server. This must be set to true to use the tsNetRetrSentHeaders function.

“skip_pasv_ip”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to ignore the IP address from the server’s 227 response message. tsNet will connect the data connection via the same IP address it used to set up the control connection.

“ssl_ciphers”: (Introduced in tsNet version 1.4.0) Use this setting to specify a list of SSL ciphers (separated by colons) to be used when negotiating SSL connections.

“ssl_client_cert”: (Introduced in tsNet version 1.4.1) Specify the filename of a client SSL certificate to use for authentication to the server.

“ssl_client_cert_type”: (Introduced in tsNet version 1.4.1) Set to the format of the client SSL certificate. Supported formats are “PEM”, “DER” and “P12”.

“ssl_client_key”: (Introduced in tsNet version 1.4.1) Specify the filename of a SSL private key file that matches the client SSL certificate.

“ssl_client_key_pass”: (Introduced in tsNet version 1.4.1) Set to the password for the SSL private key.

“ssl_client_key_type”: (Introduced in tsNet version 1.4.1) Set to the format of the SSL private key. Supported formats are “PEM” and “DER”.

“ssl_proxy_client_cert”: (Introduced in tsNet version 1.4.1) Specify the filename of a proxy client SSL certificate to use for authentication to the HTTP proxy.

“ssl_proxy_client_cert_type”: (Introduced in tsNet version 1.4.1) Set to the format of the proxy client SSL certificate. Supported formats are “PEM”, “DER” and “P12”.

“ssl_proxy_client_key”: (Introduced in tsNet version 1.4.1) Specify the filename of a SSL private key file that matches the proxy client SSL certificate.

“ssl_proxy_client_key_pass”: (Introduced in tsNet version 1.4.1) Set to the password for the SSL private key.

“ssl_proxy_client_key_type”: (Introduced in tsNet version 1.4.1) Set to the format of the SSL private key. Supported formats are “PEM” and “DER”.

"ssh_host_public_key": Set to the 128 bit MD5 checksum of the remote host's public key. The connection will be rejected unless they match.

"ssh_passphrase": (Business Edition only) Set to the passphrase for any included private key.

"ssh_private_key": (Business Edition only) Set to the private key file (including full system path) to be used in SFTP transfers.

“trace”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to include all inbound and outbound data when using tsNetSetDebugCallback() rather than just header and informational data. When this option is set, a third parameter will be posted to the debug callback function specifying the type of data that is being passed to the callback function.

“transfer_encoding”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to request the response be sent in a compressed Transfer-Encoding (if the server supports it) that will be automatically uncompressed by tsNet when it is received.

“trust_location_auth”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to continue to send authentication details when following any HTTP redirects.

“try_ssl”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to try to connect via SSL. If the connection fails to establish via SSL, connect without using SSL.

“tunnel_http_proxy”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to tunnel all operations (all protocols) through the HTTP proxy.

“use_ascii_transfer”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to use ASCII mode for FTP transfers.

“use_pret”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to send a PRET command before sending PASV/EPSV when performing passive FTP transfers.

"use_ssl": Set to true to connect using Transport Layer Security (TLS) for SMTPS and FTPS (explicit) connections.

"username": Set to a string containing the username to be used in any authentication requests from the server.

“use_ssl_control”: (Introduced in tsNet version 1.4.0) Set this option to true to ensure all control communication is encrypted.

“user_agent”: (Introduced in tsNet version 1.4.0) The contents of this setting will be used as the HTTP User-Agent: header sent as part of a HTTP request.

Function:  tsNetGetStatus

 

Returns the status of the specified transfer.

tsNetGetStatus(<pConnectionID>)

 

Operating Systems supported: Mac OS X, Windows, Linux, iOS and Android

Platforms supported:  Desktop, Server and Mobile

Example:

   local tStatus
   put tsNetGetStatus(“myConnID”) into tStatus

Parameters:

  • pConnectionID: The identifier of the transfer to retrieve.

Returns:

The tsNetGetStatus returns a string containing the current status of the connection. The string will be space separated with the
following items: status, bytes downloaded, total bytes to download, bytes uploaded, total bytes to upload. If the connection identifier is
invalid an error will be returned that starts with “tsneterr:”.

 

Function:  tsNetGetSync

 

Send a synchronous GET request to a server.

tsNetGetSync(<pURL>, <xHeaders>, <rOutHeaders>, <rResult>, <rBytes>, [<pSettings>])

 

Operating Systems supported: Mac OS X, Windows, Linux, iOS and Android

Platforms supported:  Desktop, Server and Mobile

Example 1:

   local tHeaders, tResult, tBytes, tRecvHeaders, tData
   put tsNetGetSync(“http://www.livecode.com”, tHeaders, tRecvHeaders, \
      tResult, tBytes) into tData

Example 2:

   local tHeaders, tResult, tBytes, tRecvHeaders, tData
   put tsNetGetSync(“ftp://user:pass@ftp.example.com/file.dat”, \
      tHeaders, tRecvHeaders, tResult, tBytes) into tData

Parameters:

  • pURL: The URL formatted as ‘scheme://host:port/path’ and URL-encoded as outlined in [RFC 3986](http://www.ietf.org/rfc/rfc3986.txt). The following schemes are supported: ‘tftp’, ‘ftp’, ‘ftps’, ‘http’, ‘https’ and ‘sftp’. For SFTP connections, the path is not relative to the user’s home directory, but must be the full system path.
  • xHeaders: For HTTP(s) connections, the headers to be sent to the server. For all other protocols, leave this blank. The contents of this variable will be replaced when the function returns with the headers that were sent to the server if the “save_sent_headers” array setting is specified below.
  • rOutHeaders: This variable will contain the headers that were returned from the server on completion.
  • rResult: This variable will contain the status code sent by the server to the last command that was issued during the transfer. For SFTP connections, this will always be 0. On error, the return value will be a string containing the error starting with “tsneterr:”.
  • rBytes: This variable will contain the number of bytes that were downloaded during the connection.
  • pSettings: An array of additional settings that control how the transfer is initiated.

Returns:

The tsNetGetSync function returns the data retrieved from the server on success.

Description:

The settings array can consist of the following elements (not all of the settings make sense for every possible transfer type): 

"byte_range": (Introduced in tsNet version 1.4.0) Specify the range of data to be downloaded. This can be in the format of “X-Y”, “X-“, “-Y” or “X-Y,N-M” where X, Y, N and M and byte indexes. Some HTTP servers may ignore this request.

"cookie_file": (Introduced in tsNet version 1.4.0) Specify a filename to load cookies from. If this setting is present, the internal cookie engine will be enabled and the cookies stored in the file loaded into the engine.

"cookies": (Introduced in tsNet version 1.4.0) The contents of this setting will be used to set a cookie in a HTTP request. It should be in the format of COOKIE_NAME=COOKIE_CONTENTS. Specify multiple cookies by separating them with a semi-colon. This setting does not enable the internal cookie engine of tsNet.

"cookie_jar": (Introduced in tsNet version 1.4.0) Specify a filename to write all known cookies to. If this setting is present, the internal cookie engine of tsNet will be enabled. Note that this file will only be written to at unspecified times. Use the “cookie_list” setting below to force the file to be updated.

"cookie_list": (Introduced in tsNet version 1.4.0) Set this to a list of cookies (one per line) in Netscape / Mozilla format or regular HTTP (Set-Cookie:) style format to add to the internal cookie engine. There are also several strings that when passed to this setting will perform additional actions. Passing in the string “ALL” will erase all cookies held in memory. “SESS” will erase all session cookies in memory. “FLUSH” will write all cookies stored in memory to the file specified by the “cookie_jar” setting. “RELOAD” will reload all cookies from file specified by “cookie_file”.

"disable_eprt": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from using the EPRT command when performing active FTP transfers.

"disable_epsv": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from using the EPSV command when performing passive FTP transfers.

"dont_modify_path": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from squashing “/../” and “/./” components from the URL path. RFC 3986 specifies that these should be removed.

“enable_tcp_keepalive”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to send TCP keepalive probes.

“expect100_timeout”: (Introduced in tsNet version 1.4.0) Specify the number of milliseconds to wait for a response with a HTTP 100 (Continue) or HTTP 417 (Expectation Failed) status after setting a HTTP request containing an Expect: 100-continue header. The default is 1000ms.

"fail_on_http_error": Set to true to specify that HTTP status codes greater than 400 should be considered an error.

"force_basic_auth": (Introduced in tsNet version 1.3.1) Set to true to force HTTP basic authentication rather than allow tsNet to detect what authentication methods are supported by the server.

"force_digest_auth": (Introduced in tsNet version 1.3.5) Set to true to force HTTP digest authentication rather than allow tsNet to detect what authentication methods are supported by the server.

“ftp_filemethod”: (Introduced in tsNet version 1.4.0) Set this to “nocwd” or “singlecwd” to change the method used by FTP to reach a particular file. Using “nocwd” will ensure all FTP commands use the full path to the file on the server. Using “singlecwd” will make tsNet issue a single CWD command to change to the directory that the file resides in before performing any other action on the file. The default is to issue a CWD command for each path part in the URL prior to performing any other action on the file in accordance with RFC 1738.

“ftp_ssl_ccc”: (Introduced in tsNet version 1.4.0) Set this to “passive” or “active” to disable the SSL/TLS encryption after authenticating with the FTP server. All further communication on the command channel with the FTP server will be unencrypted. Use “passive” to only disable the encryption after the server requests it. Setting this to “active” will initiate the encryption shutdown.

“ftp_user_alt”: (Introduced in tsNet version 1.4.0) Specify an alternate string to use for authentication if the standard FTP username and password negotiation fails.

“if_mod_since”: (Introduced in tsNet version 1.4.0) If the last modified time (in seconds since 1 Jan 1970) of the file is later than this, then download the file.

“if_unmod_since”: (Introduced in tsNet version 1.4.0) If the last modified time (in seconds since 1 Jan 1970) of the file is earlier than this, then download the file.

“ignore_content_length”: (Introduced in tsNet version 1.4.0) Set this option to true to ignore the content length specified in HTTP or FTP transfers. tsNet will complete the download when the server ends the connection.

“interface”: (Introduced in tsNet version 1.4.0) Specify the interface, IP address or host name to be used for the outgoing connection.

“junk_session_cookies”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to ignore all cookies loaded via the “cookie_file” setting that are session cookies.

“keepalive_idle”: (Introduced in tsNet version 1.4.0) When “enable_tcp_keepalive” is set to true, use this setting to specify the number of second to wait while the connection is idle before sending keepalive probes. The default is 60 seconds.

“keepalive_interval”: (Introduced in tsNet version 1.4.0) When “enable_tcp_keepalive” is set to true, use this setting to specify the number of seconds to wait between sending keepalive probes. The default is 60 seconds.

“local_port_range”: (Introduced in tsNet version 1.4.0) Set the number of consecutive ports above the port specified by the “local_port_start” setting to try when finding an available port for a connection.

“local_port_start”: (Introduced in tsNet version 1.4.0) Set the local port number of the socket to be used for the connection. It is recommended to also set “local_port_range” if you use this setting.

“max_file_size”: (Introduced in tsNet version 1.4.0) Specify the maximum size of a file to download. If the file exceeds this value, the transfer will not start. This option has no affect is the file size is not known prior to the download.

“max_recv_speed”: (Introduced in tsNet version 1.4.0) This option specifies the number of bytes per second to limit a download transfer to. Setting this to 0 disables any limiting.

“max_send_speed”: (Introduced in tsNet version 1.4.0) This option specifies the number of bytes per second to limit an upload transfer to. Setting this to 0 disables any limiting.

"no_reuse": Set to true to specify that the connection to the server should be disconnected and not left open for any future connections.

"no_transfer": Set to true to connect to the server but not perform any transfer.

"password": Set to a string containing the password to be used in any authentication requests from the server.

"post_commands": (Business Edition only) Set to a list of raw FTP/SFTP commands (one per line) that should be executed on the server directly after any transfer.

“post_on_301”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 301 response.

“post_on_302”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 302 response.

“post_on_303”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 303 response.

"pre_commands": (Business Edition only) Set to a list of raw FTP/SFTP commands (one per line) that should be executed on the server prior to any transfer.

“proxy_auth_basic”: (Introduced in tsNet version 1.4.0) Set this option to true to force tsNet to use basic authentication when authenticating with a proxy server.

“proxy_auth_digest”: (Introduced in tsNet version 1.4.0) Set this option to true to force tsNet to use digest authentication when authenticating with a proxy server.

"proxy_headers": Set to a list of headers (one per line) that should be sent to any proxy server that is being used.

“proxy_http_10”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to use HTTP/1.0 for any CONNECT tunnelling.

“referer”: (Introduced in tsNet version 1.4.0) The contents of this setting will be used as the HTTP Referer: header sent as part of a HTTP request.

“resolve_hosts”: (Introduced in tsNet version 1.4.0) Specify a list (one per line) of host to IP addresses to use when resolving host name for a request. Each line must be in the format of “HOSTNAME:PORT:ADDRESS”.

“resume_from”: (Introduced in tsNet version 1.4.0) Specify the number of bytes at which you want a transfer to start downloading or uploading.

"save_sent_headers": Set to true to specify that external should store a copy of all the headers that it sends to the server. This must be set to true to use the tsNetRetrSentHeaders function.

“skip_pasv_ip”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to ignore the IP address from the server’s 227 response message. tsNet will connect the data connection via the same IP address it used to set up the control connection.

“ssl_ciphers”: (Introduced in tsNet version 1.4.0) Use this setting to specify a list of SSL ciphers (separated by colons) to be used when negotiating SSL connections.

“ssl_client_cert”: (Introduced in tsNet version 1.4.1) Specify the filename of a client SSL certificate to use for authentication to the server.

“ssl_client_cert_type”: (Introduced in tsNet version 1.4.1) Set to the format of the client SSL certificate. Supported formats are “PEM”, “DER” and “P12”.

“ssl_client_key”: (Introduced in tsNet version 1.4.1) Specify the filename of a SSL private key file that matches the client SSL certificate.

“ssl_client_key_pass”: (Introduced in tsNet version 1.4.1) Set to the password for the SSL private key.

“ssl_client_key_type”: (Introduced in tsNet version 1.4.1) Set to the format of the SSL private key. Supported formats are “PEM” and “DER”.

“ssl_proxy_client_cert”: (Introduced in tsNet version 1.4.1) Specify the filename of a proxy client SSL certificate to use for authentication to the HTTP proxy.

“ssl_proxy_client_cert_type”: (Introduced in tsNet version 1.4.1) Set to the format of the proxy client SSL certificate. Supported formats are “PEM”, “DER” and “P12”.

“ssl_proxy_client_key”: (Introduced in tsNet version 1.4.1) Specify the filename of a SSL private key file that matches the proxy client SSL certificate.

“ssl_proxy_client_key_pass”: (Introduced in tsNet version 1.4.1) Set to the password for the SSL private key.

“ssl_proxy_client_key_type”: (Introduced in tsNet version 1.4.1) Set to the format of the SSL private key. Supported formats are “PEM” and “DER”.

"ssh_host_public_key": Set to the 128 bit MD5 checksum of the remote host's public key. The connection will be rejected unless they match.

"ssh_passphrase": (Business Edition only) Set to the passphrase for any included private key.

"ssh_private_key": (Business Edition only) Set to the private key file (including full system path) to be used in SFTP transfers.

“trace”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to include all inbound and outbound data when using tsNetSetDebugCallback() rather than just header and informational data. When this option is set, a third parameter will be posted to the debug callback function specifying the type of data that is being passed to the callback function.

“transfer_encoding”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to request the response be sent in a compressed Transfer-Encoding (if the server supports it) that will be automatically uncompressed by tsNet when it is received.

“trust_location_auth”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to continue to send authentication details when following any HTTP redirects.

“try_ssl”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to try to connect via SSL. If the connection fails to establish via SSL, connect without using SSL.

“tunnel_http_proxy”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to tunnel all operations (all protocols) through the HTTP proxy.

“use_ascii_transfer”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to use ASCII mode for FTP transfers.

“use_pret”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to send a PRET command before sending PASV/EPSV when performing passive FTP transfers.

"use_ssl": Set to true to connect using Transport Layer Security (TLS) for SMTPS and FTPS (explicit) connections.

"username": Set to a string containing the username to be used in any authentication requests from the server.

“use_ssl_control”: (Introduced in tsNet version 1.4.0) Set this option to true to ensure all control communication is encrypted.

“user_agent”: (Introduced in tsNet version 1.4.0) The contents of this setting will be used as the HTTP User-Agent: header sent as part of a HTTP request.

Function:  tsNetGetTimeouts

(Introduced in tsNet version 1.3.5)

Returns the current timeout values used by tsNet external.

tsNetGetTimeouts()

 

Operating Systems supported: Mac OS X, Windows, Linux, iOS and Android

Platforms supported:  Desktop, Server and Mobile

Example:

   put tsNetGetTimeouts() into tTimeouts
   set the itemDel to comma
   put item 1 of tTimeouts into tDnsCacheTimeout
   put item 2 of tTimeouts into tRequestTimeoutMS
   put item 3 of tTimeouts into tConnectTimeoutMS
   put item 4 of tTimeouts into tAcceptTimeoutMS
   put item 5 of tTimeouts into tLowSpeedTime
   put item 6 of tTimeouts into tLowSpeedLimit

Returns:

The tsNetGetTimeouts function returns a comma separated list of timeout values in the following order: DNS cache timeout, request timeout, connect timeout, accept timeout, low speed time, low speed limit. For more information about these values, look at the information listed under the <tsNetSetTimeouts> command.

 

Function:  tsNetHead

 

Send an asynchronous request to a server specifying that no body be transferred.

tsNetHead(<pConnectionID>, <pURL>, <pHeaders>, <pCallback>, [<pSettings>])

 

Operating Systems supported: Mac OS X, Windows, Linux, iOS and Android

Platforms supported:  Desktop, Server and Mobile

Example 1:

   local tHeaders, tResult
   put tsNetHead(“1”, “http://www.livecode.com”, tHeaders, \
      “transferComplete”) into tResult

Example 2:

   on transferComplete pID, pResult, pBytes, pCurlCode
      local tData, tHeaders
      if pCurlCode is not 0 then
         answer tsNetRetrError(pID)
      end if
      put tsNetRetrData(pID, tError) into tData
      tsNetCloseConn pID
      answer “Headers returned:” & tData
   end transferComplete

Parameters:

  • pConnectionID: A arbitrary user-defined label for the connection that is used when retrieving any details of the transfer.
  • pURL: The URL formatted as ‘scheme://host:port/path’ and URL-encoded as outlined in [RFC 3986](http://www.ietf.org/rfc/rfc3986.txt). The following schemes are supported: ‘tftp’, ‘ftp’, ‘ftps’, ‘http’, ‘https’ and ‘sftp’. For SFTP connections, the path is not relative to the user’s home directory, but must be the full system path.
  • pHeaders: For HTTP(s) connections, the headers to be sent to the server. For all other protocols, leave this blank.
  • pCallback: Specify a callback message to be sent to the current object when the transfer is complete.
  • pSettings: An array of additional settings that control how the transfer is initiated.

Returns:

The tsNetHead function returns empty on success. On error, the return value will be a string containing the error starting with”tsneterr:”.

Description:

This function sends a callback message on completion. Use <tsNetRetrHeaders> to access the returned headers. To save memory, it is recommended to call tsNetCloseConn when the connection is no longer needed.

The callback message will be sent with four parameters: the connection identifier, the status code sent back by the server, the number of bytes transferred and the cURL result code.

The cURL result code parameter in the callback message will be 0 for successful transfers. For any errors, further information can be retrieved by calling the tsNetRetrError function.

The settings array can consist of the following elements (not all of the settings make sense for every possible transfer type): 

"byte_range": (Introduced in tsNet version 1.4.0) Specify the range of data to be downloaded. This can be in the format of “X-Y”, “X-“, “-Y” or “X-Y,N-M” where X, Y, N and M and byte indexes. Some HTTP servers may ignore this request.

"cookie_file": (Introduced in tsNet version 1.4.0) Specify a filename to load cookies from. If this setting is present, the internal cookie engine will be enabled and the cookies stored in the file loaded into the engine.

"cookies": (Introduced in tsNet version 1.4.0) The contents of this setting will be used to set a cookie in a HTTP request. It should be in the format of COOKIE_NAME=COOKIE_CONTENTS. Specify multiple cookies by separating them with a semi-colon. This setting does not enable the internal cookie engine of tsNet.

"cookie_jar": (Introduced in tsNet version 1.4.0) Specify a filename to write all known cookies to. If this setting is present, the internal cookie engine of tsNet will be enabled. Note that this file will only be written to at unspecified times. Use the “cookie_list” setting below to force the file to be updated.

"cookie_list": (Introduced in tsNet version 1.4.0) Set this to a list of cookies (one per line) in Netscape / Mozilla format or regular HTTP (Set-Cookie:) style format to add to the internal cookie engine. There are also several strings that when passed to this setting will perform additional actions. Passing in the string “ALL” will erase all cookies held in memory. “SESS” will erase all session cookies in memory. “FLUSH” will write all cookies stored in memory to the file specified by the “cookie_jar” setting. “RELOAD” will reload all cookies from file specified by “cookie_file”.

"disable_eprt": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from using the EPRT command when performing active FTP transfers.

"disable_epsv": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from using the EPSV command when performing passive FTP transfers.

"dont_modify_path": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from squashing “/../” and “/./” components from the URL path. RFC 3986 specifies that these should be removed.

“enable_tcp_keepalive”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to send TCP keepalive probes.

“expect100_timeout”: (Introduced in tsNet version 1.4.0) Specify the number of milliseconds to wait for a response with a HTTP 100 (Continue) or HTTP 417 (Expectation Failed) status after setting a HTTP request containing an Expect: 100-continue header. The default is 1000ms.

"fail_on_http_error": Set to true to specify that HTTP status codes greater than 400 should be considered an error.

"force_basic_auth": (Introduced in tsNet version 1.3.1) Set to true to force HTTP basic authentication rather than allow tsNet to detect what authentication methods are supported by the server.

"force_digest_auth": (Introduced in tsNet version 1.3.5) Set to true to force HTTP digest authentication rather than allow tsNet to detect what authentication methods are supported by the server.

“ftp_filemethod”: (Introduced in tsNet version 1.4.0) Set this to “nocwd” or “singlecwd” to change the method used by FTP to reach a particular file. Using “nocwd” will ensure all FTP commands use the full path to the file on the server. Using “singlecwd” will make tsNet issue a single CWD command to change to the directory that the file resides in before performing any other action on the file. The default is to issue a CWD command for each path part in the URL prior to performing any other action on the file in accordance with RFC 1738.

“ftp_ssl_ccc”: (Introduced in tsNet version 1.4.0) Set this to “passive” or “active” to disable the SSL/TLS encryption after authenticating with the FTP server. All further communication on the command channel with the FTP server will be unencrypted. Use “passive” to only disable the encryption after the server requests it. Setting this to “active” will initiate the encryption shutdown.

“ftp_user_alt”: (Introduced in tsNet version 1.4.0) Specify an alternate string to use for authentication if the standard FTP username and password negotiation fails.

“if_mod_since”: (Introduced in tsNet version 1.4.0) If the last modified time (in seconds since 1 Jan 1970) of the file is later than this, then download the file.

“if_unmod_since”: (Introduced in tsNet version 1.4.0) If the last modified time (in seconds since 1 Jan 1970) of the file is earlier than this, then download the file.

“ignore_content_length”: (Introduced in tsNet version 1.4.0) Set this option to true to ignore the content length specified in HTTP or FTP transfers. tsNet will complete the download when the server ends the connection.

“interface”: (Introduced in tsNet version 1.4.0) Specify the interface, IP address or host name to be used for the outgoing connection.

“junk_session_cookies”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to ignore all cookies loaded via the “cookie_file” setting that are session cookies.

“keepalive_idle”: (Introduced in tsNet version 1.4.0) When “enable_tcp_keepalive” is set to true, use this setting to specify the number of second to wait while the connection is idle before sending keepalive probes. The default is 60 seconds.

“keepalive_interval”: (Introduced in tsNet version 1.4.0) When “enable_tcp_keepalive” is set to true, use this setting to specify the number of seconds to wait between sending keepalive probes. The default is 60 seconds.

“local_port_range”: (Introduced in tsNet version 1.4.0) Set the number of consecutive ports above the port specified by the “local_port_start” setting to try when finding an available port for a connection.

“local_port_start”: (Introduced in tsNet version 1.4.0) Set the local port number of the socket to be used for the connection. It is recommended to also set “local_port_range” if you use this setting.

“max_file_size”: (Introduced in tsNet version 1.4.0) Specify the maximum size of a file to download. If the file exceeds this value, the transfer will not start. This option has no affect is the file size is not known prior to the download.

“max_recv_speed”: (Introduced in tsNet version 1.4.0) This option specifies the number of bytes per second to limit a download transfer to. Setting this to 0 disables any limiting.

“max_send_speed”: (Introduced in tsNet version 1.4.0) This option specifies the number of bytes per second to limit an upload transfer to. Setting this to 0 disables any limiting.

"no_reuse": Set to true to specify that the connection to the server should be disconnected and not left open for any future connections.

"no_transfer": Set to true to connect to the server but not perform any transfer.

"password": Set to a string containing the password to be used in any authentication requests from the server.

"post_commands": (Business Edition only) Set to a list of raw FTP/SFTP commands (one per line) that should be executed on the server directly after any transfer.

“post_on_301”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 301 response.

“post_on_302”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 302 response.

“post_on_303”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 303 response.

"pre_commands": (Business Edition only) Set to a list of raw FTP/SFTP commands (one per line) that should be executed on the server prior to any transfer.

“proxy_auth_basic”: (Introduced in tsNet version 1.4.0) Set this option to true to force tsNet to use basic authentication when authenticating with a proxy server.

“proxy_auth_digest”: (Introduced in tsNet version 1.4.0) Set this option to true to force tsNet to use digest authentication when authenticating with a proxy server.

"proxy_headers": Set to a list of headers (one per line) that should be sent to any proxy server that is being used.

“proxy_http_10”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to use HTTP/1.0 for any CONNECT tunnelling.

“referer”: (Introduced in tsNet version 1.4.0) The contents of this setting will be used as the HTTP Referer: header sent as part of a HTTP request.

“resolve_hosts”: (Introduced in tsNet version 1.4.0) Specify a list (one per line) of host to IP addresses to use when resolving host name for a request. Each line must be in the format of “HOSTNAME:PORT:ADDRESS”.

“resume_from”: (Introduced in tsNet version 1.4.0) Specify the number of bytes at which you want a transfer to start downloading or uploading.

"save_sent_headers": Set to true to specify that external should store a copy of all the headers that it sends to the server. This must be set to true to use the tsNetRetrSentHeaders function.

“skip_pasv_ip”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to ignore the IP address from the server’s 227 response message. tsNet will connect the data connection via the same IP address it used to set up the control connection.

“ssl_ciphers”: (Introduced in tsNet version 1.4.0) Use this setting to specify a list of SSL ciphers (separated by colons) to be used when negotiating SSL connections.

“ssl_client_cert”: (Introduced in tsNet version 1.4.1) Specify the filename of a client SSL certificate to use for authentication to the server.

“ssl_client_cert_type”: (Introduced in tsNet version 1.4.1) Set to the format of the client SSL certificate. Supported formats are “PEM”, “DER” and “P12”.

“ssl_client_key”: (Introduced in tsNet version 1.4.1) Specify the filename of a SSL private key file that matches the client SSL certificate.

“ssl_client_key_pass”: (Introduced in tsNet version 1.4.1) Set to the password for the SSL private key.

“ssl_client_key_type”: (Introduced in tsNet version 1.4.1) Set to the format of the SSL private key. Supported formats are “PEM” and “DER”.

“ssl_proxy_client_cert”: (Introduced in tsNet version 1.4.1) Specify the filename of a proxy client SSL certificate to use for authentication to the HTTP proxy.

“ssl_proxy_client_cert_type”: (Introduced in tsNet version 1.4.1) Set to the format of the proxy client SSL certificate. Supported formats are “PEM”, “DER” and “P12”.

“ssl_proxy_client_key”: (Introduced in tsNet version 1.4.1) Specify the filename of a SSL private key file that matches the proxy client SSL certificate.

“ssl_proxy_client_key_pass”: (Introduced in tsNet version 1.4.1) Set to the password for the SSL private key.

“ssl_proxy_client_key_type”: (Introduced in tsNet version 1.4.1) Set to the format of the SSL private key. Supported formats are “PEM” and “DER”.

"ssh_host_public_key": Set to the 128 bit MD5 checksum of the remote host's public key. The connection will be rejected unless they match.

"ssh_passphrase": (Business Edition only) Set to the passphrase for any included private key.

"ssh_private_key": (Business Edition only) Set to the private key file (including full system path) to be used in SFTP transfers.

“trace”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to include all inbound and outbound data when using tsNetSetDebugCallback() rather than just header and informational data. When this option is set, a third parameter will be posted to the debug callback function specifying the type of data that is being passed to the callback function.

“transfer_encoding”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to request the response be sent in a compressed Transfer-Encoding (if the server supports it) that will be automatically uncompressed by tsNet when it is received.

“trust_location_auth”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to continue to send authentication details when following any HTTP redirects.

“try_ssl”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to try to connect via SSL. If the connection fails to establish via SSL, connect without using SSL.

“tunnel_http_proxy”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to tunnel all operations (all protocols) through the HTTP proxy.

“use_ascii_transfer”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to use ASCII mode for FTP transfers.

“use_pret”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to send a PRET command before sending PASV/EPSV when performing passive FTP transfers.

"use_ssl": Set to true to connect using Transport Layer Security (TLS) for SMTPS and FTPS (explicit) connections.

"username": Set to a string containing the username to be used in any authentication requests from the server.

“use_ssl_control”: (Introduced in tsNet version 1.4.0) Set this option to true to ensure all control communication is encrypted.

“user_agent”: (Introduced in tsNet version 1.4.0) The contents of this setting will be used as the HTTP User-Agent: header sent as part of a HTTP request.

Function:  tsNetHeadSync

 

Send a synchronous request to a server specifying that no body be transferred.

tsNetHeadSync(<pURL>, <xHeaders>, <rResult>, <rBytes>, [<pSettings>])

 

Operating Systems supported: Mac OS X, Windows, Linux, iOS and Android

Platforms supported:  Desktop, Server and Mobile

Example:

   local tSentHeaders, tResult, tBytes, tHeaders
   put tsNetHeadSync(“http://www.livecode.com”, tSentHeaders, tResult, \
      tBytes) into tHeaders

Parameters:

  • pURL: The URL formatted as ‘scheme://host:port/path’ and URL-encoded as outlined in [RFC 3986](http://www.ietf.org/rfc/rfc3986.txt). The following schemes are supported: ‘tftp’, ‘ftp’, ‘ftps’, ‘http’, ‘https’ and ‘sftp’. For SFTP connections, the path is not relative to the user’s home directory, but must be the full system path.
  • xHeaders: For HTTP(s) connections, the headers to be sent to the server. For all other protocols, leave this blank. The contents of this variable will be replaced when the function returns with the headers that were sent to the server if the “save_sent_headers” array setting is specified below.
  • rResult: This variable will contain the status code sent by the server to the last command that was issued during the transfer. For SFTP connections, this will always be 0. On error, the return value will be a string containing the error starting with “tsneterr:”.
  • rBytes: This variable will contain the number of bytes that were downloaded during the connection.
  • pSettings: An array of additional settings that control how the transfer is initiated.

Returns:

The tsNetHeadSync function returns the headers retrieved from the server on success.

Description:

The settings array can consist of the following elements (not all of the settings make sense for every possible transfer type): 

"byte_range": (Introduced in tsNet version 1.4.0) Specify the range of data to be downloaded. This can be in the format of “X-Y”, “X-“, “-Y” or “X-Y,N-M” where X, Y, N and M and byte indexes. Some HTTP servers may ignore this request.

"cookie_file": (Introduced in tsNet version 1.4.0) Specify a filename to load cookies from. If this setting is present, the internal cookie engine will be enabled and the cookies stored in the file loaded into the engine.

"cookies": (Introduced in tsNet version 1.4.0) The contents of this setting will be used to set a cookie in a HTTP request. It should be in the format of COOKIE_NAME=COOKIE_CONTENTS. Specify multiple cookies by separating them with a semi-colon. This setting does not enable the internal cookie engine of tsNet.

"cookie_jar": (Introduced in tsNet version 1.4.0) Specify a filename to write all known cookies to. If this setting is present, the internal cookie engine of tsNet will be enabled. Note that this file will only be written to at unspecified times. Use the “cookie_list” setting below to force the file to be updated.

"cookie_list": (Introduced in tsNet version 1.4.0) Set this to a list of cookies (one per line) in Netscape / Mozilla format or regular HTTP (Set-Cookie:) style format to add to the internal cookie engine. There are also several strings that when passed to this setting will perform additional actions. Passing in the string “ALL” will erase all cookies held in memory. “SESS” will erase all session cookies in memory. “FLUSH” will write all cookies stored in memory to the file specified by the “cookie_jar” setting. “RELOAD” will reload all cookies from file specified by “cookie_file”.

"disable_eprt": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from using the EPRT command when performing active FTP transfers.

"disable_epsv": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from using the EPSV command when performing passive FTP transfers.

"dont_modify_path": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from squashing “/../” and “/./” components from the URL path. RFC 3986 specifies that these should be removed.

“enable_tcp_keepalive”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to send TCP keepalive probes.

“expect100_timeout”: (Introduced in tsNet version 1.4.0) Specify the number of milliseconds to wait for a response with a HTTP 100 (Continue) or HTTP 417 (Expectation Failed) status after setting a HTTP request containing an Expect: 100-continue header. The default is 1000ms.

"fail_on_http_error": Set to true to specify that HTTP status codes greater than 400 should be considered an error.

"force_basic_auth": (Introduced in tsNet version 1.3.1) Set to true to force HTTP basic authentication rather than allow tsNet to detect what authentication methods are supported by the server.

"force_digest_auth": (Introduced in tsNet version 1.3.5) Set to true to force HTTP digest authentication rather than allow tsNet to detect what authentication methods are supported by the server.

“ftp_filemethod”: (Introduced in tsNet version 1.4.0) Set this to “nocwd” or “singlecwd” to change the method used by FTP to reach a particular file. Using “nocwd” will ensure all FTP commands use the full path to the file on the server. Using “singlecwd” will make tsNet issue a single CWD command to change to the directory that the file resides in before performing any other action on the file. The default is to issue a CWD command for each path part in the URL prior to performing any other action on the file in accordance with RFC 1738.

“ftp_ssl_ccc”: (Introduced in tsNet version 1.4.0) Set this to “passive” or “active” to disable the SSL/TLS encryption after authenticating with the FTP server. All further communication on the command channel with the FTP server will be unencrypted. Use “passive” to only disable the encryption after the server requests it. Setting this to “active” will initiate the encryption shutdown.

“ftp_user_alt”: (Introduced in tsNet version 1.4.0) Specify an alternate string to use for authentication if the standard FTP username and password negotiation fails.

“if_mod_since”: (Introduced in tsNet version 1.4.0) If the last modified time (in seconds since 1 Jan 1970) of the file is later than this, then download the file.

“if_unmod_since”: (Introduced in tsNet version 1.4.0) If the last modified time (in seconds since 1 Jan 1970) of the file is earlier than this, then download the file.

“ignore_content_length”: (Introduced in tsNet version 1.4.0) Set this option to true to ignore the content length specified in HTTP or FTP transfers. tsNet will complete the download when the server ends the connection.

“interface”: (Introduced in tsNet version 1.4.0) Specify the interface, IP address or host name to be used for the outgoing connection.

“junk_session_cookies”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to ignore all cookies loaded via the “cookie_file” setting that are session cookies.

“keepalive_idle”: (Introduced in tsNet version 1.4.0) When “enable_tcp_keepalive” is set to true, use this setting to specify the number of second to wait while the connection is idle before sending keepalive probes. The default is 60 seconds.

“keepalive_interval”: (Introduced in tsNet version 1.4.0) When “enable_tcp_keepalive” is set to true, use this setting to specify the number of seconds to wait between sending keepalive probes. The default is 60 seconds.

“local_port_range”: (Introduced in tsNet version 1.4.0) Set the number of consecutive ports above the port specified by the “local_port_start” setting to try when finding an available port for a connection.

“local_port_start”: (Introduced in tsNet version 1.4.0) Set the local port number of the socket to be used for the connection. It is recommended to also set “local_port_range” if you use this setting.

“max_file_size”: (Introduced in tsNet version 1.4.0) Specify the maximum size of a file to download. If the file exceeds this value, the transfer will not start. This option has no affect is the file size is not known prior to the download.

“max_recv_speed”: (Introduced in tsNet version 1.4.0) This option specifies the number of bytes per second to limit a download transfer to. Setting this to 0 disables any limiting.

“max_send_speed”: (Introduced in tsNet version 1.4.0) This option specifies the number of bytes per second to limit an upload transfer to. Setting this to 0 disables any limiting.

"no_reuse": Set to true to specify that the connection to the server should be disconnected and not left open for any future connections.

"no_transfer": Set to true to connect to the server but not perform any transfer.

"password": Set to a string containing the password to be used in any authentication requests from the server.

"post_commands": (Business Edition only) Set to a list of raw FTP/SFTP commands (one per line) that should be executed on the server directly after any transfer.

“post_on_301”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 301 response.

“post_on_302”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 302 response.

“post_on_303”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 303 response.

"pre_commands": (Business Edition only) Set to a list of raw FTP/SFTP commands (one per line) that should be executed on the server prior to any transfer.

“proxy_auth_basic”: (Introduced in tsNet version 1.4.0) Set this option to true to force tsNet to use basic authentication when authenticating with a proxy server.

“proxy_auth_digest”: (Introduced in tsNet version 1.4.0) Set this option to true to force tsNet to use digest authentication when authenticating with a proxy server.

"proxy_headers": Set to a list of headers (one per line) that should be sent to any proxy server that is being used.

“proxy_http_10”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to use HTTP/1.0 for any CONNECT tunnelling.

“referer”: (Introduced in tsNet version 1.4.0) The contents of this setting will be used as the HTTP Referer: header sent as part of a HTTP request.

“resolve_hosts”: (Introduced in tsNet version 1.4.0) Specify a list (one per line) of host to IP addresses to use when resolving host name for a request. Each line must be in the format of “HOSTNAME:PORT:ADDRESS”.

“resume_from”: (Introduced in tsNet version 1.4.0) Specify the number of bytes at which you want a transfer to start downloading or uploading.

"save_sent_headers": Set to true to specify that external should store a copy of all the headers that it sends to the server. This must be set to true to use the tsNetRetrSentHeaders function.

“skip_pasv_ip”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to ignore the IP address from the server’s 227 response message. tsNet will connect the data connection via the same IP address it used to set up the control connection.

“ssl_ciphers”: (Introduced in tsNet version 1.4.0) Use this setting to specify a list of SSL ciphers (separated by colons) to be used when negotiating SSL connections.

“ssl_client_cert”: (Introduced in tsNet version 1.4.1) Specify the filename of a client SSL certificate to use for authentication to the server.

“ssl_client_cert_type”: (Introduced in tsNet version 1.4.1) Set to the format of the client SSL certificate. Supported formats are “PEM”, “DER” and “P12”.

“ssl_client_key”: (Introduced in tsNet version 1.4.1) Specify the filename of a SSL private key file that matches the client SSL certificate.

“ssl_client_key_pass”: (Introduced in tsNet version 1.4.1) Set to the password for the SSL private key.

“ssl_client_key_type”: (Introduced in tsNet version 1.4.1) Set to the format of the SSL private key. Supported formats are “PEM” and “DER”.

“ssl_proxy_client_cert”: (Introduced in tsNet version 1.4.1) Specify the filename of a proxy client SSL certificate to use for authentication to the HTTP proxy.

“ssl_proxy_client_cert_type”: (Introduced in tsNet version 1.4.1) Set to the format of the proxy client SSL certificate. Supported formats are “PEM”, “DER” and “P12”.

“ssl_proxy_client_key”: (Introduced in tsNet version 1.4.1) Specify the filename of a SSL private key file that matches the proxy client SSL certificate.

“ssl_proxy_client_key_pass”: (Introduced in tsNet version 1.4.1) Set to the password for the SSL private key.

“ssl_proxy_client_key_type”: (Introduced in tsNet version 1.4.1) Set to the format of the SSL private key. Supported formats are “PEM” and “DER”.

"ssh_host_public_key": Set to the 128 bit MD5 checksum of the remote host's public key. The connection will be rejected unless they match.

"ssh_passphrase": (Business Edition only) Set to the passphrase for any included private key.

"ssh_private_key": (Business Edition only) Set to the private key file (including full system path) to be used in SFTP transfers.

“trace”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to include all inbound and outbound data when using tsNetSetDebugCallback() rather than just header and informational data. When this option is set, a third parameter will be posted to the debug callback function specifying the type of data that is being passed to the callback function.

“transfer_encoding”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to request the response be sent in a compressed Transfer-Encoding (if the server supports it) that will be automatically uncompressed by tsNet when it is received.

“trust_location_auth”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to continue to send authentication details when following any HTTP redirects.

“try_ssl”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to try to connect via SSL. If the connection fails to establish via SSL, connect without using SSL.

“tunnel_http_proxy”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to tunnel all operations (all protocols) through the HTTP proxy.

“use_ascii_transfer”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to use ASCII mode for FTP transfers.

“use_pret”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to send a PRET command before sending PASV/EPSV when performing passive FTP transfers.

"use_ssl": Set to true to connect using Transport Layer Security (TLS) for SMTPS and FTPS (explicit) connections.

"username": Set to a string containing the username to be used in any authentication requests from the server.

“use_ssl_control”: (Introduced in tsNet version 1.4.0) Set this option to true to ensure all control communication is encrypted.

“user_agent”: (Introduced in tsNet version 1.4.0) The contents of this setting will be used as the HTTP User-Agent: header sent as part of a HTTP request.

Command:  tsNetInit

 

Initialises the tsNet external. This must be done prior to calling any other functions within the tsNet library.

tsNetInit

 

Operating Systems supported: Mac OS X, Windows, Linux, iOS and Android

Platforms supported:  Desktop, Server and Mobile

Example:

   tsNetInit

The result:

The tsNetInit command puts empty into the result if successful. Otherwise an error string is put into the result.

 

Function:  tsNetIsSyncBlocked

 

Returns whether another synchronous call can be made immediately.

tsNetIsSyncBlocked()

 

Operating Systems supported: Mac OS X, Windows, Linux, iOS and Android

Platforms supported:  Desktop, Server and Mobile

Example:

   if tsNetIsSyncBlocked() then
      answer “A synchronous network call is already in progress”
   end if

Returns:

The tsNetIsSyncBlocked command returns true if no more synchronous network calls can be made at the current time or false
otherwise.

 

Command:  tsNetLibUrlReuseConnection

(Introduced in tsNet version 1.2.1)

Enable or disable connection re-use when using tsNet with libUrl.

tsNetLibUrlReuseConnection <pEnable>

 

Operating Systems supported: Mac OS X, Windows, Linux, iOS and Android

Platforms supported:  Desktop, Server and Mobile

Example:

   tsNetLibUrlReuseConnection false

Parameters:

  • pEnable: Set to either true or false. The default value is true.

Description:

By default tsNet will not disconnect from a server after making a network request to enable future requests to re-use the same connection. Set this to false to ensure that tsNet always opens a new connection to the server.

 

Function:  tsNetPost

 

Send an asynchronous POST request to a server.

tsNetPost(<pConnectionID>, <pURL>, <pHeaders>, <pPostData>, <pCallback>, [<pSettings>])

 

Operating Systems supported: Mac OS X, Windows, Linux, iOS and Android

Platforms supported:  Desktop, Server and Mobile

Example 1:

   local tHeaders, tResult, tPostData
   put “recordId=1&recordType=plain” into tPostData
   put tsNetPost(“1”, “http://www.example.com/post.php”, tHeaders, \
      tPostData, “transferComplete”) into tResult

Example 2:

   on transferComplete pID, pResult, pBytes, pCurlCode
      local tData, tHeaders
      if pCurlCode is not 0 then
         answer tsNetRetrError(pID)
      end if
      put tsNetRetrData(pID, tError) into tData
      tsNetCloseConn pID
      answer “Server data returned:” & tData
   end transferComplete

Parameters:

  • pConnectionID: A arbitrary user-defined label for the connection that is used when retrieving any details of the transfer.
  • pURL: The URL formatted as ‘scheme://host:port/path’ and URL-encoded as outlined in [RFC 3986](http://www.ietf.org/rfc/rfc3986.txt). The following schemes are supported: ‘tftp’, ‘ftp’, ‘ftps’, ‘http’, ‘https’ and ‘sftp’. For SFTP connections (Business Edition only), the path is not relative to the user’s home directory, but must be the full system path.
  • pHeaders: For HTTP(s) connections, the headers to be sent to the server. For all other protocols, leave this blank.
  • pPostData: The data to be “posted” to the server.
  • pCallback: Specify a callback message to be sent to the current object when the transfer is complete.
  • pSettings: An array of additional settings that control how the transfer is initiated.

Returns:

The tsNetPost function returns empty on success. On error, the return value will be a string containing the error starting with
“tsneterr:”.

Description:

This function sends a callback message on completion. Use tsNetRetrData to access the returned data. To save memory, it is recommended to call tsNetCloseConn when the connection is no longer needed.

The callback message will be sent with four parameters: the connection identifier, the status code sent back by the server, the number of bytes transferred and the cURL result code.

The cURL result code parameter in the callback message will be 0 for successful transfers. For any errors, further information can be
retrieved by calling the tsNetRetrError function.

The settings array can consist of the following elements (not all of the settings make sense for every possible transfer type): 

"byte_range": (Introduced in tsNet version 1.4.0) Specify the range of data to be downloaded. This can be in the format of “X-Y”, “X-“, “-Y” or “X-Y,N-M” where X, Y, N and M and byte indexes. Some HTTP servers may ignore this request.

"cookie_file": (Introduced in tsNet version 1.4.0) Specify a filename to load cookies from. If this setting is present, the internal cookie engine will be enabled and the cookies stored in the file loaded into the engine.

"cookies": (Introduced in tsNet version 1.4.0) The contents of this setting will be used to set a cookie in a HTTP request. It should be in the format of COOKIE_NAME=COOKIE_CONTENTS. Specify multiple cookies by separating them with a semi-colon. This setting does not enable the internal cookie engine of tsNet.

"cookie_jar": (Introduced in tsNet version 1.4.0) Specify a filename to write all known cookies to. If this setting is present, the internal cookie engine of tsNet will be enabled. Note that this file will only be written to at unspecified times. Use the “cookie_list” setting below to force the file to be updated.

"cookie_list": (Introduced in tsNet version 1.4.0) Set this to a list of cookies (one per line) in Netscape / Mozilla format or regular HTTP (Set-Cookie:) style format to add to the internal cookie engine. There are also several strings that when passed to this setting will perform additional actions. Passing in the string “ALL” will erase all cookies held in memory. “SESS” will erase all session cookies in memory. “FLUSH” will write all cookies stored in memory to the file specified by the “cookie_jar” setting. “RELOAD” will reload all cookies from file specified by “cookie_file”.

"disable_eprt": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from using the EPRT command when performing active FTP transfers.

"disable_epsv": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from using the EPSV command when performing passive FTP transfers.

"dont_modify_path": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from squashing “/../” and “/./” components from the URL path. RFC 3986 specifies that these should be removed.

“enable_tcp_keepalive”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to send TCP keepalive probes.

“expect100_timeout”: (Introduced in tsNet version 1.4.0) Specify the number of milliseconds to wait for a response with a HTTP 100 (Continue) or HTTP 417 (Expectation Failed) status after setting a HTTP request containing an Expect: 100-continue header. The default is 1000ms.

"fail_on_http_error": Set to true to specify that HTTP status codes greater than 400 should be considered an error.

"force_basic_auth": (Introduced in tsNet version 1.3.1) Set to true to force HTTP basic authentication rather than allow tsNet to detect what authentication methods are supported by the server.

"force_digest_auth": (Introduced in tsNet version 1.3.5) Set to true to force HTTP digest authentication rather than allow tsNet to detect what authentication methods are supported by the server.

“ftp_filemethod”: (Introduced in tsNet version 1.4.0) Set this to “nocwd” or “singlecwd” to change the method used by FTP to reach a particular file. Using “nocwd” will ensure all FTP commands use the full path to the file on the server. Using “singlecwd” will make tsNet issue a single CWD command to change to the directory that the file resides in before performing any other action on the file. The default is to issue a CWD command for each path part in the URL prior to performing any other action on the file in accordance with RFC 1738.

“ftp_ssl_ccc”: (Introduced in tsNet version 1.4.0) Set this to “passive” or “active” to disable the SSL/TLS encryption after authenticating with the FTP server. All further communication on the command channel with the FTP server will be unencrypted. Use “passive” to only disable the encryption after the server requests it. Setting this to “active” will initiate the encryption shutdown.

“ftp_user_alt”: (Introduced in tsNet version 1.4.0) Specify an alternate string to use for authentication if the standard FTP username and password negotiation fails.

“if_mod_since”: (Introduced in tsNet version 1.4.0) If the last modified time (in seconds since 1 Jan 1970) of the file is later than this, then download the file.

“if_unmod_since”: (Introduced in tsNet version 1.4.0) If the last modified time (in seconds since 1 Jan 1970) of the file is earlier than this, then download the file.

“ignore_content_length”: (Introduced in tsNet version 1.4.0) Set this option to true to ignore the content length specified in HTTP or FTP transfers. tsNet will complete the download when the server ends the connection.

“interface”: (Introduced in tsNet version 1.4.0) Specify the interface, IP address or host name to be used for the outgoing connection.

“junk_session_cookies”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to ignore all cookies loaded via the “cookie_file” setting that are session cookies.

“keepalive_idle”: (Introduced in tsNet version 1.4.0) When “enable_tcp_keepalive” is set to true, use this setting to specify the number of second to wait while the connection is idle before sending keepalive probes. The default is 60 seconds.

“keepalive_interval”: (Introduced in tsNet version 1.4.0) When “enable_tcp_keepalive” is set to true, use this setting to specify the number of seconds to wait between sending keepalive probes. The default is 60 seconds.

“local_port_range”: (Introduced in tsNet version 1.4.0) Set the number of consecutive ports above the port specified by the “local_port_start” setting to try when finding an available port for a connection.

“local_port_start”: (Introduced in tsNet version 1.4.0) Set the local port number of the socket to be used for the connection. It is recommended to also set “local_port_range” if you use this setting.

“max_file_size”: (Introduced in tsNet version 1.4.0) Specify the maximum size of a file to download. If the file exceeds this value, the transfer will not start. This option has no affect is the file size is not known prior to the download.

“max_recv_speed”: (Introduced in tsNet version 1.4.0) This option specifies the number of bytes per second to limit a download transfer to. Setting this to 0 disables any limiting.

“max_send_speed”: (Introduced in tsNet version 1.4.0) This option specifies the number of bytes per second to limit an upload transfer to. Setting this to 0 disables any limiting.

"no_reuse": Set to true to specify that the connection to the server should be disconnected and not left open for any future connections.

"no_transfer": Set to true to connect to the server but not perform any transfer.

"password": Set to a string containing the password to be used in any authentication requests from the server.

"post_commands": (Business Edition only) Set to a list of raw FTP/SFTP commands (one per line) that should be executed on the server directly after any transfer.

“post_on_301”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 301 response.

“post_on_302”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 302 response.

“post_on_303”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 303 response.

"pre_commands": (Business Edition only) Set to a list of raw FTP/SFTP commands (one per line) that should be executed on the server prior to any transfer.

“proxy_auth_basic”: (Introduced in tsNet version 1.4.0) Set this option to true to force tsNet to use basic authentication when authenticating with a proxy server.

“proxy_auth_digest”: (Introduced in tsNet version 1.4.0) Set this option to true to force tsNet to use digest authentication when authenticating with a proxy server.

"proxy_headers": Set to a list of headers (one per line) that should be sent to any proxy server that is being used.

“proxy_http_10”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to use HTTP/1.0 for any CONNECT tunnelling.

“referer”: (Introduced in tsNet version 1.4.0) The contents of this setting will be used as the HTTP Referer: header sent as part of a HTTP request.

“resolve_hosts”: (Introduced in tsNet version 1.4.0) Specify a list (one per line) of host to IP addresses to use when resolving host name for a request. Each line must be in the format of “HOSTNAME:PORT:ADDRESS”.

“resume_from”: (Introduced in tsNet version 1.4.0) Specify the number of bytes at which you want a transfer to start downloading or uploading.

"save_sent_headers": Set to true to specify that external should store a copy of all the headers that it sends to the server. This must be set to true to use the tsNetRetrSentHeaders function.

“skip_pasv_ip”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to ignore the IP address from the server’s 227 response message. tsNet will connect the data connection via the same IP address it used to set up the control connection.

“ssl_ciphers”: (Introduced in tsNet version 1.4.0) Use this setting to specify a list of SSL ciphers (separated by colons) to be used when negotiating SSL connections.

“ssl_client_cert”: (Introduced in tsNet version 1.4.1) Specify the filename of a client SSL certificate to use for authentication to the server.

“ssl_client_cert_type”: (Introduced in tsNet version 1.4.1) Set to the format of the client SSL certificate. Supported formats are “PEM”, “DER” and “P12”.

“ssl_client_key”: (Introduced in tsNet version 1.4.1) Specify the filename of a SSL private key file that matches the client SSL certificate.

“ssl_client_key_pass”: (Introduced in tsNet version 1.4.1) Set to the password for the SSL private key.

“ssl_client_key_type”: (Introduced in tsNet version 1.4.1) Set to the format of the SSL private key. Supported formats are “PEM” and “DER”.

“ssl_proxy_client_cert”: (Introduced in tsNet version 1.4.1) Specify the filename of a proxy client SSL certificate to use for authentication to the HTTP proxy.

“ssl_proxy_client_cert_type”: (Introduced in tsNet version 1.4.1) Set to the format of the proxy client SSL certificate. Supported formats are “PEM”, “DER” and “P12”.

“ssl_proxy_client_key”: (Introduced in tsNet version 1.4.1) Specify the filename of a SSL private key file that matches the proxy client SSL certificate.

“ssl_proxy_client_key_pass”: (Introduced in tsNet version 1.4.1) Set to the password for the SSL private key.

“ssl_proxy_client_key_type”: (Introduced in tsNet version 1.4.1) Set to the format of the SSL private key. Supported formats are “PEM” and “DER”.

"ssh_host_public_key": Set to the 128 bit MD5 checksum of the remote host's public key. The connection will be rejected unless they match.

"ssh_passphrase": (Business Edition only) Set to the passphrase for any included private key.

"ssh_private_key": (Business Edition only) Set to the private key file (including full system path) to be used in SFTP transfers.

“trace”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to include all inbound and outbound data when using tsNetSetDebugCallback() rather than just header and informational data. When this option is set, a third parameter will be posted to the debug callback function specifying the type of data that is being passed to the callback function.

“transfer_encoding”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to request the response be sent in a compressed Transfer-Encoding (if the server supports it) that will be automatically uncompressed by tsNet when it is received.

“trust_location_auth”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to continue to send authentication details when following any HTTP redirects.

“try_ssl”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to try to connect via SSL. If the connection fails to establish via SSL, connect without using SSL.

“tunnel_http_proxy”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to tunnel all operations (all protocols) through the HTTP proxy.

“use_ascii_transfer”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to use ASCII mode for FTP transfers.

“use_pret”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to send a PRET command before sending PASV/EPSV when performing passive FTP transfers.

"use_ssl": Set to true to connect using Transport Layer Security (TLS) for SMTPS and FTPS (explicit) connections.

"username": Set to a string containing the username to be used in any authentication requests from the server.

“use_ssl_control”: (Introduced in tsNet version 1.4.0) Set this option to true to ensure all control communication is encrypted.

“user_agent”: (Introduced in tsNet version 1.4.0) The contents of this setting will be used as the HTTP User-Agent: header sent as part of a HTTP request.

Function:  tsNetPostSync

 

Send a synchronous POST request to a server.

tsNetPostSync(<pURL>, <xHeaders>, <pPostData>, <rOutHeaders>, <rResult>, <rBytes>, [<pSettings>])

 

Operating Systems supported: Mac OS X, Windows, Linux, iOS and Android

Platforms supported:  Desktop, Server and Mobile

Example:

   local tHeaders, tResult, tBytes, tRecvHeaders, tPostData, tData
   local tSettings
   put true into tSettings[“save_sent_headers”]
   put “recordId=1&recordType=plain” into tPostData
   put tsNetPostSync(“http://www.livecode.com”, tHeaders, tPostData, \
      tRecvHeaders, tResult, tBytes, tSettings) into tData

Parameters:

  • pURL: The URL formatted as ‘scheme://host:port/path’ and URL-encoded as outlined in [RFC 3986](http://www.ietf.org/rfc/rfc3986.txt). The following schemes are supported: ‘tftp’, ‘ftp’, ‘ftps’, ‘http’, ‘https’ and ‘sftp’. For SFTP connections (Business Edition only), the path is not relative to the user’s home directory, but must be the full system path.
  • xHeaders: For HTTP(s) connections, the headers to be sent to the server. For all other protocols, leave this blank. The contents of this variable will be replaced when the function returns with the headers that were sent to the server if the “save_sent_headers” array setting is specified below.pPostData: The data to be “posted” to the server.
  • rOutHeaders: This variable will contain the headers that were returned from the server on completion.
  • rResult: This variable will contain the status code sent by the server to the last command that was issued during the transfer. For SFTP connections, this will always be 0. On error, the return value will be a string containing the error starting with “tsneterr:”.
  • rBytes: This variable will contain the number of bytes that were downloaded during the connection.
  • pSettings: An array of additional settings that control how the transfer is initiated.

Returns:

The tsNetPostSync function returns the data retrieved from the server on success.

Description:

The settings array can consist of the following elements (not all of the settings make sense for every possible transfer type): 

"byte_range": (Introduced in tsNet version 1.4.0) Specify the range of data to be downloaded. This can be in the format of “X-Y”, “X-“, “-Y” or “X-Y,N-M” where X, Y, N and M and byte indexes. Some HTTP servers may ignore this request.

"cookie_file": (Introduced in tsNet version 1.4.0) Specify a filename to load cookies from. If this setting is present, the internal cookie engine will be enabled and the cookies stored in the file loaded into the engine.

"cookies": (Introduced in tsNet version 1.4.0) The contents of this setting will be used to set a cookie in a HTTP request. It should be in the format of COOKIE_NAME=COOKIE_CONTENTS. Specify multiple cookies by separating them with a semi-colon. This setting does not enable the internal cookie engine of tsNet.

"cookie_jar": (Introduced in tsNet version 1.4.0) Specify a filename to write all known cookies to. If this setting is present, the internal cookie engine of tsNet will be enabled. Note that this file will only be written to at unspecified times. Use the “cookie_list” setting below to force the file to be updated.

"cookie_list": (Introduced in tsNet version 1.4.0) Set this to a list of cookies (one per line) in Netscape / Mozilla format or regular HTTP (Set-Cookie:) style format to add to the internal cookie engine. There are also several strings that when passed to this setting will perform additional actions. Passing in the string “ALL” will erase all cookies held in memory. “SESS” will erase all session cookies in memory. “FLUSH” will write all cookies stored in memory to the file specified by the “cookie_jar” setting. “RELOAD” will reload all cookies from file specified by “cookie_file”.

"disable_eprt": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from using the EPRT command when performing active FTP transfers.

"disable_epsv": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from using the EPSV command when performing passive FTP transfers.

"dont_modify_path": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from squashing “/../” and “/./” components from the URL path. RFC 3986 specifies that these should be removed.

“enable_tcp_keepalive”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to send TCP keepalive probes.

“expect100_timeout”: (Introduced in tsNet version 1.4.0) Specify the number of milliseconds to wait for a response with a HTTP 100 (Continue) or HTTP 417 (Expectation Failed) status after setting a HTTP request containing an Expect: 100-continue header. The default is 1000ms.

"fail_on_http_error": Set to true to specify that HTTP status codes greater than 400 should be considered an error.

"force_basic_auth": (Introduced in tsNet version 1.3.1) Set to true to force HTTP basic authentication rather than allow tsNet to detect what authentication methods are supported by the server.

"force_digest_auth": (Introduced in tsNet version 1.3.5) Set to true to force HTTP digest authentication rather than allow tsNet to detect what authentication methods are supported by the server.

“ftp_filemethod”: (Introduced in tsNet version 1.4.0) Set this to “nocwd” or “singlecwd” to change the method used by FTP to reach a particular file. Using “nocwd” will ensure all FTP commands use the full path to the file on the server. Using “singlecwd” will make tsNet issue a single CWD command to change to the directory that the file resides in before performing any other action on the file. The default is to issue a CWD command for each path part in the URL prior to performing any other action on the file in accordance with RFC 1738.

“ftp_ssl_ccc”: (Introduced in tsNet version 1.4.0) Set this to “passive” or “active” to disable the SSL/TLS encryption after authenticating with the FTP server. All further communication on the command channel with the FTP server will be unencrypted. Use “passive” to only disable the encryption after the server requests it. Setting this to “active” will initiate the encryption shutdown.

“ftp_user_alt”: (Introduced in tsNet version 1.4.0) Specify an alternate string to use for authentication if the standard FTP username and password negotiation fails.

“if_mod_since”: (Introduced in tsNet version 1.4.0) If the last modified time (in seconds since 1 Jan 1970) of the file is later than this, then download the file.

“if_unmod_since”: (Introduced in tsNet version 1.4.0) If the last modified time (in seconds since 1 Jan 1970) of the file is earlier than this, then download the file.

“ignore_content_length”: (Introduced in tsNet version 1.4.0) Set this option to true to ignore the content length specified in HTTP or FTP transfers. tsNet will complete the download when the server ends the connection.

“interface”: (Introduced in tsNet version 1.4.0) Specify the interface, IP address or host name to be used for the outgoing connection.

“junk_session_cookies”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to ignore all cookies loaded via the “cookie_file” setting that are session cookies.

“keepalive_idle”: (Introduced in tsNet version 1.4.0) When “enable_tcp_keepalive” is set to true, use this setting to specify the number of second to wait while the connection is idle before sending keepalive probes. The default is 60 seconds.

“keepalive_interval”: (Introduced in tsNet version 1.4.0) When “enable_tcp_keepalive” is set to true, use this setting to specify the number of seconds to wait between sending keepalive probes. The default is 60 seconds.

“local_port_range”: (Introduced in tsNet version 1.4.0) Set the number of consecutive ports above the port specified by the “local_port_start” setting to try when finding an available port for a connection.

“local_port_start”: (Introduced in tsNet version 1.4.0) Set the local port number of the socket to be used for the connection. It is recommended to also set “local_port_range” if you use this setting.

“max_file_size”: (Introduced in tsNet version 1.4.0) Specify the maximum size of a file to download. If the file exceeds this value, the transfer will not start. This option has no affect is the file size is not known prior to the download.

“max_recv_speed”: (Introduced in tsNet version 1.4.0) This option specifies the number of bytes per second to limit a download transfer to. Setting this to 0 disables any limiting.

“max_send_speed”: (Introduced in tsNet version 1.4.0) This option specifies the number of bytes per second to limit an upload transfer to. Setting this to 0 disables any limiting.

"no_reuse": Set to true to specify that the connection to the server should be disconnected and not left open for any future connections.

"no_transfer": Set to true to connect to the server but not perform any transfer.

"password": Set to a string containing the password to be used in any authentication requests from the server.

"post_commands": (Business Edition only) Set to a list of raw FTP/SFTP commands (one per line) that should be executed on the server directly after any transfer.

“post_on_301”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 301 response.

“post_on_302”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 302 response.

“post_on_303”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 303 response.

"pre_commands": (Business Edition only) Set to a list of raw FTP/SFTP commands (one per line) that should be executed on the server prior to any transfer.

“proxy_auth_basic”: (Introduced in tsNet version 1.4.0) Set this option to true to force tsNet to use basic authentication when authenticating with a proxy server.

“proxy_auth_digest”: (Introduced in tsNet version 1.4.0) Set this option to true to force tsNet to use digest authentication when authenticating with a proxy server.

"proxy_headers": Set to a list of headers (one per line) that should be sent to any proxy server that is being used.

“proxy_http_10”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to use HTTP/1.0 for any CONNECT tunnelling.

“referer”: (Introduced in tsNet version 1.4.0) The contents of this setting will be used as the HTTP Referer: header sent as part of a HTTP request.

“resolve_hosts”: (Introduced in tsNet version 1.4.0) Specify a list (one per line) of host to IP addresses to use when resolving host name for a request. Each line must be in the format of “HOSTNAME:PORT:ADDRESS”.

“resume_from”: (Introduced in tsNet version 1.4.0) Specify the number of bytes at which you want a transfer to start downloading or uploading.

"save_sent_headers": Set to true to specify that external should store a copy of all the headers that it sends to the server. This must be set to true to use the tsNetRetrSentHeaders function.

“skip_pasv_ip”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to ignore the IP address from the server’s 227 response message. tsNet will connect the data connection via the same IP address it used to set up the control connection.

“ssl_ciphers”: (Introduced in tsNet version 1.4.0) Use this setting to specify a list of SSL ciphers (separated by colons) to be used when negotiating SSL connections.

“ssl_client_cert”: (Introduced in tsNet version 1.4.1) Specify the filename of a client SSL certificate to use for authentication to the server.

“ssl_client_cert_type”: (Introduced in tsNet version 1.4.1) Set to the format of the client SSL certificate. Supported formats are “PEM”, “DER” and “P12”.

“ssl_client_key”: (Introduced in tsNet version 1.4.1) Specify the filename of a SSL private key file that matches the client SSL certificate.

“ssl_client_key_pass”: (Introduced in tsNet version 1.4.1) Set to the password for the SSL private key.

“ssl_client_key_type”: (Introduced in tsNet version 1.4.1) Set to the format of the SSL private key. Supported formats are “PEM” and “DER”.

“ssl_proxy_client_cert”: (Introduced in tsNet version 1.4.1) Specify the filename of a proxy client SSL certificate to use for authentication to the HTTP proxy.

“ssl_proxy_client_cert_type”: (Introduced in tsNet version 1.4.1) Set to the format of the proxy client SSL certificate. Supported formats are “PEM”, “DER” and “P12”.

“ssl_proxy_client_key”: (Introduced in tsNet version 1.4.1) Specify the filename of a SSL private key file that matches the proxy client SSL certificate.

“ssl_proxy_client_key_pass”: (Introduced in tsNet version 1.4.1) Set to the password for the SSL private key.

“ssl_proxy_client_key_type”: (Introduced in tsNet version 1.4.1) Set to the format of the SSL private key. Supported formats are “PEM” and “DER”.

"ssh_host_public_key": Set to the 128 bit MD5 checksum of the remote host's public key. The connection will be rejected unless they match.

"ssh_passphrase": (Business Edition only) Set to the passphrase for any included private key.

"ssh_private_key": (Business Edition only) Set to the private key file (including full system path) to be used in SFTP transfers.

“trace”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to include all inbound and outbound data when using tsNetSetDebugCallback() rather than just header and informational data. When this option is set, a third parameter will be posted to the debug callback function specifying the type of data that is being passed to the callback function.

“transfer_encoding”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to request the response be sent in a compressed Transfer-Encoding (if the server supports it) that will be automatically uncompressed by tsNet when it is received.

“trust_location_auth”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to continue to send authentication details when following any HTTP redirects.

“try_ssl”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to try to connect via SSL. If the connection fails to establish via SSL, connect without using SSL.

“tunnel_http_proxy”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to tunnel all operations (all protocols) through the HTTP proxy.

“use_ascii_transfer”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to use ASCII mode for FTP transfers.

“use_pret”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to send a PRET command before sending PASV/EPSV when performing passive FTP transfers.

"use_ssl": Set to true to connect using Transport Layer Security (TLS) for SMTPS and FTPS (explicit) connections.

"username": Set to a string containing the username to be used in any authentication requests from the server.

“use_ssl_control”: (Introduced in tsNet version 1.4.0) Set this option to true to ensure all control communication is encrypted.

“user_agent”: (Introduced in tsNet version 1.4.0) The contents of this setting will be used as the HTTP User-Agent: header sent as part of a HTTP request.

Command:  tsNetRedirEnable

 

Enable or disable automatic following of HTTP redirects.

tsNetRedirEnable <pEnable>

 

Operating Systems supported: Mac OS X, Windows, Linux, iOS and Android

Platforms supported:  Desktop, Server and Mobile

Example:

   tsNetRedirEnable false

Parameters:

  • pEnable: Set to either true or false. The default value is true.

 

Function:  tsNetRetrData

 

Retrieve any returned data from a transfer.

tsNetRetrData(<pConnectionID>, <rError>)

 

Operating Systems supported: Mac OS X, Windows, Linux, iOS and Android

Platforms supported:  Desktop, Server and Mobile

Example:

   local tError, tData
   put tsNetRetrData(“myConnID”, tError) into tData

Parameters:

  • pConnectionID: The identifier of the transfer to retrieve.
  • rError: If the connection identifier is invalid or any other error occurs in retrieving the data, an error will be returned that starts
    with “tsneterr:”. Otherwise this will be set to empty.

Returns:

The tsNetRetrData returns the data retrieved from the server during the transfer.

 

Function:  tsNetRetrError

 

Returns the error message of a failed transfer.

tsNetRetrError(<pConnectionID>)

 

Operating Systems supported: Mac OS X, Windows, Linux, iOS and Android

Platforms supported:  Desktop, Server and Mobile

Example:

   local tError
   put tsNetRetrError(“myConnID”) into tError

Parameters:

  • pConnectionID: The identifier of the transfer to retrieve.

Returns:

The tsNetRetrError returns a string containing the error message explaining why the transfer failed. If the connection identifier is invalid, an error will be returned that starts with “tsneterr:”.

 

Function:  tsNetRetrHeaders

 

Retrieve any returned headers from a transfer.

tsNetRetrHeaders(<pConnectionID>, <rError>)

 

Operating Systems supported: Mac OS X, Windows, Linux, iOS and Android

Platforms supported:  Desktop, Server and Mobile

Example:

   local tError, tHeaders
   put tsNetRetrHeaders(“myConnID”, tError) into tHeaders

Parameters:

  • pConnectionID: The identifier of the transfer to retrieve.
  • rError: If the connection identifier is invalid or any other error occurs in retrieving the data, an error will be returned that starts
    with “tsneterr:”. Otherwise this will be set to empty.

Returns:

The tsNetRetrHeaders returns the headers retrieved from the server during the transfer.

 

Function:  tsNetRetrSentHeaders

 

Retrieve any headers sent to the server during a transfer.

tsNetRetrSentHeaders(<pConnectionID>, <rError>)

 

Operating Systems supported: Mac OS X, Windows, Linux, iOS and Android

Platforms supported:  Desktop, Server and Mobile

Example:

   local tError, tSentHeaders
   put tsNetRetrSentHeaders(“myConnID”, tError) into tSentHeaders

Parameters:

  • pConnectionID: The identifier of the transfer to retrieve.
  • rError: If the connection identifier is invalid or any other error occurs in retrieving the data, an error will be returned that starts with “tsneterr:”. Otherwise this will be set to empty.

Returns:

The tsNetRetrSentHeaders returns the headers that were sent to the server during the transfer.

 

Command:  tsNetSetDebugCallback

 

Sends a message to the given callback with verbose debug information during network transfers.

tsNetSetDebugCallback <pCallback>

 

Operating Systems supported: Mac OS X, Windows, Linux, iOS and Android

Platforms supported:  Desktop, Server and Mobile

Example 1:

   tsNetSetDebugCallback “debugCallback”

Example 2:

   tsNetSetDebugCallback “”

 Parameters:

  • pCallback: Specify a callback message to be sent to the current card for network transfers. Set this to empty to disable debug callback messages. The message will be sent with two parameters: the identifier for the transfer and the debug message.

 

Command:  tsNetSetDirNLST

 

Enable or disable “simple” directory listings over FTP and SFTP.

tsNetSetDirNLST <pEnable>

 

Operating Systems supported: Mac OS X, Windows, Linux, iOS and Android

Platforms supported:  Desktop, Server and Mobile

Example:

   tsNetSetDirNLST true

Parameters:

  • pEnable: Set to either true or false. The default value is false.

 

Command:  tsNetSetFTPPort

 

Enable or disable the use of active transfers for FTP.

tsNetSetFTPPort <pPort>

 

Operating Systems supported: Mac OS X, Windows, Linux, iOS and Android

Platforms supported:  Desktop, Server and Mobile

Example 1:

   tsNetSetFTPPort “-“

Example 2:

   tsNetSetFTPPort “192.168.0.1”

Example 3:

   tsNetSetFTPPort “”

Parameters:

  • pPort: This can be set to an IP address or hostname for FTP to use when specifying the local address for the FTP server to connect to. To specific a port number (or range of ports separated by a ‘-‘) to be used, append a ‘:’ after the address and put the port number(s) at the end. This can also be simply set to ‘-‘ to let tsNet guess the IP address and port(s) to use. If this parameter is empty, all FTP transfers will use passive mode, otherwise active mode is used.

 

Command:  tsNetSetProxy

 

Enable or disable the use of a proxy for networking transfers.

tsNetSetProxy <pProxyURL>, <pNoProxy>, <pUsername>, <pPassword>

 

Operating Systems supported: Mac OS X, Windows, Linux, iOS and Android

Platforms supported:  Desktop, Server and Mobile

Example 1:

   tsNetSetProxy “http://proxy.mydomain.com:1080” \
      , “local.mydomain.com,intranet.mydomain.com” \
      , “proxyusername”, “proxypassword”

 Example 2:

   tsNetSetProxy “”

Parameters:

  • pProxyURL: The hostname or IP address of the proxy server to be used for all networking connections. Can be prefixed with `socks4://`, `socks4a://`, `socks5://`, `socks5h://` or `http://` to specify the type of proxy to use. If there is no protocol specified, HTTP will be assumed. The use of `socks5h://` indicates that the proxy will do the resolving of hostnames. Append :<port> to specify the port number to be used, otherwise port 1080 will be assumed.
  • pNoProxy: Can be a comma separated list of host names that should bypass the proxy. Host names can include a port number after a ‘:’.
  • pUsername: The username to authenticate with the proxy server. Set to empty to disable authentication.
  • pPassword: The password to authenticate with the proxy server. Set to empty to disable authentication.

Description:

Note that setting a proxy will affect all protocols, not just HTTP.

 

Command:  tsNetSetStatusCallback

 

Sends a message to the given callback when status updates are available for network transfers.

tsNetSetStatusCallback <pCallback>

 

Operating Systems supported: Mac OS X, Windows, Linux, iOS and Android

Platforms supported:  Desktop, Server and Mobile

Example 1:

   tsNetSetStatusCallback “progressUpdate”

 Example 2:

   tsNetSetStatusCallback “”

Parameters:

  • pCallback: Specify a callback message to be sent to the current card for network transfers. Set this to empty to disable status callback messages.

Description:

The message will be sent with five parameters: the identifier for the transfer, the status of the transfer, the number of bytes that have
been downloaded, the total number of bytes to be downloaded, the number of bytes that have been uploaded and the total number of bytes to be uploaded. The total bytes may be 0 if the external is unable to determine this figure.

The status of the transfer can be any of: cancelled, timeout, error, uploaded, downloaded, requested, contacted, uploading or loading.

 

Command:  tsNetSetTimeouts

(Introduced in tsNet version 1.2.10)

Adjust the timeout values used by tsNet external.

tsNetSetTimeouts <pDnsCacheTimeout>, <pRequestTimeoutMS>, <pConnectTimeoutMS>, <pAcceptTimeoutMS>, <pLowSpeedTime>, <pLowSpeedLimit>

 

Operating Systems supported: Mac OS X, Windows, Linux, iOS and Android

Platforms supported:  Desktop, Server and Mobile

Example:

   tsNetSetTimeouts 30, 0, 300000, 60000, 30, 1000

Parameters:

  • pDnsCacheTimeout: tsNet caches DNS responses for a default time of 60 seconds. The value for this parameter (in seconds) will override this default.
  • pRequestTimeoutMS: By default, tsNet does not limit the length of time a request can take. This parameter will set a maximum number of milliseconds the entire request can take. Set this to 0 to not enforce a limit.
  • pConnectTimeoutMS: This parameter sets the length of time in milliseconds that the external will wait for the initial connection to the server to be established. The default is 300000 milliseconds.
  • pAcceptTimeoutMS: For active FTP connections, this parameter sets the length of time in milliseconds that the external will wait for the FTP server to connect back to tsNet when establishing the data stream. The default is 60000 milliseconds.
  • pLowSpeedTime: This parameter defines the time period in seconds that is used to calculate whether or not the transfer has fallen below the low speed limit set by pLowSpeedLimit. Set this to 0 to disable this feature.
  • pLowSpeedLimit: If the speed of transfer falls below this number of bytes per second (over the time period specified by pLowSpeedLimit) then the connection will be aborted. Set this to 0 to disable this feature.

 

Command:  tsNetSSLNoRevoke

(Introduced in tsNet version 1.2.10)

Enable or disable SSL certificate revocation checks.

tsNetSSLNoRevoke <pEnable>

 

Operating Systems supported: Windows

Platforms supported:  Desktop, Server and Mobile

Example:

   tsNetSSLNoRevoke true

Parameters:

  • pEnable: Set to either true or false. The default value is false.

 

Command:  tsNetSuppressConnectHeaders

(Introduced in tsNet version 1.2.10)

Prevent proxy CONNECT responses from being included in the returned HTTP headers

tsNetSuppressConnectHeaders <pEnable>

 

Operating Systems supported: Mac OS X, Windows, Linux, iOS and Android

Platforms supported:  Desktop, Server and Mobile

Example:

    tsNetSuppressConnectHeaders true

Parameters:

  • pEnable: Set to either true or false. The default value is false.

 

Command:  tsNetVerifySSLPeer

 

Enable or disable SSL peer certificate verification.

tsNetVerifySSLPeer <pEnable>

 

Operating Systems supported: Mac OS X, Windows, Linux, iOS and Android

Platforms supported:  Desktop, Server and Mobile

Example:

   tsNetVerifySSLPeer false

Parameters:

  • pEnable: Set to either true or false. The default value is true.

Description:

By default tsNet will not disconnect from a server after making a network request to enable future requests to re-use the same connection. Set this to false to ensure that tsNet always opens a new connection to the server.

 

Function:  tsNetVersion

 

Returns the version of the tsNet external.

tsNetVersion()

 

Operating Systems supported: Mac OS X, Windows, Linux, iOS and Android

Platforms supported:  Desktop, Server and Mobile

Example:

   put tsNetVersion() into tVersion

Returns:

The tsNetVersion command returns the version of the tsNet external in use.

 

Function:  tsNetSendCmd

 

Send an asynchronous command to a FTP or SFTP server.

tsNetSendCmd(<pConnectionID>, <pURL>, <pCommand>, <pCallback>, [<pSettings>])

 

Operating Systems supported: Mac OS X, Windows, Linux, iOS and Android

Platforms supported:  Desktop, Server and Mobile

Example 1:

   local tResult, tCmds
   put “CWD /upload_dir” into tCmds
   put cr & “DELE backup.dat” after tCmds
   put tsNetSendCmd(“1”, “ftp://user:pass@ftp.example.com”, tCmds, \
      “transferComplete”) into tResult

Example 2:

   local tResult, tCmds
   put “mkdir /path/to/upload_dir” into tCmds
   put tsNetSendCmd(“1”, “sftp://user:pass@sftp.example.com”, tCmds, \
      “transferComplete”) into tResult

Example 3:

   on transferComplete pID, pResult, pBytes, pCurlCode
      local tData, tHeaders
      if pCurlCode is not 0 then
         answer tsNetRetrError(pID)
      end if
      put tsNetRetrData(pID, tError) into tData
      tsNetCloseConn pID
      answer “Server response:” & tData
   end transferComplete

Parameters:

  • pConnectionID: A arbitrary user-defined label for the connection that is used when retrieving any details of the transfer.
  • pURL: The URL formatted as ‘scheme://host:port/path’ and URL-encoded as outlined in [RFC 3986](http://www.ietf.org/rfc/rfc3986.txt). The following schemes are supported: ‘tftp’, ‘ftp’, ‘ftps’, ‘http’, ‘https’ and ‘sftp’. For SFTP connections (Business Edition only), the path is not relative to the user’s home directory, but must be the full system path.
  • pCommand: Set to a list of raw FTP/SFTP commands (one per line) that should be executed on the server. SFTP commands are only supported in the Business Edition of LiveCode.
  • pCallback: Specify a callback message to be sent to the current object when the transfer is complete.
  • pSettings: An array of additional settings that control how the transfer is initiated.

Returns:

The tsNetSendCmd function returns empty on success. On error, the return value will be a string containing the error starting with “tsneterr:”.

Description:

This function sends a callback message on completion. Use tsNetRetrData to access the returned data. To save memory, it is recommended to call tsNetCloseConn when the connection is no longer needed.

The callback message will be sent with four parameters: the connection identifier, the status code sent back by the server, the number of bytes transferred and the cURL result code.

The cURL result code parameter in the callback message will be 0 for successful transfers. For any errors, further information can be
retrieved by calling the tsNetRetrError function.

The settings array can consist of the following elements (not all of the settings make sense for every possible transfer type): 

"byte_range": (Introduced in tsNet version 1.4.0) Specify the range of data to be downloaded. This can be in the format of “X-Y”, “X-“, “-Y” or “X-Y,N-M” where X, Y, N and M and byte indexes. Some HTTP servers may ignore this request.

"cookie_file": (Introduced in tsNet version 1.4.0) Specify a filename to load cookies from. If this setting is present, the internal cookie engine will be enabled and the cookies stored in the file loaded into the engine.

"cookies": (Introduced in tsNet version 1.4.0) The contents of this setting will be used to set a cookie in a HTTP request. It should be in the format of COOKIE_NAME=COOKIE_CONTENTS. Specify multiple cookies by separating them with a semi-colon. This setting does not enable the internal cookie engine of tsNet.

"cookie_jar": (Introduced in tsNet version 1.4.0) Specify a filename to write all known cookies to. If this setting is present, the internal cookie engine of tsNet will be enabled. Note that this file will only be written to at unspecified times. Use the “cookie_list” setting below to force the file to be updated.

"cookie_list": (Introduced in tsNet version 1.4.0) Set this to a list of cookies (one per line) in Netscape / Mozilla format or regular HTTP (Set-Cookie:) style format to add to the internal cookie engine. There are also several strings that when passed to this setting will perform additional actions. Passing in the string “ALL” will erase all cookies held in memory. “SESS” will erase all session cookies in memory. “FLUSH” will write all cookies stored in memory to the file specified by the “cookie_jar” setting. “RELOAD” will reload all cookies from file specified by “cookie_file”.

"disable_eprt": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from using the EPRT command when performing active FTP transfers.

"disable_epsv": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from using the EPSV command when performing passive FTP transfers.

"dont_modify_path": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from squashing “/../” and “/./” components from the URL path. RFC 3986 specifies that these should be removed.

“enable_tcp_keepalive”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to send TCP keepalive probes.

“expect100_timeout”: (Introduced in tsNet version 1.4.0) Specify the number of milliseconds to wait for a response with a HTTP 100 (Continue) or HTTP 417 (Expectation Failed) status after setting a HTTP request containing an Expect: 100-continue header. The default is 1000ms.

"fail_on_http_error": Set to true to specify that HTTP status codes greater than 400 should be considered an error.

"force_basic_auth": (Introduced in tsNet version 1.3.1) Set to true to force HTTP basic authentication rather than allow tsNet to detect what authentication methods are supported by the server.

"force_digest_auth": (Introduced in tsNet version 1.3.5) Set to true to force HTTP digest authentication rather than allow tsNet to detect what authentication methods are supported by the server.

“ftp_filemethod”: (Introduced in tsNet version 1.4.0) Set this to “nocwd” or “singlecwd” to change the method used by FTP to reach a particular file. Using “nocwd” will ensure all FTP commands use the full path to the file on the server. Using “singlecwd” will make tsNet issue a single CWD command to change to the directory that the file resides in before performing any other action on the file. The default is to issue a CWD command for each path part in the URL prior to performing any other action on the file in accordance with RFC 1738.

“ftp_ssl_ccc”: (Introduced in tsNet version 1.4.0) Set this to “passive” or “active” to disable the SSL/TLS encryption after authenticating with the FTP server. All further communication on the command channel with the FTP server will be unencrypted. Use “passive” to only disable the encryption after the server requests it. Setting this to “active” will initiate the encryption shutdown.

“ftp_user_alt”: (Introduced in tsNet version 1.4.0) Specify an alternate string to use for authentication if the standard FTP username and password negotiation fails.

“if_mod_since”: (Introduced in tsNet version 1.4.0) If the last modified time (in seconds since 1 Jan 1970) of the file is later than this, then download the file.

“if_unmod_since”: (Introduced in tsNet version 1.4.0) If the last modified time (in seconds since 1 Jan 1970) of the file is earlier than this, then download the file.

“ignore_content_length”: (Introduced in tsNet version 1.4.0) Set this option to true to ignore the content length specified in HTTP or FTP transfers. tsNet will complete the download when the server ends the connection.

“interface”: (Introduced in tsNet version 1.4.0) Specify the interface, IP address or host name to be used for the outgoing connection.

“junk_session_cookies”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to ignore all cookies loaded via the “cookie_file” setting that are session cookies.

“keepalive_idle”: (Introduced in tsNet version 1.4.0) When “enable_tcp_keepalive” is set to true, use this setting to specify the number of second to wait while the connection is idle before sending keepalive probes. The default is 60 seconds.

“keepalive_interval”: (Introduced in tsNet version 1.4.0) When “enable_tcp_keepalive” is set to true, use this setting to specify the number of seconds to wait between sending keepalive probes. The default is 60 seconds.

“local_port_range”: (Introduced in tsNet version 1.4.0) Set the number of consecutive ports above the port specified by the “local_port_start” setting to try when finding an available port for a connection.

“local_port_start”: (Introduced in tsNet version 1.4.0) Set the local port number of the socket to be used for the connection. It is recommended to also set “local_port_range” if you use this setting.

“max_file_size”: (Introduced in tsNet version 1.4.0) Specify the maximum size of a file to download. If the file exceeds this value, the transfer will not start. This option has no affect is the file size is not known prior to the download.

“max_recv_speed”: (Introduced in tsNet version 1.4.0) This option specifies the number of bytes per second to limit a download transfer to. Setting this to 0 disables any limiting.

“max_send_speed”: (Introduced in tsNet version 1.4.0) This option specifies the number of bytes per second to limit an upload transfer to. Setting this to 0 disables any limiting.

"no_reuse": Set to true to specify that the connection to the server should be disconnected and not left open for any future connections.

"no_transfer": Set to true to connect to the server but not perform any transfer.

"password": Set to a string containing the password to be used in any authentication requests from the server.

"post_commands": (Business Edition only) Set to a list of raw FTP/SFTP commands (one per line) that should be executed on the server directly after any transfer.

“post_on_301”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 301 response.

“post_on_302”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 302 response.

“post_on_303”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 303 response.

"pre_commands": (Business Edition only) Set to a list of raw FTP/SFTP commands (one per line) that should be executed on the server prior to any transfer.

“proxy_auth_basic”: (Introduced in tsNet version 1.4.0) Set this option to true to force tsNet to use basic authentication when authenticating with a proxy server.

“proxy_auth_digest”: (Introduced in tsNet version 1.4.0) Set this option to true to force tsNet to use digest authentication when authenticating with a proxy server.

"proxy_headers": Set to a list of headers (one per line) that should be sent to any proxy server that is being used.

“proxy_http_10”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to use HTTP/1.0 for any CONNECT tunnelling.

“referer”: (Introduced in tsNet version 1.4.0) The contents of this setting will be used as the HTTP Referer: header sent as part of a HTTP request.

“resolve_hosts”: (Introduced in tsNet version 1.4.0) Specify a list (one per line) of host to IP addresses to use when resolving host name for a request. Each line must be in the format of “HOSTNAME:PORT:ADDRESS”.

“resume_from”: (Introduced in tsNet version 1.4.0) Specify the number of bytes at which you want a transfer to start downloading or uploading.

"save_sent_headers": Set to true to specify that external should store a copy of all the headers that it sends to the server. This must be set to true to use the tsNetRetrSentHeaders function.

“skip_pasv_ip”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to ignore the IP address from the server’s 227 response message. tsNet will connect the data connection via the same IP address it used to set up the control connection.

“ssl_ciphers”: (Introduced in tsNet version 1.4.0) Use this setting to specify a list of SSL ciphers (separated by colons) to be used when negotiating SSL connections.

“ssl_client_cert”: (Introduced in tsNet version 1.4.1) Specify the filename of a client SSL certificate to use for authentication to the server.

“ssl_client_cert_type”: (Introduced in tsNet version 1.4.1) Set to the format of the client SSL certificate. Supported formats are “PEM”, “DER” and “P12”.

“ssl_client_key”: (Introduced in tsNet version 1.4.1) Specify the filename of a SSL private key file that matches the client SSL certificate.

“ssl_client_key_pass”: (Introduced in tsNet version 1.4.1) Set to the password for the SSL private key.

“ssl_client_key_type”: (Introduced in tsNet version 1.4.1) Set to the format of the SSL private key. Supported formats are “PEM” and “DER”.

“ssl_proxy_client_cert”: (Introduced in tsNet version 1.4.1) Specify the filename of a proxy client SSL certificate to use for authentication to the HTTP proxy.

“ssl_proxy_client_cert_type”: (Introduced in tsNet version 1.4.1) Set to the format of the proxy client SSL certificate. Supported formats are “PEM”, “DER” and “P12”.

“ssl_proxy_client_key”: (Introduced in tsNet version 1.4.1) Specify the filename of a SSL private key file that matches the proxy client SSL certificate.

“ssl_proxy_client_key_pass”: (Introduced in tsNet version 1.4.1) Set to the password for the SSL private key.

“ssl_proxy_client_key_type”: (Introduced in tsNet version 1.4.1) Set to the format of the SSL private key. Supported formats are “PEM” and “DER”.

"ssh_host_public_key": Set to the 128 bit MD5 checksum of the remote host's public key. The connection will be rejected unless they match.

"ssh_passphrase": (Business Edition only) Set to the passphrase for any included private key.

"ssh_private_key": (Business Edition only) Set to the private key file (including full system path) to be used in SFTP transfers.

“trace”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to include all inbound and outbound data when using tsNetSetDebugCallback() rather than just header and informational data. When this option is set, a third parameter will be posted to the debug callback function specifying the type of data that is being passed to the callback function.

“transfer_encoding”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to request the response be sent in a compressed Transfer-Encoding (if the server supports it) that will be automatically uncompressed by tsNet when it is received.

“trust_location_auth”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to continue to send authentication details when following any HTTP redirects.

“try_ssl”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to try to connect via SSL. If the connection fails to establish via SSL, connect without using SSL.

“tunnel_http_proxy”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to tunnel all operations (all protocols) through the HTTP proxy.

“use_ascii_transfer”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to use ASCII mode for FTP transfers.

“use_pret”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to send a PRET command before sending PASV/EPSV when performing passive FTP transfers.

"use_ssl": Set to true to connect using Transport Layer Security (TLS) for SMTPS and FTPS (explicit) connections.

"username": Set to a string containing the username to be used in any authentication requests from the server.

“use_ssl_control”: (Introduced in tsNet version 1.4.0) Set this option to true to ensure all control communication is encrypted.

“user_agent”: (Introduced in tsNet version 1.4.0) The contents of this setting will be used as the HTTP User-Agent: header sent as part of a HTTP request.

Function:  tsNetSendCmdSync

 

Send a synchronous command to a FTP or SFTP server.

tsNetSendCmdSync(<pURL>, <pCommand>, <rResult>, <rBytes>, [<pSettings>])

 

Operating Systems supported: Mac OS X, Windows, Linux, iOS and Android

Platforms supported:  Desktop, Server and Mobile

Example 1:

   local tResultCode, tBytes, tCmds, tResult
   put “CWD /upload_dir” into tCmds
   put cr & “DELE backup.dat” after tCmds
   put tsNetSendCmdSync(“ftp://user:pass@ftp.example.com”, tCmds, \
      tResultCode, tBytes) into tResult

Example 2:

   local tResultCode, tBytes, tCmds, tResult
   put “mkdir /path/to/upload_dir” into tCmds
   put tsNetSendCmdSync(“sftp://user:pass@sftp.example.com”, tCmds, \
      tResultCode, tBytes) into tResult

Parameters:

  • pURL: The URL formatted as ‘scheme://host:port/path’ and URL-encoded as outlined in [RFC 3986](http://www.ietf.org/rfc/rfc3986.txt). The following schemes are supported: ‘tftp’, ‘ftp’, ‘ftps’, ‘http’, ‘https’ and ‘sftp’. For SFTP connections, the path is not relative to the user’s home directory, but must be the full system path.
  • pCommand: Set to a list of raw FTP/SFTP commands (one per line) that should be executed on the server.
  • rResult: This variable will contain the status code sent by the server to the last command that was issued during the transfer. For SFTP connections, this will always be 0. On error, the return value will be a string containing the error starting with “tsneterr:”.
  • rBytes: This variable will contain the number of bytes that were downloaded during the connection.
  • pSettings: An array of additional settings that control how the transfer is initiated.

Returns:

The tsNetSendCmdSync function returns the headers sent by the server on success.

Description:

The settings array can consist of the following elements (not all of the settings make sense for every possible transfer type): 

"byte_range": (Introduced in tsNet version 1.4.0) Specify the range of data to be downloaded. This can be in the format of “X-Y”, “X-“, “-Y” or “X-Y,N-M” where X, Y, N and M and byte indexes. Some HTTP servers may ignore this request.

"cookie_file": (Introduced in tsNet version 1.4.0) Specify a filename to load cookies from. If this setting is present, the internal cookie engine will be enabled and the cookies stored in the file loaded into the engine.

"cookies": (Introduced in tsNet version 1.4.0) The contents of this setting will be used to set a cookie in a HTTP request. It should be in the format of COOKIE_NAME=COOKIE_CONTENTS. Specify multiple cookies by separating them with a semi-colon. This setting does not enable the internal cookie engine of tsNet.

"cookie_jar": (Introduced in tsNet version 1.4.0) Specify a filename to write all known cookies to. If this setting is present, the internal cookie engine of tsNet will be enabled. Note that this file will only be written to at unspecified times. Use the “cookie_list” setting below to force the file to be updated.

"cookie_list": (Introduced in tsNet version 1.4.0) Set this to a list of cookies (one per line) in Netscape / Mozilla format or regular HTTP (Set-Cookie:) style format to add to the internal cookie engine. There are also several strings that when passed to this setting will perform additional actions. Passing in the string “ALL” will erase all cookies held in memory. “SESS” will erase all session cookies in memory. “FLUSH” will write all cookies stored in memory to the file specified by the “cookie_jar” setting. “RELOAD” will reload all cookies from file specified by “cookie_file”.

"disable_eprt": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from using the EPRT command when performing active FTP transfers.

"disable_epsv": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from using the EPSV command when performing passive FTP transfers.

"dont_modify_path": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from squashing “/../” and “/./” components from the URL path. RFC 3986 specifies that these should be removed.

“enable_tcp_keepalive”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to send TCP keepalive probes.

“expect100_timeout”: (Introduced in tsNet version 1.4.0) Specify the number of milliseconds to wait for a response with a HTTP 100 (Continue) or HTTP 417 (Expectation Failed) status after setting a HTTP request containing an Expect: 100-continue header. The default is 1000ms.

"fail_on_http_error": Set to true to specify that HTTP status codes greater than 400 should be considered an error.

"force_basic_auth": (Introduced in tsNet version 1.3.1) Set to true to force HTTP basic authentication rather than allow tsNet to detect what authentication methods are supported by the server.

"force_digest_auth": (Introduced in tsNet version 1.3.5) Set to true to force HTTP digest authentication rather than allow tsNet to detect what authentication methods are supported by the server.

“ftp_filemethod”: (Introduced in tsNet version 1.4.0) Set this to “nocwd” or “singlecwd” to change the method used by FTP to reach a particular file. Using “nocwd” will ensure all FTP commands use the full path to the file on the server. Using “singlecwd” will make tsNet issue a single CWD command to change to the directory that the file resides in before performing any other action on the file. The default is to issue a CWD command for each path part in the URL prior to performing any other action on the file in accordance with RFC 1738.

“ftp_ssl_ccc”: (Introduced in tsNet version 1.4.0) Set this to “passive” or “active” to disable the SSL/TLS encryption after authenticating with the FTP server. All further communication on the command channel with the FTP server will be unencrypted. Use “passive” to only disable the encryption after the server requests it. Setting this to “active” will initiate the encryption shutdown.

“ftp_user_alt”: (Introduced in tsNet version 1.4.0) Specify an alternate string to use for authentication if the standard FTP username and password negotiation fails.

“if_mod_since”: (Introduced in tsNet version 1.4.0) If the last modified time (in seconds since 1 Jan 1970) of the file is later than this, then download the file.

“if_unmod_since”: (Introduced in tsNet version 1.4.0) If the last modified time (in seconds since 1 Jan 1970) of the file is earlier than this, then download the file.

“ignore_content_length”: (Introduced in tsNet version 1.4.0) Set this option to true to ignore the content length specified in HTTP or FTP transfers. tsNet will complete the download when the server ends the connection.

“interface”: (Introduced in tsNet version 1.4.0) Specify the interface, IP address or host name to be used for the outgoing connection.

“junk_session_cookies”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to ignore all cookies loaded via the “cookie_file” setting that are session cookies.

“keepalive_idle”: (Introduced in tsNet version 1.4.0) When “enable_tcp_keepalive” is set to true, use this setting to specify the number of second to wait while the connection is idle before sending keepalive probes. The default is 60 seconds.

“keepalive_interval”: (Introduced in tsNet version 1.4.0) When “enable_tcp_keepalive” is set to true, use this setting to specify the number of seconds to wait between sending keepalive probes. The default is 60 seconds.

“local_port_range”: (Introduced in tsNet version 1.4.0) Set the number of consecutive ports above the port specified by the “local_port_start” setting to try when finding an available port for a connection.

“local_port_start”: (Introduced in tsNet version 1.4.0) Set the local port number of the socket to be used for the connection. It is recommended to also set “local_port_range” if you use this setting.

“max_file_size”: (Introduced in tsNet version 1.4.0) Specify the maximum size of a file to download. If the file exceeds this value, the transfer will not start. This option has no affect is the file size is not known prior to the download.

“max_recv_speed”: (Introduced in tsNet version 1.4.0) This option specifies the number of bytes per second to limit a download transfer to. Setting this to 0 disables any limiting.

“max_send_speed”: (Introduced in tsNet version 1.4.0) This option specifies the number of bytes per second to limit an upload transfer to. Setting this to 0 disables any limiting.

"no_reuse": Set to true to specify that the connection to the server should be disconnected and not left open for any future connections.

"no_transfer": Set to true to connect to the server but not perform any transfer.

"password": Set to a string containing the password to be used in any authentication requests from the server.

"post_commands": (Business Edition only) Set to a list of raw FTP/SFTP commands (one per line) that should be executed on the server directly after any transfer.

“post_on_301”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 301 response.

“post_on_302”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 302 response.

“post_on_303”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 303 response.

"pre_commands": (Business Edition only) Set to a list of raw FTP/SFTP commands (one per line) that should be executed on the server prior to any transfer.

“proxy_auth_basic”: (Introduced in tsNet version 1.4.0) Set this option to true to force tsNet to use basic authentication when authenticating with a proxy server.

“proxy_auth_digest”: (Introduced in tsNet version 1.4.0) Set this option to true to force tsNet to use digest authentication when authenticating with a proxy server.

"proxy_headers": Set to a list of headers (one per line) that should be sent to any proxy server that is being used.

“proxy_http_10”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to use HTTP/1.0 for any CONNECT tunnelling.

“referer”: (Introduced in tsNet version 1.4.0) The contents of this setting will be used as the HTTP Referer: header sent as part of a HTTP request.

“resolve_hosts”: (Introduced in tsNet version 1.4.0) Specify a list (one per line) of host to IP addresses to use when resolving host name for a request. Each line must be in the format of “HOSTNAME:PORT:ADDRESS”.

“resume_from”: (Introduced in tsNet version 1.4.0) Specify the number of bytes at which you want a transfer to start downloading or uploading.

"save_sent_headers": Set to true to specify that external should store a copy of all the headers that it sends to the server. This must be set to true to use the tsNetRetrSentHeaders function.

“skip_pasv_ip”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to ignore the IP address from the server’s 227 response message. tsNet will connect the data connection via the same IP address it used to set up the control connection.

“ssl_ciphers”: (Introduced in tsNet version 1.4.0) Use this setting to specify a list of SSL ciphers (separated by colons) to be used when negotiating SSL connections.

“ssl_client_cert”: (Introduced in tsNet version 1.4.1) Specify the filename of a client SSL certificate to use for authentication to the server.

“ssl_client_cert_type”: (Introduced in tsNet version 1.4.1) Set to the format of the client SSL certificate. Supported formats are “PEM”, “DER” and “P12”.

“ssl_client_key”: (Introduced in tsNet version 1.4.1) Specify the filename of a SSL private key file that matches the client SSL certificate.

“ssl_client_key_pass”: (Introduced in tsNet version 1.4.1) Set to the password for the SSL private key.

“ssl_client_key_type”: (Introduced in tsNet version 1.4.1) Set to the format of the SSL private key. Supported formats are “PEM” and “DER”.

“ssl_proxy_client_cert”: (Introduced in tsNet version 1.4.1) Specify the filename of a proxy client SSL certificate to use for authentication to the HTTP proxy.

“ssl_proxy_client_cert_type”: (Introduced in tsNet version 1.4.1) Set to the format of the proxy client SSL certificate. Supported formats are “PEM”, “DER” and “P12”.

“ssl_proxy_client_key”: (Introduced in tsNet version 1.4.1) Specify the filename of a SSL private key file that matches the proxy client SSL certificate.

“ssl_proxy_client_key_pass”: (Introduced in tsNet version 1.4.1) Set to the password for the SSL private key.

“ssl_proxy_client_key_type”: (Introduced in tsNet version 1.4.1) Set to the format of the SSL private key. Supported formats are “PEM” and “DER”.

"ssh_host_public_key": Set to the 128 bit MD5 checksum of the remote host's public key. The connection will be rejected unless they match.

"ssh_passphrase": (Business Edition only) Set to the passphrase for any included private key.

"ssh_private_key": (Business Edition only) Set to the private key file (including full system path) to be used in SFTP transfers.

“trace”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to include all inbound and outbound data when using tsNetSetDebugCallback() rather than just header and informational data. When this option is set, a third parameter will be posted to the debug callback function specifying the type of data that is being passed to the callback function.

“transfer_encoding”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to request the response be sent in a compressed Transfer-Encoding (if the server supports it) that will be automatically uncompressed by tsNet when it is received.

“trust_location_auth”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to continue to send authentication details when following any HTTP redirects.

“try_ssl”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to try to connect via SSL. If the connection fails to establish via SSL, connect without using SSL.

“tunnel_http_proxy”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to tunnel all operations (all protocols) through the HTTP proxy.

“use_ascii_transfer”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to use ASCII mode for FTP transfers.

“use_pret”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to send a PRET command before sending PASV/EPSV when performing passive FTP transfers.

"use_ssl": Set to true to connect using Transport Layer Security (TLS) for SMTPS and FTPS (explicit) connections.

"username": Set to a string containing the username to be used in any authentication requests from the server.

“use_ssl_control”: (Introduced in tsNet version 1.4.0) Set this option to true to ensure all control communication is encrypted.

“user_agent”: (Introduced in tsNet version 1.4.0) The contents of this setting will be used as the HTTP User-Agent: header sent as part of a HTTP request.

Function:  tsNetSmtp

 

Send an asynchronous upload request to a server.

tsNetSmtp(<pConnectionID>, <pURL>, <pFrom>, <pRcpt>, <pCallback>, <pData>, [<pSettings>])

 

Operating Systems supported: Mac OS X, Windows, Linux, iOS and Android

Platforms supported:  Desktop, Server and Mobile

Example 1:

   local tRcpt, tResult, tFilePath, tData, tSettings
   put “mysmtpusername@example.com” into tSettings[“username”]
   put “mysmtppassword” into tSettings[“password”]
   — This next line forces the connection to be TLS
   put true into tSettings[“use_ssl”]
   put specialFolderPath(“documents”) & “/mime_message.eml” into tFilePath
   put URL(“file:” & tFilePath) into tData
   put “you@example.com” & cr & “admin@example.com” into tRcpt
   — For TLS connections, the standard port is 587
   put tsNetSmtp(“1”, “smtp://smtp.example.com:587”, “me@example.com”, \
      tRcpt, “transferComplete”, tData, tSettings) into tResult

Example 2:

   local tRcpt, tResult, tFilePath, tData, tSettings
   put “mysmtpusername@example.com” into tSettings[“username”]
   put “mysmtppassword” into tSettings[“password”]
   put specialFolderPath(“documents”) & “/mime_message.eml” into tFilePath
   put URL(“file:” & tFilePath) into tData
   put “you@example.com” & cr & “admin@example.com” into tRcpt
   — Using smtps:// here forces the connection to be SSL
   put tsNetSmtp(“1”, “smtps://smtp.example.com”, “me@example.com”, \
      tRcpt, “transferComplete”, tData, tSettings) into tResult

Example 3:

   on transferComplete pID, pResult, pBytes, pCurlCode
      local tData, tHeaders
      if pCurlCode is not 0 then
         answer tsNetRetrError(pID)
      else
         answer “Email sent successfully”
      end if
      tsNetCloseConn pID
   end transferComplete

Parameters:

  • pConnectionID: A arbitrary user-defined label for the connection that is used when retrieving any details of the transfer.
  • pURL: The URL formatted as ‘scheme://host:port/path’ and URL-encoded as outlined in [RFC 3986](http://www.ietf.org/rfc/rfc3986.txt). For SMTP functions, the scheme must be either ‘smtp’ or ‘smtps’.
  • pFrom: The e-mail address of the sender to be used in the MAIL FROM command to the SMTP server. This is unrelated to the sender listed in the mail header itself which is contained within the pData parameter.
  • pRcpt: The e-mail addresses of the recipients to be used in the RCPT TO command to the SMTP server. This is unrelated to the recipients listed in the mail header itself which is contained within the pData parameter.
  • pCallback: Specify a callback message to be sent to the current object when the transfer is complete.
  • pData: The e-mail message that is to be sent to the server.  Please note that the pData parameter consists of the entire message – any e-mail headers followed by a blank line and then the body of the e-mail.  The subject of an e-mail is one potential header that can be included, however others include the “From”, “To”, “Cc” headers along with the “Content-Type” header, mime related headers and any number of other bits of information that can be included as part of the header of an e-mail.
  • pSettings: An array of additional settings that control how the transfer is initiated.

Returns:

The tsNetSmtp function returns empty on success. On error, the return value will be a string containing the error starting with
“tsneterr:”.

Description:

This function sends a callback message on completion. Use tsNetRetrData to access any returned data. To save memory, it
is recommended to call tsNetCloseConn when the connection is no longer needed.

Using the `smtps://` scheme will initiate an SMTP SSL connection to the server. To connect using Transport Layer Security (TLS), use a URL with a format of `smtp://host:port` where the port number reflects the appropriate server port for TLS connections and set the “use_ssl” array setting below to true.

The callback message will be sent with four parameters: the connection identifier, the status code sent back by the server, the number of bytes transferred and the cURL result code.

The cURL result code parameter in the callback message will be 0 for successful transfers. For any errors, further information can be retrieved by calling the tsNetRetrError function.

The settings array can consist of the following elements (not all of the settings make sense for every possible transfer type):

"enable_tcp_keepalive": (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to send TCP keepalive probes.

"interface": (Introduced in tsNet version 1.4.0) Specify the interface, IP address or host name to be used for the outgoing connection.

"keepalive_idle": (Introduced in tsNet version 1.4.0) When "enable_tcp_keepalive" is set to true, use this setting to specify the number of second to wait while the connection is idle before sending keepalive probes. The default is 60 seconds.

"keepalive_interval": (Introduced in tsNet version 1.4.0) When "enable_tcp_keepalive" is set to true, use this setting to specify the number of seconds to wait between sending keepalive probes. The default is 60 seconds.

"local_port_range": (Introduced in tsNet version 1.4.0) Set the number of consecutive ports above the port specified by the "local_port_start" setting to try when finding an available port for a connection.

"local_port_start": (Introduced in tsNet version 1.4.0) Set the local port number of the socket to be used for the connection. It is recommended to also set "local_port_range" if you use this setting.

"no_reuse": Set to true to specify that the connection to the server should be disconnected and not left open for any future connections.

"no_transfer": Set to true to connect to the server but not perform any transfer.

"password": Set to a string containing the password to be used in any authentication requests from the server.

"proxy_headers": Set to a list of headers (one per line) that should be sent to any proxy server that is being used.

"replace_lf_crlf": (Introduced in tsNet version 1.3.5) If this is set to true, tsNet will convert the standard LiveCode newline in the body of the e-mail with CRLF. Some SMTP servers do not recognise the standard LiveCode end-of-line character and you may experience issues sending e-mail through them unless this is enabled.

"resolve_hosts": (Introduced in tsNet version 1.4.0) Specify a list (one per line) of host to IP addresses to use when resolving host name for a request. Each line must be in the format of "HOSTNAME:PORT:ADDRESS".

"save_sent_headers": Set to true to specify that external should store a copy of all the headers that it sends to the server. This must be set to true to use the tsNetRetrSentHeaders function.

"ssl_ciphers": (Introduced in tsNet version 1.4.0) Use this setting to specify a list of SSL ciphers (separated by colons) to be used when negotiating SSL connections.

"trace": (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to include all inbound and outbound data when using tsNetSetDebugCallback() rather than just header and informational data. When this option is set, a third parameter will be posted to the debug callback function specifying the type of data that is being passed to the callback function.

"try_ssl": (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to try to connect via SSL. If the connection fails to establish via SSL, connect without using SSL.

"tunnel_http_proxy": (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to tunnel all operations (all protocols) through the HTTP proxy.

"username": Set to a string containing the username to be used in any authentication requests from the server.

"use_ssl": Set to true to connect using Transport Layer Security (TLS) for SMTPS and FTPS (explicit) connections.

Function:  tsNetSmtpFile

 

Send an asynchronous upload request to a server which retrieves the data to be sent directly from a file.

tsNetSmtpFile(<pConnectionID>, <pFile>, <pURL>, <pFrom>, <pRcpt>, <pCallback>, [<pSettings>])

 

Operating Systems supported: Mac OS X, Windows, Linux, iOS and Android

Platforms supported:  Desktop, Server and Mobile

Example 1:

   local tRcpt, tResult, tSettings
   put “mysmtpusername@example.com” into tSettings[“username”]
   put “mysmtppassword” into tSettings[“password”]
   — This next line forces the connection to be TLS
   put true into tSettings[“use_ssl”]
   put “you@example.com” & cr & “admin@example.com” into tRcpt
   — For TLS connections, the standard port is 587
   put tsNetSmtpFile(“1”, “/path/to/email/message.eml”, \
      “smtp://smtp.example.com:587”, “me@example.com”, \
      tRcpt, “transferComplete”, tSettings) into tResult

Example 2:

   local tRcpt, tResult, tSettings
   put “mysmtpusername@example.com” into tSettings[“username”]
   put “mysmtppassword” into tSettings[“password”]
   put “you@example.com” & cr & “admin@example.com” into tRcpt
   — Using smtps:// here forces the connection to be SSL
   put tsNetSmtpFile(“1”, “/path/to/email/message.eml”, \
      “smtps://smtp.example.com”, “me@example.com”, \
      tRcpt, “transferComplete”, tSettings) into tResult

Example 3:

   on transferComplete pID, pResult, pBytes, pCurlCode
      local tData, tHeaders
      if pCurlCode is not 0 then
         answer tsNetRetrError(pID)
      else
         answer “Email sent successfully”
      end if
      tsNetCloseConn pID
   end transferComplete

Parameters:

  • pConnectionID: A arbitrary user-defined label for the connection that is used when retrieving any details of the transfer.
  • pFile: The full path and filename that contains the e-mail message to be sent to the server.  Please note that the file must consist of the entire message – any e-mail headers followed by a blank line and then the body of the e-mail.  The subject of an e-mail is one potential header that can be included, however others include the “From”, “To”, “Cc” headers along with the “Content-Type” header, mime related headers and any number of other bits of information that can be included as part of the header of an e-mail.
  • pURL: The URL formatted as ‘scheme://host:port/path’ and URL-encoded as outlined in [RFC 3986](http://www.ietf.org/rfc/rfc3986.txt). For SMTP functions, the scheme must be either ‘smtp’ or ‘smtps’.
  • pFrom: The e-mail address of the sender to be used in the MAIL FROM command to the SMTP server. This is unrelated to the sender listed in the mail header itself which is contained within the pData parameter.
  • pRcpt: The e-mail addresses of the recipients to be used in the RCPT TO command to the SMTP server. This is unrelated to the recipients listed in the mail header itself which is contained within the pData parameter.
  • pCallback: Specify a callback message to be sent to the current object when the transfer is complete.
  • pSettings: An array of additional settings that control how the transfer is initiated.

Returns:

The tsNetSmtpFile function returns empty on success. On error, the return value will be a string containing the error starting
with “tsneterr:”.

Description:

This function sends a callback message on completion. To save memory, it is recommended to call tsNetCloseConn when the connection is no longer needed.

Using the `smtps://` scheme will initiate an SMTP SSL connection to the server. To connect using Transport Layer Security (TLS), use a URL with a format of `smtp://host:port` where the port number reflects the appropriate server port for TLS connections and set the “use_ssl” array setting below to true.

The callback message will be sent with four parameters: the connection identifier, the status code sent back by the server, the number of bytes transferred and the cURL result code.

The cURL result code parameter in the callback message will be 0 for successful transfers. For any errors, further information can be retrieved by calling the tsNetRetrError function.

The settings array can consist of the following elements (not all of the settings make sense for every possible transfer type):

"enable_tcp_keepalive": (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to send TCP keepalive probes.

"interface": (Introduced in tsNet version 1.4.0) Specify the interface, IP address or host name to be used for the outgoing connection.

"keepalive_idle": (Introduced in tsNet version 1.4.0) When "enable_tcp_keepalive" is set to true, use this setting to specify the number of second to wait while the connection is idle before sending keepalive probes. The default is 60 seconds.

"keepalive_interval": (Introduced in tsNet version 1.4.0) When "enable_tcp_keepalive" is set to true, use this setting to specify the number of seconds to wait between sending keepalive probes. The default is 60 seconds.

"local_port_range": (Introduced in tsNet version 1.4.0) Set the number of consecutive ports above the port specified by the "local_port_start" setting to try when finding an available port for a connection.

"local_port_start": (Introduced in tsNet version 1.4.0) Set the local port number of the socket to be used for the connection. It is recommended to also set "local_port_range" if you use this setting.

"no_reuse": Set to true to specify that the connection to the server should be disconnected and not left open for any future connections.

"no_transfer": Set to true to connect to the server but not perform any transfer.

"password": Set to a string containing the password to be used in any authentication requests from the server.

"proxy_headers": Set to a list of headers (one per line) that should be sent to any proxy server that is being used.

"replace_lf_crlf": (Introduced in tsNet version 1.3.5) If this is set to true, tsNet will convert the standard LiveCode newline in the body of the e-mail with CRLF. Some SMTP servers do not recognise the standard LiveCode end-of-line character and you may experience issues sending e-mail through them unless this is enabled.

"resolve_hosts": (Introduced in tsNet version 1.4.0) Specify a list (one per line) of host to IP addresses to use when resolving host name for a request. Each line must be in the format of "HOSTNAME:PORT:ADDRESS".

"save_sent_headers": Set to true to specify that external should store a copy of all the headers that it sends to the server. This must be set to true to use the tsNetRetrSentHeaders function.

"ssl_ciphers": (Introduced in tsNet version 1.4.0) Use this setting to specify a list of SSL ciphers (separated by colons) to be used when negotiating SSL connections.

"trace": (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to include all inbound and outbound data when using tsNetSetDebugCallback() rather than just header and informational data. When this option is set, a third parameter will be posted to the debug callback function specifying the type of data that is being passed to the callback function.

"try_ssl": (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to try to connect via SSL. If the connection fails to establish via SSL, connect without using SSL.

"tunnel_http_proxy": (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to tunnel all operations (all protocols) through the HTTP proxy.

"username": Set to a string containing the username to be used in any authentication requests from the server.

"use_ssl": Set to true to connect using Transport Layer Security (TLS) for SMTPS and FTPS (explicit) connections.

Function:  tsNetSmtpFileSync

 

Send a synchronous upload request to a server which retrieves the data to be sent directly from a file.

tsNetSmtpFileSync(<pFile>, <pURL>, <pFrom>, <pRcpt>, <rOutHeaders>, <rBytes>, [<pSettings>])

 

Operating Systems supported: Mac OS X, Windows, Linux, iOS and Android

Platforms supported:  Desktop, Server and Mobile

Example 1:

   local tRcpt, tResult, tOutHeaders, tBytes, tFilePath, tData, tSettings
   put “mysmtpusername@example.com” into tSettings[“username”]
   put “mysmtppassword” into tSettings[“password”]
   — This next line forces the connection to be TLS
   put true into tSettings[“use_ssl”]
   put “you@example.com” & cr & “admin@example.com” into tRcpt
   — For TLS connections, the standard port is 587
   put tsNetSmtpFileSync(“/path/to/email/message.eml”, \
      “smtp://smtp.example.com:587”, “me@example.com”, \
      tRcpt, tOutHeaders, tBytes, tSettings) into tResult

Example 2:

   local tRcpt, tResult, tOutHeaders, tBytes, tFilePath, tData, tSettings
   put “mysmtpusername@example.com” into tSettings[“username”]
   put “mysmtppassword” into tSettings[“password”]
   put “you@example.com” & cr & “admin@example.com” into tRcpt
   — Using smtps:// here forces the connection to be SSL
   put tsNetSmtpFileSync(“/path/to/email/message.eml”, \
      “smtps://smtp.example.com”, “me@example.com”, \
      tRcpt, tOutHeaders, tBytes, tSettings) into tResult

Parameters:

  • pFile: The full path and filename that contains the e-mail message to be sent to the server.  Please note that the file must consist of the entire message – any e-mail headers followed by a blank line and then the body of the e-mail.  The subject of an e-mail is one potential header that can be included, however others include the “From”, “To”, “Cc” headers along with the “Content-Type” header, mime related headers and any number of other bits of information that can be included as part of the header of an e-mail.
  • pURL: The URL formatted as ‘scheme://host:port/path’ and URL-encoded as outlined in [RFC 3986](http://www.ietf.org/rfc/rfc3986.txt). For SMTP functions, the scheme must be either ‘smtp’ or ‘smtps’.
  • pFrom: The e-mail address of the sender to be used in the MAIL FROM command to the SMTP server. This is unrelated to the sender listed in the mail header itself which is contained within the pData parameter.
  • pRcpt: The e-mail addresses of the recipients to be used in the RCPT TO command to the SMTP server. This is unrelated to the recipients listed in the mail header itself which is contained within the pData parameter.
  • rOutHeaders: This variable will contain the headers that were returned from the server on completion.
  • rBytes: This variable will contain the number of bytes that were downloaded during the connection.
  • pSettings: An array of additional settings that control how the transfer is initiated.

Returns:

The tsNetSmtpFileSync function returns the status code sent by the server to the last command that was issued during the transfer on
success. For SFTP connections, this will always be 0. On error, the return value will be a string containing the error starting with “tsneterr:”.

Description:

Using the `smtps://` scheme will initiate an SMTP SSL connection to the server. To connect using Transport Layer Security (TLS), use a URL with a format of `smtp://host:port` where the port number reflects the appropriate server port for TLS connections and set the “use_ssl” array setting below to true.

The settings array can consist of the following elements (not all of the settings make sense for every possible transfer type):

"enable_tcp_keepalive": (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to send TCP keepalive probes.

"interface": (Introduced in tsNet version 1.4.0) Specify the interface, IP address or host name to be used for the outgoing connection.

"keepalive_idle": (Introduced in tsNet version 1.4.0) When "enable_tcp_keepalive" is set to true, use this setting to specify the number of second to wait while the connection is idle before sending keepalive probes. The default is 60 seconds.

"keepalive_interval": (Introduced in tsNet version 1.4.0) When "enable_tcp_keepalive" is set to true, use this setting to specify the number of seconds to wait between sending keepalive probes. The default is 60 seconds.

"local_port_range": (Introduced in tsNet version 1.4.0) Set the number of consecutive ports above the port specified by the "local_port_start" setting to try when finding an available port for a connection.

"local_port_start": (Introduced in tsNet version 1.4.0) Set the local port number of the socket to be used for the connection. It is recommended to also set "local_port_range" if you use this setting.

"no_reuse": Set to true to specify that the connection to the server should be disconnected and not left open for any future connections.

"no_transfer": Set to true to connect to the server but not perform any transfer.

"password": Set to a string containing the password to be used in any authentication requests from the server.

"proxy_headers": Set to a list of headers (one per line) that should be sent to any proxy server that is being used.

"replace_lf_crlf": (Introduced in tsNet version 1.3.5) If this is set to true, tsNet will convert the standard LiveCode newline in the body of the e-mail with CRLF. Some SMTP servers do not recognise the standard LiveCode end-of-line character and you may experience issues sending e-mail through them unless this is enabled.

"resolve_hosts": (Introduced in tsNet version 1.4.0) Specify a list (one per line) of host to IP addresses to use when resolving host name for a request. Each line must be in the format of "HOSTNAME:PORT:ADDRESS".

"save_sent_headers": Set to true to specify that external should store a copy of all the headers that it sends to the server. This must be set to true to use the tsNetRetrSentHeaders function.

"ssl_ciphers": (Introduced in tsNet version 1.4.0) Use this setting to specify a list of SSL ciphers (separated by colons) to be used when negotiating SSL connections.

"trace": (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to include all inbound and outbound data when using tsNetSetDebugCallback() rather than just header and informational data. When this option is set, a third parameter will be posted to the debug callback function specifying the type of data that is being passed to the callback function.

"try_ssl": (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to try to connect via SSL. If the connection fails to establish via SSL, connect without using SSL.

"tunnel_http_proxy": (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to tunnel all operations (all protocols) through the HTTP proxy.

"username": Set to a string containing the username to be used in any authentication requests from the server.

"use_ssl": Set to true to connect using Transport Layer Security (TLS) for SMTPS and FTPS (explicit) connections.

Function:  tsNetSmtpSync

 

Send a synchronous upload request to a server.

tsNetSmtpSync(<pURL>, <pFrom>, <pRcpt>, <pData>, <rOutHeaders>, <rBytes>, [<pSettings>])

 

Operating Systems supported: Mac OS X, Windows, Linux, iOS and Android

Platforms supported:  Desktop, Server and Mobile

Example 1:

   local tRcpt, tResult, tOutHeaders, tBytes, tFilePath, tData, tSettings
   put “mysmtpusername@example.com” into tSettings[“username”]
   put “mysmtppassword” into tSettings[“password”]
   — This next line forces the connection to be TLS
   put true into tSettings[“use_ssl”]
   put specialFolderPath(“documents”) & “/mime_message.eml” into tFilePath
   put URL(“file:” & tFilePath) into tData
   put “you@example.com” & cr & “admin@example.com” into tRcpt
   — For TLS connections, the standard port is 587
   put tsNetSmtpSync(“smtp://smtp.example.com:587”, “me@example.com”, \
      tRcpt, tData, tOutHeaders, tBytes, tSettings) into tResult

Example 2:

   local tRcpt, tResult, tOutHeaders, tBytes, tFilePath, tData, tSettings
   put “mysmtpusername@example.com” into tSettings[“username”]
   put “mysmtppassword” into tSettings[“password”]
   put specialFolderPath(“documents”) & “/mime_message.eml” into tFilePath
   put URL(“file:” & tFilePath) into tData
   put “you@example.com” & cr & “admin@example.com” into tRcpt
   — Using smtps:// here forces the connection to be SSL
   put tsNetSmtpSync(“smtps://smtp.example.com”, “me@example.com”, \
      tRcpt, tData, tOutHeaders, tBytes, tSettings) into tResult

Parameters:

  • pURL: The URL formatted as ‘scheme://host:port/path’ and URL-encoded as outlined in [RFC 3986](http://www.ietf.org/rfc/rfc3986.txt). For SMTP functions, the scheme must be either ‘smtp’ or ‘smtps’.
  • pFrom: The e-mail address of the sender to be used in the MAIL FROM command to the SMTP server. This is unrelated to the sender listed in the mail header itself which is contained within the pData parameter.
  • pRcpt: The e-mail addresses of the recipients to be used in the RCPT TO command to the SMTP server. This is unrelated to the recipients listed in the mail header itself which is contained within the pData parameter.
  • pData: The e-mail message that is to be send to the server.  Please note that the pData parameter consists of the entire message – any e-mail headers followed by a blank line and then the body of the e-mail.  The subject of an e-mail is one potential header that can be included, however others include the “From”, “To”, “Cc” headers along with the “Content-Type” header, mime related headers and any number of other bits of information that can be included as part of the header of an e-mail.
  • rOutHeaders: This variable will contain the headers that were returned from the server on completion.
  • pResult: This variable will contain the status code sent by the server to the last command that was issued during the transfer. For SFTP connections, this will always be 0.
  • rBytes: This variable will contain the number of bytes that were downloaded during the connection.
  • pSettings: An array of additional settings that control how the transfer is initiated.

Returns:

The tsNetSmtpSync function returns the status code sent by the server to the last command that was issued during the transfer on success. For SFTP connections, this will always be 0. On error, the return value will be a string containing the error starting with “tsneterr:”.

Description:

Using the `smtps://` scheme will initiate an SMTP SSL connection to the server. To connect using Transport Layer Security (TLS), use a URL with a format of `smtp://host:port` where the port number reflects the appropriate server port for TLS connections and set the “use_ssl” array setting below to true.

The settings array can consist of the following elements (not all of the settings make sense for every possible transfer type):

"enable_tcp_keepalive": (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to send TCP keepalive probes.

"interface": (Introduced in tsNet version 1.4.0) Specify the interface, IP address or host name to be used for the outgoing connection.

"keepalive_idle": (Introduced in tsNet version 1.4.0) When "enable_tcp_keepalive" is set to true, use this setting to specify the number of second to wait while the connection is idle before sending keepalive probes. The default is 60 seconds.

"keepalive_interval": (Introduced in tsNet version 1.4.0) When "enable_tcp_keepalive" is set to true, use this setting to specify the number of seconds to wait between sending keepalive probes. The default is 60 seconds.

"local_port_range": (Introduced in tsNet version 1.4.0) Set the number of consecutive ports above the port specified by the "local_port_start" setting to try when finding an available port for a connection.

"local_port_start": (Introduced in tsNet version 1.4.0) Set the local port number of the socket to be used for the connection. It is recommended to also set "local_port_range" if you use this setting.

"no_reuse": Set to true to specify that the connection to the server should be disconnected and not left open for any future connections.

"no_transfer": Set to true to connect to the server but not perform any transfer.

"password": Set to a string containing the password to be used in any authentication requests from the server.

"proxy_headers": Set to a list of headers (one per line) that should be sent to any proxy server that is being used.

"replace_lf_crlf": (Introduced in tsNet version 1.3.5) If this is set to true, tsNet will convert the standard LiveCode newline in the body of the e-mail with CRLF. Some SMTP servers do not recognise the standard LiveCode end-of-line character and you may experience issues sending e-mail through them unless this is enabled.

"resolve_hosts": (Introduced in tsNet version 1.4.0) Specify a list (one per line) of host to IP addresses to use when resolving host name for a request. Each line must be in the format of "HOSTNAME:PORT:ADDRESS".

"save_sent_headers": Set to true to specify that external should store a copy of all the headers that it sends to the server. This must be set to true to use the tsNetRetrSentHeaders function.

"ssl_ciphers": (Introduced in tsNet version 1.4.0) Use this setting to specify a list of SSL ciphers (separated by colons) to be used when negotiating SSL connections.

"trace": (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to include all inbound and outbound data when using tsNetSetDebugCallback() rather than just header and informational data. When this option is set, a third parameter will be posted to the debug callback function specifying the type of data that is being passed to the callback function.

"try_ssl": (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to try to connect via SSL. If the connection fails to establish via SSL, connect without using SSL.

"tunnel_http_proxy": (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to tunnel all operations (all protocols) through the HTTP proxy.

"username": Set to a string containing the username to be used in any authentication requests from the server.

"use_ssl": Set to true to connect using Transport Layer Security (TLS) for SMTPS and FTPS (explicit) connections.

Function:  tsNetUpload

 

Send an asynchronous upload request to a server.

tsNetUpload(<pConnectionID>, <pURL>, <pHeaders>, <pCallback>, <pData>, [<pSettings>])

 

Operating Systems supported: Mac OS X, Windows, Linux, iOS and Android

Platforms supported:  Desktop, Server and Mobile

Example 1:

   local tHeaders, tResult, tFilePath, tData
   put specialFolderPath(“documents”) & “/file.dat” into tFilePath
   put URL(“file:” & tFilePath) into tData
   put tsNetUpload(“1”, “ftp://user:pass@ftp.example.com/dir/file.dat”, \
      tHeaders, “transferComplete”, tData) into tResult

Example 2:

   on transferComplete pID, pResult, pBytes, pCurlCode
      local tData, tHeaders
      if pCurlCode is not 0 then
         answer tsNetRetrError(pID)
      else
         answer “File uploaded successfully”
      end if
      tsNetCloseConn pID
   end transferComplete

Parameters:

  • pConnectionID: A arbitrary user-defined label for the connection that is used when retrieving any details of the transfer.
  • pURL: The URL formatted as ‘scheme://host:port/path’ and URL-encoded as outlined in [RFC 3986](http://www.ietf.org/rfc/rfc3986.txt). The following schemes are supported: ‘tftp’, ‘ftp’, ‘ftps’, ‘http’, ‘https’ and ‘sftp’. For SFTP connections (Business Edition only), the path is not relative to the user’s home directory, but must be the full system path.
  • pHeaders: For HTTP(s) connections, the headers to be sent to the server. For all other protocols, leave this blank.
  • pCallback: Specify a callback message to be sent to the current object when the transfer is complete.
  • pData: The data that is to be sent to the server.
  • pSettings: An array of additional settings that control how the transfer is initiated.

Returns:

The tsNetUpload function returns empty on success. On error, the return value will be a string containing the error starting with “tsneterr:”.

Description:

This function sends a callback message on completion. Use tsNetRetrData to access any returned data. To save memory, it is recommended to call tsNetCloseConn when the connection is no longer needed.

The callback message will be sent with four parameters: the connection identifier, the status code sent back by the server, the number of bytes transferred and the cURL result code.

The cURL result code parameter in the callback message will be 0 for successful transfers. For any errors, further information can be
retrieved by calling the tsNetRetrError function.

The settings array can consist of the following elements (not all of the settings make sense for every possible transfer type): 

"byte_range": (Introduced in tsNet version 1.4.0) Specify the range of data to be downloaded. This can be in the format of “X-Y”, “X-“, “-Y” or “X-Y,N-M” where X, Y, N and M and byte indexes. Some HTTP servers may ignore this request.

"cookie_file": (Introduced in tsNet version 1.4.0) Specify a filename to load cookies from. If this setting is present, the internal cookie engine will be enabled and the cookies stored in the file loaded into the engine.

"cookies": (Introduced in tsNet version 1.4.0) The contents of this setting will be used to set a cookie in a HTTP request. It should be in the format of COOKIE_NAME=COOKIE_CONTENTS. Specify multiple cookies by separating them with a semi-colon. This setting does not enable the internal cookie engine of tsNet.

"cookie_jar": (Introduced in tsNet version 1.4.0) Specify a filename to write all known cookies to. If this setting is present, the internal cookie engine of tsNet will be enabled. Note that this file will only be written to at unspecified times. Use the “cookie_list” setting below to force the file to be updated.

"cookie_list": (Introduced in tsNet version 1.4.0) Set this to a list of cookies (one per line) in Netscape / Mozilla format or regular HTTP (Set-Cookie:) style format to add to the internal cookie engine. There are also several strings that when passed to this setting will perform additional actions. Passing in the string “ALL” will erase all cookies held in memory. “SESS” will erase all session cookies in memory. “FLUSH” will write all cookies stored in memory to the file specified by the “cookie_jar” setting. “RELOAD” will reload all cookies from file specified by “cookie_file”.

"disable_eprt": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from using the EPRT command when performing active FTP transfers.

"disable_epsv": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from using the EPSV command when performing passive FTP transfers.

"dont_modify_path": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from squashing “/../” and “/./” components from the URL path. RFC 3986 specifies that these should be removed.

“enable_tcp_keepalive”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to send TCP keepalive probes.

“expect100_timeout”: (Introduced in tsNet version 1.4.0) Specify the number of milliseconds to wait for a response with a HTTP 100 (Continue) or HTTP 417 (Expectation Failed) status after setting a HTTP request containing an Expect: 100-continue header. The default is 1000ms.

"fail_on_http_error": Set to true to specify that HTTP status codes greater than 400 should be considered an error.

"force_basic_auth": (Introduced in tsNet version 1.3.1) Set to true to force HTTP basic authentication rather than allow tsNet to detect what authentication methods are supported by the server.

"force_digest_auth": (Introduced in tsNet version 1.3.5) Set to true to force HTTP digest authentication rather than allow tsNet to detect what authentication methods are supported by the server.

“ftp_filemethod”: (Introduced in tsNet version 1.4.0) Set this to “nocwd” or “singlecwd” to change the method used by FTP to reach a particular file. Using “nocwd” will ensure all FTP commands use the full path to the file on the server. Using “singlecwd” will make tsNet issue a single CWD command to change to the directory that the file resides in before performing any other action on the file. The default is to issue a CWD command for each path part in the URL prior to performing any other action on the file in accordance with RFC 1738.

“ftp_ssl_ccc”: (Introduced in tsNet version 1.4.0) Set this to “passive” or “active” to disable the SSL/TLS encryption after authenticating with the FTP server. All further communication on the command channel with the FTP server will be unencrypted. Use “passive” to only disable the encryption after the server requests it. Setting this to “active” will initiate the encryption shutdown.

“ftp_user_alt”: (Introduced in tsNet version 1.4.0) Specify an alternate string to use for authentication if the standard FTP username and password negotiation fails.

“if_mod_since”: (Introduced in tsNet version 1.4.0) If the last modified time (in seconds since 1 Jan 1970) of the file is later than this, then download the file.

“if_unmod_since”: (Introduced in tsNet version 1.4.0) If the last modified time (in seconds since 1 Jan 1970) of the file is earlier than this, then download the file.

“ignore_content_length”: (Introduced in tsNet version 1.4.0) Set this option to true to ignore the content length specified in HTTP or FTP transfers. tsNet will complete the download when the server ends the connection.

“interface”: (Introduced in tsNet version 1.4.0) Specify the interface, IP address or host name to be used for the outgoing connection.

“junk_session_cookies”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to ignore all cookies loaded via the “cookie_file” setting that are session cookies.

“keepalive_idle”: (Introduced in tsNet version 1.4.0) When “enable_tcp_keepalive” is set to true, use this setting to specify the number of second to wait while the connection is idle before sending keepalive probes. The default is 60 seconds.

“keepalive_interval”: (Introduced in tsNet version 1.4.0) When “enable_tcp_keepalive” is set to true, use this setting to specify the number of seconds to wait between sending keepalive probes. The default is 60 seconds.

“local_port_range”: (Introduced in tsNet version 1.4.0) Set the number of consecutive ports above the port specified by the “local_port_start” setting to try when finding an available port for a connection.

“local_port_start”: (Introduced in tsNet version 1.4.0) Set the local port number of the socket to be used for the connection. It is recommended to also set “local_port_range” if you use this setting.

“max_file_size”: (Introduced in tsNet version 1.4.0) Specify the maximum size of a file to download. If the file exceeds this value, the transfer will not start. This option has no affect is the file size is not known prior to the download.

“max_recv_speed”: (Introduced in tsNet version 1.4.0) This option specifies the number of bytes per second to limit a download transfer to. Setting this to 0 disables any limiting.

“max_send_speed”: (Introduced in tsNet version 1.4.0) This option specifies the number of bytes per second to limit an upload transfer to. Setting this to 0 disables any limiting.

"no_reuse": Set to true to specify that the connection to the server should be disconnected and not left open for any future connections.

"no_transfer": Set to true to connect to the server but not perform any transfer.

"password": Set to a string containing the password to be used in any authentication requests from the server.

"post_commands": (Business Edition only) Set to a list of raw FTP/SFTP commands (one per line) that should be executed on the server directly after any transfer.

“post_on_301”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 301 response.

“post_on_302”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 302 response.

“post_on_303”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 303 response.

"pre_commands": (Business Edition only) Set to a list of raw FTP/SFTP commands (one per line) that should be executed on the server prior to any transfer.

“proxy_auth_basic”: (Introduced in tsNet version 1.4.0) Set this option to true to force tsNet to use basic authentication when authenticating with a proxy server.

“proxy_auth_digest”: (Introduced in tsNet version 1.4.0) Set this option to true to force tsNet to use digest authentication when authenticating with a proxy server.

"proxy_headers": Set to a list of headers (one per line) that should be sent to any proxy server that is being used.

“proxy_http_10”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to use HTTP/1.0 for any CONNECT tunnelling.

“referer”: (Introduced in tsNet version 1.4.0) The contents of this setting will be used as the HTTP Referer: header sent as part of a HTTP request.

“resolve_hosts”: (Introduced in tsNet version 1.4.0) Specify a list (one per line) of host to IP addresses to use when resolving host name for a request. Each line must be in the format of “HOSTNAME:PORT:ADDRESS”.

“resume_from”: (Introduced in tsNet version 1.4.0) Specify the number of bytes at which you want a transfer to start downloading or uploading.

"save_sent_headers": Set to true to specify that external should store a copy of all the headers that it sends to the server. This must be set to true to use the tsNetRetrSentHeaders function.

“skip_pasv_ip”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to ignore the IP address from the server’s 227 response message. tsNet will connect the data connection via the same IP address it used to set up the control connection.

“ssl_ciphers”: (Introduced in tsNet version 1.4.0) Use this setting to specify a list of SSL ciphers (separated by colons) to be used when negotiating SSL connections.

“ssl_client_cert”: (Introduced in tsNet version 1.4.1) Specify the filename of a client SSL certificate to use for authentication to the server.

“ssl_client_cert_type”: (Introduced in tsNet version 1.4.1) Set to the format of the client SSL certificate. Supported formats are “PEM”, “DER” and “P12”.

“ssl_client_key”: (Introduced in tsNet version 1.4.1) Specify the filename of a SSL private key file that matches the client SSL certificate.

“ssl_client_key_pass”: (Introduced in tsNet version 1.4.1) Set to the password for the SSL private key.

“ssl_client_key_type”: (Introduced in tsNet version 1.4.1) Set to the format of the SSL private key. Supported formats are “PEM” and “DER”.

“ssl_proxy_client_cert”: (Introduced in tsNet version 1.4.1) Specify the filename of a proxy client SSL certificate to use for authentication to the HTTP proxy.

“ssl_proxy_client_cert_type”: (Introduced in tsNet version 1.4.1) Set to the format of the proxy client SSL certificate. Supported formats are “PEM”, “DER” and “P12”.

“ssl_proxy_client_key”: (Introduced in tsNet version 1.4.1) Specify the filename of a SSL private key file that matches the proxy client SSL certificate.

“ssl_proxy_client_key_pass”: (Introduced in tsNet version 1.4.1) Set to the password for the SSL private key.

“ssl_proxy_client_key_type”: (Introduced in tsNet version 1.4.1) Set to the format of the SSL private key. Supported formats are “PEM” and “DER”.

"ssh_host_public_key": Set to the 128 bit MD5 checksum of the remote host's public key. The connection will be rejected unless they match.

"ssh_passphrase": (Business Edition only) Set to the passphrase for any included private key.

"ssh_private_key": (Business Edition only) Set to the private key file (including full system path) to be used in SFTP transfers.

“trace”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to include all inbound and outbound data when using tsNetSetDebugCallback() rather than just header and informational data. When this option is set, a third parameter will be posted to the debug callback function specifying the type of data that is being passed to the callback function.

“transfer_encoding”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to request the response be sent in a compressed Transfer-Encoding (if the server supports it) that will be automatically uncompressed by tsNet when it is received.

“trust_location_auth”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to continue to send authentication details when following any HTTP redirects.

“try_ssl”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to try to connect via SSL. If the connection fails to establish via SSL, connect without using SSL.

“tunnel_http_proxy”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to tunnel all operations (all protocols) through the HTTP proxy.

“use_ascii_transfer”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to use ASCII mode for FTP transfers.

“use_pret”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to send a PRET command before sending PASV/EPSV when performing passive FTP transfers.

"use_ssl": Set to true to connect using Transport Layer Security (TLS) for SMTPS and FTPS (explicit) connections.

"username": Set to a string containing the username to be used in any authentication requests from the server.

“use_ssl_control”: (Introduced in tsNet version 1.4.0) Set this option to true to ensure all control communication is encrypted.

“user_agent”: (Introduced in tsNet version 1.4.0) The contents of this setting will be used as the HTTP User-Agent: header sent as part of a HTTP request.

Function:  tsNetUploadFile

 

Send an asynchronous upload request to a server which retrieves the data to be sent directly from a file.

tsNetUploadFile(<pConnectionID>, <pFile>, <pURL>, <pHeaders>, <pCallback>, [<pSettings>])

 

Operating Systems supported: Mac OS X, Windows, Linux, iOS and Android

Platforms supported:  Desktop, Server and Mobile

Example 1:

   local tHeaders, tResult
   put tsNetUploadFile(“1”, “/path/to/upload/file.dat”, \
      “ftp://user:pass@ftp.example.com/dir/file.dat”, tHeaders, \
      “transferComplete”) into tResult

Example 2:

   on transferComplete pID, pResult, pBytes, pCurlCode
      local tData, tHeaders
      if pCurlCode is not 0 then
         answer tsNetRetrError(pID)
      else
         answer “File uploaded successfully”
      end if
      tsNetCloseConn pID
   end transferComplete

Parameters:

  • pConnectionID: A arbitrary user-defined label for the connection that is used when retrieving any details of the transfer.
  • pFile: The full path and filename that contains the data to be sent to the server.
  • pURL: The URL formatted as ‘scheme://host:port/path’ and URL-encoded as outlined in [RFC 3986](http://www.ietf.org/rfc/rfc3986.txt). The following schemes are supported: ‘tftp’, ‘ftp’, ‘ftps’, ‘http’, ‘https’ and ‘sftp’. For SFTP connections (Business Edition only), the path is not relative to the user’s home directory, but must be the full system path.
  • pHeaders: For HTTP(s) connections, the headers to be sent to the server. For all other protocols, leave this blank.
  • pCallback: Specify a callback message to be sent to the current object when the transfer is complete.
  • pSettings: An array of additional settings that control how the transfer is initiated.

Returns:

The tsNetUploadFile function returns empty on success. On error, the return value will be a string containing the error starting
with “tsneterr:”.

Description:

This function sends a callback message on completion. To save memory, it is recommended to call tsNetCloseConn when the connection is no longer needed.

The callback message will be sent with four parameters: the connection identifier, the status code sent back by the server, the number of bytes transferred and the cURL result code.

The cURL result code parameter in the callback message will be 0 for successful transfers. For any errors, further information can be
retrieved by calling the tsNetRetrError function.

The settings array can consist of the following elements (not all of the settings make sense for every possible transfer type): 

"byte_range": (Introduced in tsNet version 1.4.0) Specify the range of data to be downloaded. This can be in the format of “X-Y”, “X-“, “-Y” or “X-Y,N-M” where X, Y, N and M and byte indexes. Some HTTP servers may ignore this request.

"cookie_file": (Introduced in tsNet version 1.4.0) Specify a filename to load cookies from. If this setting is present, the internal cookie engine will be enabled and the cookies stored in the file loaded into the engine.

"cookies": (Introduced in tsNet version 1.4.0) The contents of this setting will be used to set a cookie in a HTTP request. It should be in the format of COOKIE_NAME=COOKIE_CONTENTS. Specify multiple cookies by separating them with a semi-colon. This setting does not enable the internal cookie engine of tsNet.

"cookie_jar": (Introduced in tsNet version 1.4.0) Specify a filename to write all known cookies to. If this setting is present, the internal cookie engine of tsNet will be enabled. Note that this file will only be written to at unspecified times. Use the “cookie_list” setting below to force the file to be updated.

"cookie_list": (Introduced in tsNet version 1.4.0) Set this to a list of cookies (one per line) in Netscape / Mozilla format or regular HTTP (Set-Cookie:) style format to add to the internal cookie engine. There are also several strings that when passed to this setting will perform additional actions. Passing in the string “ALL” will erase all cookies held in memory. “SESS” will erase all session cookies in memory. “FLUSH” will write all cookies stored in memory to the file specified by the “cookie_jar” setting. “RELOAD” will reload all cookies from file specified by “cookie_file”.

"disable_eprt": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from using the EPRT command when performing active FTP transfers.

"disable_epsv": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from using the EPSV command when performing passive FTP transfers.

"dont_modify_path": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from squashing “/../” and “/./” components from the URL path. RFC 3986 specifies that these should be removed.

“enable_tcp_keepalive”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to send TCP keepalive probes.

“expect100_timeout”: (Introduced in tsNet version 1.4.0) Specify the number of milliseconds to wait for a response with a HTTP 100 (Continue) or HTTP 417 (Expectation Failed) status after setting a HTTP request containing an Expect: 100-continue header. The default is 1000ms.

"fail_on_http_error": Set to true to specify that HTTP status codes greater than 400 should be considered an error.

"force_basic_auth": (Introduced in tsNet version 1.3.1) Set to true to force HTTP basic authentication rather than allow tsNet to detect what authentication methods are supported by the server.

"force_digest_auth": (Introduced in tsNet version 1.3.5) Set to true to force HTTP digest authentication rather than allow tsNet to detect what authentication methods are supported by the server.

“ftp_filemethod”: (Introduced in tsNet version 1.4.0) Set this to “nocwd” or “singlecwd” to change the method used by FTP to reach a particular file. Using “nocwd” will ensure all FTP commands use the full path to the file on the server. Using “singlecwd” will make tsNet issue a single CWD command to change to the directory that the file resides in before performing any other action on the file. The default is to issue a CWD command for each path part in the URL prior to performing any other action on the file in accordance with RFC 1738.

“ftp_ssl_ccc”: (Introduced in tsNet version 1.4.0) Set this to “passive” or “active” to disable the SSL/TLS encryption after authenticating with the FTP server. All further communication on the command channel with the FTP server will be unencrypted. Use “passive” to only disable the encryption after the server requests it. Setting this to “active” will initiate the encryption shutdown.

“ftp_user_alt”: (Introduced in tsNet version 1.4.0) Specify an alternate string to use for authentication if the standard FTP username and password negotiation fails.

“if_mod_since”: (Introduced in tsNet version 1.4.0) If the last modified time (in seconds since 1 Jan 1970) of the file is later than this, then download the file.

“if_unmod_since”: (Introduced in tsNet version 1.4.0) If the last modified time (in seconds since 1 Jan 1970) of the file is earlier than this, then download the file.

“ignore_content_length”: (Introduced in tsNet version 1.4.0) Set this option to true to ignore the content length specified in HTTP or FTP transfers. tsNet will complete the download when the server ends the connection.

“interface”: (Introduced in tsNet version 1.4.0) Specify the interface, IP address or host name to be used for the outgoing connection.

“junk_session_cookies”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to ignore all cookies loaded via the “cookie_file” setting that are session cookies.

“keepalive_idle”: (Introduced in tsNet version 1.4.0) When “enable_tcp_keepalive” is set to true, use this setting to specify the number of second to wait while the connection is idle before sending keepalive probes. The default is 60 seconds.

“keepalive_interval”: (Introduced in tsNet version 1.4.0) When “enable_tcp_keepalive” is set to true, use this setting to specify the number of seconds to wait between sending keepalive probes. The default is 60 seconds.

“local_port_range”: (Introduced in tsNet version 1.4.0) Set the number of consecutive ports above the port specified by the “local_port_start” setting to try when finding an available port for a connection.

“local_port_start”: (Introduced in tsNet version 1.4.0) Set the local port number of the socket to be used for the connection. It is recommended to also set “local_port_range” if you use this setting.

“max_file_size”: (Introduced in tsNet version 1.4.0) Specify the maximum size of a file to download. If the file exceeds this value, the transfer will not start. This option has no affect is the file size is not known prior to the download.

“max_recv_speed”: (Introduced in tsNet version 1.4.0) This option specifies the number of bytes per second to limit a download transfer to. Setting this to 0 disables any limiting.

“max_send_speed”: (Introduced in tsNet version 1.4.0) This option specifies the number of bytes per second to limit an upload transfer to. Setting this to 0 disables any limiting.

"no_reuse": Set to true to specify that the connection to the server should be disconnected and not left open for any future connections.

"no_transfer": Set to true to connect to the server but not perform any transfer.

"password": Set to a string containing the password to be used in any authentication requests from the server.

"post_commands": (Business Edition only) Set to a list of raw FTP/SFTP commands (one per line) that should be executed on the server directly after any transfer.

“post_on_301”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 301 response.

“post_on_302”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 302 response.

“post_on_303”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 303 response.

"pre_commands": (Business Edition only) Set to a list of raw FTP/SFTP commands (one per line) that should be executed on the server prior to any transfer.

“proxy_auth_basic”: (Introduced in tsNet version 1.4.0) Set this option to true to force tsNet to use basic authentication when authenticating with a proxy server.

“proxy_auth_digest”: (Introduced in tsNet version 1.4.0) Set this option to true to force tsNet to use digest authentication when authenticating with a proxy server.

"proxy_headers": Set to a list of headers (one per line) that should be sent to any proxy server that is being used.

“proxy_http_10”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to use HTTP/1.0 for any CONNECT tunnelling.

“referer”: (Introduced in tsNet version 1.4.0) The contents of this setting will be used as the HTTP Referer: header sent as part of a HTTP request.

“resolve_hosts”: (Introduced in tsNet version 1.4.0) Specify a list (one per line) of host to IP addresses to use when resolving host name for a request. Each line must be in the format of “HOSTNAME:PORT:ADDRESS”.

“resume_from”: (Introduced in tsNet version 1.4.0) Specify the number of bytes at which you want a transfer to start downloading or uploading.

"save_sent_headers": Set to true to specify that external should store a copy of all the headers that it sends to the server. This must be set to true to use the tsNetRetrSentHeaders function.

“skip_pasv_ip”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to ignore the IP address from the server’s 227 response message. tsNet will connect the data connection via the same IP address it used to set up the control connection.

“ssl_ciphers”: (Introduced in tsNet version 1.4.0) Use this setting to specify a list of SSL ciphers (separated by colons) to be used when negotiating SSL connections.

“ssl_client_cert”: (Introduced in tsNet version 1.4.1) Specify the filename of a client SSL certificate to use for authentication to the server.

“ssl_client_cert_type”: (Introduced in tsNet version 1.4.1) Set to the format of the client SSL certificate. Supported formats are “PEM”, “DER” and “P12”.

“ssl_client_key”: (Introduced in tsNet version 1.4.1) Specify the filename of a SSL private key file that matches the client SSL certificate.

“ssl_client_key_pass”: (Introduced in tsNet version 1.4.1) Set to the password for the SSL private key.

“ssl_client_key_type”: (Introduced in tsNet version 1.4.1) Set to the format of the SSL private key. Supported formats are “PEM” and “DER”.

“ssl_proxy_client_cert”: (Introduced in tsNet version 1.4.1) Specify the filename of a proxy client SSL certificate to use for authentication to the HTTP proxy.

“ssl_proxy_client_cert_type”: (Introduced in tsNet version 1.4.1) Set to the format of the proxy client SSL certificate. Supported formats are “PEM”, “DER” and “P12”.

“ssl_proxy_client_key”: (Introduced in tsNet version 1.4.1) Specify the filename of a SSL private key file that matches the proxy client SSL certificate.

“ssl_proxy_client_key_pass”: (Introduced in tsNet version 1.4.1) Set to the password for the SSL private key.

“ssl_proxy_client_key_type”: (Introduced in tsNet version 1.4.1) Set to the format of the SSL private key. Supported formats are “PEM” and “DER”.

"ssh_host_public_key": Set to the 128 bit MD5 checksum of the remote host's public key. The connection will be rejected unless they match.

"ssh_passphrase": (Business Edition only) Set to the passphrase for any included private key.

"ssh_private_key": (Business Edition only) Set to the private key file (including full system path) to be used in SFTP transfers.

“trace”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to include all inbound and outbound data when using tsNetSetDebugCallback() rather than just header and informational data. When this option is set, a third parameter will be posted to the debug callback function specifying the type of data that is being passed to the callback function.

“transfer_encoding”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to request the response be sent in a compressed Transfer-Encoding (if the server supports it) that will be automatically uncompressed by tsNet when it is received.

“trust_location_auth”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to continue to send authentication details when following any HTTP redirects.

“try_ssl”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to try to connect via SSL. If the connection fails to establish via SSL, connect without using SSL.

“tunnel_http_proxy”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to tunnel all operations (all protocols) through the HTTP proxy.

“use_ascii_transfer”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to use ASCII mode for FTP transfers.

“use_pret”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to send a PRET command before sending PASV/EPSV when performing passive FTP transfers.

"use_ssl": Set to true to connect using Transport Layer Security (TLS) for SMTPS and FTPS (explicit) connections.

"username": Set to a string containing the username to be used in any authentication requests from the server.

“use_ssl_control”: (Introduced in tsNet version 1.4.0) Set this option to true to ensure all control communication is encrypted.

“user_agent”: (Introduced in tsNet version 1.4.0) The contents of this setting will be used as the HTTP User-Agent: header sent as part of a HTTP request.

Function:  tsNetUploadFileSync

 

Send a synchronous upload request to a server which retrieves the data to be sent directly from a file.

tsNetUploadFileSync(<pFile>, <pURL>, <xHeaders>, <rOutHeaders>, <rResult>, <rBytes>, [<pSettings>])

 

Operating Systems supported: Mac OS X, Windows, Linux, iOS and Android

Platforms supported:  Desktop, Server and Mobile

Example:

   local tHeaders, tResultCode, tBytes, tRecvHeaders, tResult
   put tsNetUploadFileSync(“/path/to/upload/file.dat”, \
      “ftp://user:pass@ftp.example.com/file.dat”, tHeaders, \
      tRecvHeaders, tResultCode, tBytes) into tResult

Parameters:

  • pFile: The full path and filename that contains the data to be sent to the server.
  • pURL: The URL formatted as ‘scheme://host:port/path’ and URL-encoded as outlined in [RFC 3986](http://www.ietf.org/rfc/rfc3986.txt). The following schemes are supported: ‘tftp’, ‘ftp’, ‘ftps’, ‘http’, ‘https’ and ‘sftp’. For SFTP connections (Business Edition only), the path is not relative to the user’s home directory, but must be the full system path.
  • xHeaders: For HTTP(s) connections, the headers to be sent to the server. For all other protocols, leave this blank. The contents of this variable will be replaced when the function returns with the headers that were sent to the server if the “save_sent_headers” array setting is specified below.
  • rOutHeaders: This variable will contain the headers that were returned from the server on completion.
  • rResult: This variable will contain the status code sent by the server to the last command that was issued during the transfer. For SFTP connections, this will always be 0. On error, the return value will be a string containing the error starting with “tsneterr:”.
  • rBytes: This variable will contain the number of bytes that were downloaded during the connection.
  • pSettings: An array of additional settings that control how the transfer is initiated.

Returns:

The tsNetUploadFileSync function returns the data retrieved from the server on success.

Description:

The settings array can consist of the following elements (not all of the settings make sense for every possible transfer type): 

"byte_range": (Introduced in tsNet version 1.4.0) Specify the range of data to be downloaded. This can be in the format of “X-Y”, “X-“, “-Y” or “X-Y,N-M” where X, Y, N and M and byte indexes. Some HTTP servers may ignore this request.

"cookie_file": (Introduced in tsNet version 1.4.0) Specify a filename to load cookies from. If this setting is present, the internal cookie engine will be enabled and the cookies stored in the file loaded into the engine.

"cookies": (Introduced in tsNet version 1.4.0) The contents of this setting will be used to set a cookie in a HTTP request. It should be in the format of COOKIE_NAME=COOKIE_CONTENTS. Specify multiple cookies by separating them with a semi-colon. This setting does not enable the internal cookie engine of tsNet.

"cookie_jar": (Introduced in tsNet version 1.4.0) Specify a filename to write all known cookies to. If this setting is present, the internal cookie engine of tsNet will be enabled. Note that this file will only be written to at unspecified times. Use the “cookie_list” setting below to force the file to be updated.

"cookie_list": (Introduced in tsNet version 1.4.0) Set this to a list of cookies (one per line) in Netscape / Mozilla format or regular HTTP (Set-Cookie:) style format to add to the internal cookie engine. There are also several strings that when passed to this setting will perform additional actions. Passing in the string “ALL” will erase all cookies held in memory. “SESS” will erase all session cookies in memory. “FLUSH” will write all cookies stored in memory to the file specified by the “cookie_jar” setting. “RELOAD” will reload all cookies from file specified by “cookie_file”.

"disable_eprt": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from using the EPRT command when performing active FTP transfers.

"disable_epsv": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from using the EPSV command when performing passive FTP transfers.

"dont_modify_path": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from squashing “/../” and “/./” components from the URL path. RFC 3986 specifies that these should be removed.

“enable_tcp_keepalive”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to send TCP keepalive probes.

“expect100_timeout”: (Introduced in tsNet version 1.4.0) Specify the number of milliseconds to wait for a response with a HTTP 100 (Continue) or HTTP 417 (Expectation Failed) status after setting a HTTP request containing an Expect: 100-continue header. The default is 1000ms.

"fail_on_http_error": Set to true to specify that HTTP status codes greater than 400 should be considered an error.

"force_basic_auth": (Introduced in tsNet version 1.3.1) Set to true to force HTTP basic authentication rather than allow tsNet to detect what authentication methods are supported by the server.

"force_digest_auth": (Introduced in tsNet version 1.3.5) Set to true to force HTTP digest authentication rather than allow tsNet to detect what authentication methods are supported by the server.

“ftp_filemethod”: (Introduced in tsNet version 1.4.0) Set this to “nocwd” or “singlecwd” to change the method used by FTP to reach a particular file. Using “nocwd” will ensure all FTP commands use the full path to the file on the server. Using “singlecwd” will make tsNet issue a single CWD command to change to the directory that the file resides in before performing any other action on the file. The default is to issue a CWD command for each path part in the URL prior to performing any other action on the file in accordance with RFC 1738.

“ftp_ssl_ccc”: (Introduced in tsNet version 1.4.0) Set this to “passive” or “active” to disable the SSL/TLS encryption after authenticating with the FTP server. All further communication on the command channel with the FTP server will be unencrypted. Use “passive” to only disable the encryption after the server requests it. Setting this to “active” will initiate the encryption shutdown.

“ftp_user_alt”: (Introduced in tsNet version 1.4.0) Specify an alternate string to use for authentication if the standard FTP username and password negotiation fails.

“if_mod_since”: (Introduced in tsNet version 1.4.0) If the last modified time (in seconds since 1 Jan 1970) of the file is later than this, then download the file.

“if_unmod_since”: (Introduced in tsNet version 1.4.0) If the last modified time (in seconds since 1 Jan 1970) of the file is earlier than this, then download the file.

“ignore_content_length”: (Introduced in tsNet version 1.4.0) Set this option to true to ignore the content length specified in HTTP or FTP transfers. tsNet will complete the download when the server ends the connection.

“interface”: (Introduced in tsNet version 1.4.0) Specify the interface, IP address or host name to be used for the outgoing connection.

“junk_session_cookies”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to ignore all cookies loaded via the “cookie_file” setting that are session cookies.

“keepalive_idle”: (Introduced in tsNet version 1.4.0) When “enable_tcp_keepalive” is set to true, use this setting to specify the number of second to wait while the connection is idle before sending keepalive probes. The default is 60 seconds.

“keepalive_interval”: (Introduced in tsNet version 1.4.0) When “enable_tcp_keepalive” is set to true, use this setting to specify the number of seconds to wait between sending keepalive probes. The default is 60 seconds.

“local_port_range”: (Introduced in tsNet version 1.4.0) Set the number of consecutive ports above the port specified by the “local_port_start” setting to try when finding an available port for a connection.

“local_port_start”: (Introduced in tsNet version 1.4.0) Set the local port number of the socket to be used for the connection. It is recommended to also set “local_port_range” if you use this setting.

“max_file_size”: (Introduced in tsNet version 1.4.0) Specify the maximum size of a file to download. If the file exceeds this value, the transfer will not start. This option has no affect is the file size is not known prior to the download.

“max_recv_speed”: (Introduced in tsNet version 1.4.0) This option specifies the number of bytes per second to limit a download transfer to. Setting this to 0 disables any limiting.

“max_send_speed”: (Introduced in tsNet version 1.4.0) This option specifies the number of bytes per second to limit an upload transfer to. Setting this to 0 disables any limiting.

"no_reuse": Set to true to specify that the connection to the server should be disconnected and not left open for any future connections.

"no_transfer": Set to true to connect to the server but not perform any transfer.

"password": Set to a string containing the password to be used in any authentication requests from the server.

"post_commands": (Business Edition only) Set to a list of raw FTP/SFTP commands (one per line) that should be executed on the server directly after any transfer.

“post_on_301”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 301 response.

“post_on_302”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 302 response.

“post_on_303”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 303 response.

"pre_commands": (Business Edition only) Set to a list of raw FTP/SFTP commands (one per line) that should be executed on the server prior to any transfer.

“proxy_auth_basic”: (Introduced in tsNet version 1.4.0) Set this option to true to force tsNet to use basic authentication when authenticating with a proxy server.

“proxy_auth_digest”: (Introduced in tsNet version 1.4.0) Set this option to true to force tsNet to use digest authentication when authenticating with a proxy server.

"proxy_headers": Set to a list of headers (one per line) that should be sent to any proxy server that is being used.

“proxy_http_10”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to use HTTP/1.0 for any CONNECT tunnelling.

“referer”: (Introduced in tsNet version 1.4.0) The contents of this setting will be used as the HTTP Referer: header sent as part of a HTTP request.

“resolve_hosts”: (Introduced in tsNet version 1.4.0) Specify a list (one per line) of host to IP addresses to use when resolving host name for a request. Each line must be in the format of “HOSTNAME:PORT:ADDRESS”.

“resume_from”: (Introduced in tsNet version 1.4.0) Specify the number of bytes at which you want a transfer to start downloading or uploading.

"save_sent_headers": Set to true to specify that external should store a copy of all the headers that it sends to the server. This must be set to true to use the tsNetRetrSentHeaders function.

“skip_pasv_ip”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to ignore the IP address from the server’s 227 response message. tsNet will connect the data connection via the same IP address it used to set up the control connection.

“ssl_ciphers”: (Introduced in tsNet version 1.4.0) Use this setting to specify a list of SSL ciphers (separated by colons) to be used when negotiating SSL connections.

“ssl_client_cert”: (Introduced in tsNet version 1.4.1) Specify the filename of a client SSL certificate to use for authentication to the server.

“ssl_client_cert_type”: (Introduced in tsNet version 1.4.1) Set to the format of the client SSL certificate. Supported formats are “PEM”, “DER” and “P12”.

“ssl_client_key”: (Introduced in tsNet version 1.4.1) Specify the filename of a SSL private key file that matches the client SSL certificate.

“ssl_client_key_pass”: (Introduced in tsNet version 1.4.1) Set to the password for the SSL private key.

“ssl_client_key_type”: (Introduced in tsNet version 1.4.1) Set to the format of the SSL private key. Supported formats are “PEM” and “DER”.

“ssl_proxy_client_cert”: (Introduced in tsNet version 1.4.1) Specify the filename of a proxy client SSL certificate to use for authentication to the HTTP proxy.

“ssl_proxy_client_cert_type”: (Introduced in tsNet version 1.4.1) Set to the format of the proxy client SSL certificate. Supported formats are “PEM”, “DER” and “P12”.

“ssl_proxy_client_key”: (Introduced in tsNet version 1.4.1) Specify the filename of a SSL private key file that matches the proxy client SSL certificate.

“ssl_proxy_client_key_pass”: (Introduced in tsNet version 1.4.1) Set to the password for the SSL private key.

“ssl_proxy_client_key_type”: (Introduced in tsNet version 1.4.1) Set to the format of the SSL private key. Supported formats are “PEM” and “DER”.

"ssh_host_public_key": Set to the 128 bit MD5 checksum of the remote host's public key. The connection will be rejected unless they match.

"ssh_passphrase": (Business Edition only) Set to the passphrase for any included private key.

"ssh_private_key": (Business Edition only) Set to the private key file (including full system path) to be used in SFTP transfers.

“trace”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to include all inbound and outbound data when using tsNetSetDebugCallback() rather than just header and informational data. When this option is set, a third parameter will be posted to the debug callback function specifying the type of data that is being passed to the callback function.

“transfer_encoding”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to request the response be sent in a compressed Transfer-Encoding (if the server supports it) that will be automatically uncompressed by tsNet when it is received.

“trust_location_auth”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to continue to send authentication details when following any HTTP redirects.

“try_ssl”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to try to connect via SSL. If the connection fails to establish via SSL, connect without using SSL.

“tunnel_http_proxy”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to tunnel all operations (all protocols) through the HTTP proxy.

“use_ascii_transfer”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to use ASCII mode for FTP transfers.

“use_pret”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to send a PRET command before sending PASV/EPSV when performing passive FTP transfers.

"use_ssl": Set to true to connect using Transport Layer Security (TLS) for SMTPS and FTPS (explicit) connections.

"username": Set to a string containing the username to be used in any authentication requests from the server.

“use_ssl_control”: (Introduced in tsNet version 1.4.0) Set this option to true to ensure all control communication is encrypted.

“user_agent”: (Introduced in tsNet version 1.4.0) The contents of this setting will be used as the HTTP User-Agent: header sent as part of a HTTP request.

Function:  tsNetUploadSync

 

Send a synchronous upload request to a server.

tsNetUploadSync(<pURL>, <xHeaders>, <pData>, <rOutHeaders>, <rResult>, <rBytes>, [<pSettings>])

 

Operating Systems supported: Mac OS X, Windows, Linux, iOS and Android

Platforms supported:  Desktop, Server and Mobile

Example:

   local tHeaders, tResult, tBytes, tRecvHeaders, tData, tOutputData
   put specialFolderPath(“documents”) & “/file.dat” into tFilePath
   put URL(“file:” & tFilePath) into tData
   put tsNetUploadSync(“ftp://user:pass@ftp.example.com/dir/file.dat”, \
      tHeaders, tData, tRecvHeaders, tResult, tBytes) into tOutputData

Parameters:

  • pURL: The URL formatted as ‘scheme://host:port/path’ and URL-encoded as outlined in [RFC 3986](http://www.ietf.org/rfc/rfc3986.txt). The following schemes are supported: ‘tftp’, ‘ftp’, ‘ftps’, ‘http’, ‘https’ and ‘sftp’. For SFTP connections, the path is not relative to the user’s home directory, but must be the full system path.
  • xHeaders: For HTTP(s) connections, the headers to be sent to the server. For all other protocols, leave this blank. The contents of this variable will be replaced when the function returns with the headers that were sent to the server if the “save_sent_headers” array setting is specified below.
  • pData: The data that is to be sent to the server.
  • rOutHeaders: This variable will contain the headers that were returned from the server on completion.
  • rResult: This variable will contain the status code sent by the server to the last command that was issued during the transfer. For SFTP connections, this will always be 0. On error, the return value will be a string containing the error starting with “tsneterr:”.
  • rBytes: This variable will contain the number of bytes that were downloaded during the connection.
  • pSettings: An array of additional settings that control how the transfer is initiated.

Returns:

The tsNetUploadSync function returns the data retrieved from the server on success.

Description:

The settings array can consist of the following elements (not all of the settings make sense for every possible transfer type): 

"byte_range": (Introduced in tsNet version 1.4.0) Specify the range of data to be downloaded. This can be in the format of “X-Y”, “X-“, “-Y” or “X-Y,N-M” where X, Y, N and M and byte indexes. Some HTTP servers may ignore this request.

"cookie_file": (Introduced in tsNet version 1.4.0) Specify a filename to load cookies from. If this setting is present, the internal cookie engine will be enabled and the cookies stored in the file loaded into the engine.

"cookies": (Introduced in tsNet version 1.4.0) The contents of this setting will be used to set a cookie in a HTTP request. It should be in the format of COOKIE_NAME=COOKIE_CONTENTS. Specify multiple cookies by separating them with a semi-colon. This setting does not enable the internal cookie engine of tsNet.

"cookie_jar": (Introduced in tsNet version 1.4.0) Specify a filename to write all known cookies to. If this setting is present, the internal cookie engine of tsNet will be enabled. Note that this file will only be written to at unspecified times. Use the “cookie_list” setting below to force the file to be updated.

"cookie_list": (Introduced in tsNet version 1.4.0) Set this to a list of cookies (one per line) in Netscape / Mozilla format or regular HTTP (Set-Cookie:) style format to add to the internal cookie engine. There are also several strings that when passed to this setting will perform additional actions. Passing in the string “ALL” will erase all cookies held in memory. “SESS” will erase all session cookies in memory. “FLUSH” will write all cookies stored in memory to the file specified by the “cookie_jar” setting. “RELOAD” will reload all cookies from file specified by “cookie_file”.

"disable_eprt": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from using the EPRT command when performing active FTP transfers.

"disable_epsv": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from using the EPSV command when performing passive FTP transfers.

"dont_modify_path": (Introduced in tsNet version 1.4.0) Set this option to true to stop tsNet from squashing “/../” and “/./” components from the URL path. RFC 3986 specifies that these should be removed.

“enable_tcp_keepalive”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to send TCP keepalive probes.

“expect100_timeout”: (Introduced in tsNet version 1.4.0) Specify the number of milliseconds to wait for a response with a HTTP 100 (Continue) or HTTP 417 (Expectation Failed) status after setting a HTTP request containing an Expect: 100-continue header. The default is 1000ms.

"fail_on_http_error": Set to true to specify that HTTP status codes greater than 400 should be considered an error.

"force_basic_auth": (Introduced in tsNet version 1.3.1) Set to true to force HTTP basic authentication rather than allow tsNet to detect what authentication methods are supported by the server.

"force_digest_auth": (Introduced in tsNet version 1.3.5) Set to true to force HTTP digest authentication rather than allow tsNet to detect what authentication methods are supported by the server.

“ftp_filemethod”: (Introduced in tsNet version 1.4.0) Set this to “nocwd” or “singlecwd” to change the method used by FTP to reach a particular file. Using “nocwd” will ensure all FTP commands use the full path to the file on the server. Using “singlecwd” will make tsNet issue a single CWD command to change to the directory that the file resides in before performing any other action on the file. The default is to issue a CWD command for each path part in the URL prior to performing any other action on the file in accordance with RFC 1738.

“ftp_ssl_ccc”: (Introduced in tsNet version 1.4.0) Set this to “passive” or “active” to disable the SSL/TLS encryption after authenticating with the FTP server. All further communication on the command channel with the FTP server will be unencrypted. Use “passive” to only disable the encryption after the server requests it. Setting this to “active” will initiate the encryption shutdown.

“ftp_user_alt”: (Introduced in tsNet version 1.4.0) Specify an alternate string to use for authentication if the standard FTP username and password negotiation fails.

“if_mod_since”: (Introduced in tsNet version 1.4.0) If the last modified time (in seconds since 1 Jan 1970) of the file is later than this, then download the file.

“if_unmod_since”: (Introduced in tsNet version 1.4.0) If the last modified time (in seconds since 1 Jan 1970) of the file is earlier than this, then download the file.

“ignore_content_length”: (Introduced in tsNet version 1.4.0) Set this option to true to ignore the content length specified in HTTP or FTP transfers. tsNet will complete the download when the server ends the connection.

“interface”: (Introduced in tsNet version 1.4.0) Specify the interface, IP address or host name to be used for the outgoing connection.

“junk_session_cookies”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to ignore all cookies loaded via the “cookie_file” setting that are session cookies.

“keepalive_idle”: (Introduced in tsNet version 1.4.0) When “enable_tcp_keepalive” is set to true, use this setting to specify the number of second to wait while the connection is idle before sending keepalive probes. The default is 60 seconds.

“keepalive_interval”: (Introduced in tsNet version 1.4.0) When “enable_tcp_keepalive” is set to true, use this setting to specify the number of seconds to wait between sending keepalive probes. The default is 60 seconds.

“local_port_range”: (Introduced in tsNet version 1.4.0) Set the number of consecutive ports above the port specified by the “local_port_start” setting to try when finding an available port for a connection.

“local_port_start”: (Introduced in tsNet version 1.4.0) Set the local port number of the socket to be used for the connection. It is recommended to also set “local_port_range” if you use this setting.

“max_file_size”: (Introduced in tsNet version 1.4.0) Specify the maximum size of a file to download. If the file exceeds this value, the transfer will not start. This option has no affect is the file size is not known prior to the download.

“max_recv_speed”: (Introduced in tsNet version 1.4.0) This option specifies the number of bytes per second to limit a download transfer to. Setting this to 0 disables any limiting.

“max_send_speed”: (Introduced in tsNet version 1.4.0) This option specifies the number of bytes per second to limit an upload transfer to. Setting this to 0 disables any limiting.

"no_reuse": Set to true to specify that the connection to the server should be disconnected and not left open for any future connections.

"no_transfer": Set to true to connect to the server but not perform any transfer.

"password": Set to a string containing the password to be used in any authentication requests from the server.

"post_commands": (Business Edition only) Set to a list of raw FTP/SFTP commands (one per line) that should be executed on the server directly after any transfer.

“post_on_301”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 301 response.

“post_on_302”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 302 response.

“post_on_303”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to not convert POST requests to GET requests after a 303 response.

"pre_commands": (Business Edition only) Set to a list of raw FTP/SFTP commands (one per line) that should be executed on the server prior to any transfer.

“proxy_auth_basic”: (Introduced in tsNet version 1.4.0) Set this option to true to force tsNet to use basic authentication when authenticating with a proxy server.

“proxy_auth_digest”: (Introduced in tsNet version 1.4.0) Set this option to true to force tsNet to use digest authentication when authenticating with a proxy server.

"proxy_headers": Set to a list of headers (one per line) that should be sent to any proxy server that is being used.

“proxy_http_10”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to use HTTP/1.0 for any CONNECT tunnelling.

“referer”: (Introduced in tsNet version 1.4.0) The contents of this setting will be used as the HTTP Referer: header sent as part of a HTTP request.

“resolve_hosts”: (Introduced in tsNet version 1.4.0) Specify a list (one per line) of host to IP addresses to use when resolving host name for a request. Each line must be in the format of “HOSTNAME:PORT:ADDRESS”.

“resume_from”: (Introduced in tsNet version 1.4.0) Specify the number of bytes at which you want a transfer to start downloading or uploading.

"save_sent_headers": Set to true to specify that external should store a copy of all the headers that it sends to the server. This must be set to true to use the tsNetRetrSentHeaders function.

“skip_pasv_ip”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to ignore the IP address from the server’s 227 response message. tsNet will connect the data connection via the same IP address it used to set up the control connection.

“ssl_ciphers”: (Introduced in tsNet version 1.4.0) Use this setting to specify a list of SSL ciphers (separated by colons) to be used when negotiating SSL connections.

“ssl_client_cert”: (Introduced in tsNet version 1.4.1) Specify the filename of a client SSL certificate to use for authentication to the server.

“ssl_client_cert_type”: (Introduced in tsNet version 1.4.1) Set to the format of the client SSL certificate. Supported formats are “PEM”, “DER” and “P12”.

“ssl_client_key”: (Introduced in tsNet version 1.4.1) Specify the filename of a SSL private key file that matches the client SSL certificate.

“ssl_client_key_pass”: (Introduced in tsNet version 1.4.1) Set to the password for the SSL private key.

“ssl_client_key_type”: (Introduced in tsNet version 1.4.1) Set to the format of the SSL private key. Supported formats are “PEM” and “DER”.

“ssl_proxy_client_cert”: (Introduced in tsNet version 1.4.1) Specify the filename of a proxy client SSL certificate to use for authentication to the HTTP proxy.

“ssl_proxy_client_cert_type”: (Introduced in tsNet version 1.4.1) Set to the format of the proxy client SSL certificate. Supported formats are “PEM”, “DER” and “P12”.

“ssl_proxy_client_key”: (Introduced in tsNet version 1.4.1) Specify the filename of a SSL private key file that matches the proxy client SSL certificate.

“ssl_proxy_client_key_pass”: (Introduced in tsNet version 1.4.1) Set to the password for the SSL private key.

“ssl_proxy_client_key_type”: (Introduced in tsNet version 1.4.1) Set to the format of the SSL private key. Supported formats are “PEM” and “DER”.

"ssh_host_public_key": Set to the 128 bit MD5 checksum of the remote host's public key. The connection will be rejected unless they match.

"ssh_passphrase": (Business Edition only) Set to the passphrase for any included private key.

"ssh_private_key": (Business Edition only) Set to the private key file (including full system path) to be used in SFTP transfers.

“trace”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to include all inbound and outbound data when using tsNetSetDebugCallback() rather than just header and informational data. When this option is set, a third parameter will be posted to the debug callback function specifying the type of data that is being passed to the callback function.

“transfer_encoding”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to request the response be sent in a compressed Transfer-Encoding (if the server supports it) that will be automatically uncompressed by tsNet when it is received.

“trust_location_auth”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to continue to send authentication details when following any HTTP redirects.

“try_ssl”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to try to connect via SSL. If the connection fails to establish via SSL, connect without using SSL.

“tunnel_http_proxy”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to tunnel all operations (all protocols) through the HTTP proxy.

“use_ascii_transfer”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to use ASCII mode for FTP transfers.

“use_pret”: (Introduced in tsNet version 1.4.0) Set this option to true to tell tsNet to send a PRET command before sending PASV/EPSV when performing passive FTP transfers.

"use_ssl": Set to true to connect using Transport Layer Security (TLS) for SMTPS and FTPS (explicit) connections.

"username": Set to a string containing the username to be used in any authentication requests from the server.

“use_ssl_control”: (Introduced in tsNet version 1.4.0) Set this option to true to ensure all control communication is encrypted.

“user_agent”: (Introduced in tsNet version 1.4.0) The contents of this setting will be used as the HTTP User-Agent: header sent as part of a HTTP request.