HTTPSetProxyServer

Command group Flag affected Reversible Execute on client Platform(s)
External commands YES NO NO All

Syntax

HTTPSetProxyServer ([hostname,service|port,secure {Default kFalse},verify {Default kTrue}]) Returns status

Description

Note: The flag is set according to whether Omnis was able to make a call to this external command.

This Web command is multi-threaded, allowing another thread to execute in the multi-threaded server while it runs. Note that the same socket cannot safely be used concurrently by more than one thread.

HTTPSetProxyServer sets the server to which the HTTPGet, HTTPPage and HTTPPost commands connect; the proxy server then requests the URI from the original server (either directly, or via another proxy server). Before HTTPSetProxyServer has been called, the commands connect directly to the server for the URI. After setting a proxy server, you can revert to direct connections, by calling HTTPSetProxyServer with empty parameters.

Note: There is only a single proxy server setting for the Omnis environment, meaning that it is shared by all threads in the multi-threaded server.

Hostname is a Character field containing the hostname or IP address of the HTTP proxy server. For example:

www.myhost.com or 255.255.255.254

Service|Port is an optional parameter that specifies the service name or port number of the proxy server. If you specify a service name, the lookup for the port number occurs locally. If you omit this argument, it defaults to 80 or 443, the default port for HTTP or HTTPS respectively (depending on the value of Secure).

Secure is an optional Boolean parameter which indicates if a secure connection is required to the server. Pass kTrue for a secure connection, in which case the built-in security technology will be used, so on Windows ‘Secure Channel’ (Schannel) is used, on macOS ‘Secure Transport’ is used, and on Linux OpenSSL is used.

Verify is an optional Boolean parameter which is only significant when Secure is not kFalse. When Verify is kTrue, the command instructs the installed SSL library to verify the server's identity using its certificate; if the verification fails, then the connection will not be established. You can pass Verify as kFalse, to turn off this verification; in this case, the connection will still be encrypted, but there is a chance the server is an impostor. In order to perform the verification, the installed SSL library uses the Certificate Authority Certificates in the cacerts sub-folder of the secure folder in the Omnis folder. If you use your own Certificate Authority to self-sign certificates, you can place its certificate in the cacerts folder, and the installed SSL library will use it after you restart Omnis.

The command returns an integer status, which is less than zero if an error occurs. Possible error codes are listed in the Web Command Error Codes Appendix.

Example

; All requests to HTTPGet, HTTPPost and HTTPPage connect to this proxy server
Calculate lHostName as "my.proxy.com"
Calculate lPort as "8080"
HTTPSetProxyServer (lHostName,lPort)
; Clear the proxy server settings, so HTTPGet, HTTPPost and HTTPPage connect directly to the server for the requested URI
HTTPSetProxyServer