|Top Previous Next|
The sock object can function as a HTTP server. This means that when certain conditions are met, individual sockets will switch into the HTTP mode and output the data in a style, consistent with the HTTP server functionality.
Certain BASIC information about the HTTP server has already been provided in WORKING WITH HTML.
When the socket is in the HTTP mode your program has no control over the received data (HTTP requests) and only sometimes has control over the transmitted data (HTTP reply).
In the simplest case the file returned to the web browser is static- a "fixed" HTML page, a graphic, or some other file. Processing of such a static file requires no intervention from your program whatsoever. Just setup the socket(s) to be able to accept HTTP requests and the sock object will take care of the rest.
More often than not, however, you have to create a dynamic HTML page. Dynamic pages include fragments of BASIC code. When the sock object encounters such a fragment in the file being sent to the browser, it executes the code. This code, in turn, performs some action, for example, generates and sends some dynamic data to the browser or jumps to the other place in the HTML file.
The HTTP server built into the sock object understands two request types- GET and POST. Both can carry "HTTP variables" that the server will extract and pass to the BASIC code.
Supported content (file) types
At the moment, the following file extensions (types) are explicitly supported:
HTML files may include executable Tibbo BASIC or Tibbo C code. This allows to create dynamic HTML output.
All other file types are always static and are sent to the browser "as is". There is, however, a method of programmatic generation of such files — see URL Substitution.
Some file types are only supported on 32-bit platforms. Platform type is listed on each platform's page.
File compression (32-bit platforms only)
On 32-bit platforms, files of all types except HTML can be attached to the project in .gz (compressed) form.
For example, rather then attaching picture.jpg you can compress this file and attach picture.jpg.gz. TiOS webserver will handle this correctly:
Whenever a browser requests picture.jpg, the server will first look for this file and, if not found, will also look for picture.jpg.gz. If the latter is found, the browser will output this file with "Content-Encoding: gzip" in the reply header.
Compressed HTML files are not supported. This is because HTML files can potentially include executable Tibbo BASIC or Tibbo C code. Therefore, TiOS must store such files in their original, uncompressed, form.