This is a simple function that executes a page request to a remote server and returns a string containing the body of the server response page.
function string ExecRemote(string site_address, string url)
http_header = header("GET " + url + " HTTP/1.1")
page_request = httpPage(http_header, "")
page_response = page_request.Exec(site_address)
The ExecRemote function takes two strings as parameters, containing the site address and the path of the page that should be requested. The latter must always start with the / (slash) character, i.e. must be relative to the site root.
Within the function a header class object is created by passing a string consisting of a request (the actual header is empty) to the class constructor. The request consists in the GET method followed by the path of the page and protocol version.
On the next line an object of the httpPage class is created by passing the newly created header and an empty body to the class constructor. Then the Exec method is called on the object we just created using the site address as parameter.
The function returns the body of the server response page resulting from the call to the Exec method.
An invocation of the ExecRemote function looks like the following:
result = ExecRemote("www.tabasoft.it", "/home.bfr")
The use of this function can be very useful in practice when we have to insert content (news, search forms, marketing polls) originating from another Web site in a box on the home page of our Web site and we do not want to use frames or inline frames (the latter are not supported by all browsers).
In this case the script that implements our home page can execute the remote page of interest and incorporate the result (typically HTML code) in our page. Another scenario is a site distributed across multiple remote machines. In this case the ExecRemote function is a very useful tool to exploit resources on remote computers.