Pi3Web Feature Suite - Flexible CGI

CGI (Common Gateway Interface) is a method used to extend HTTP servers that relies on external scripts or programs. These programs are executed for each request. Data from the client browser is fed into the CGI program and the results from the CGI program are fed back to the browser. Pi3Web has a flexible CGI handler (CGI) that can be configured to handle many different types of CGI.
Return to main features index.

Vanilla CGI

Here's the simplest CGI programs:
URL Action
/cgi-bin/Hello.exe Says hello to the world
/cgi-bin/CheckArg.exe?isindex+check Tests ISINDEX (true)
/cgi-bin/CheckArg.exe?isindex%3dcheck Tests ISINDEX (false)
/cgi-bin/ViewEnv.exe/path_info?query_string View CGI Environment


Return to
CGI index.
Return to main features index.


Non-parsed Headers

Non-parsed headers is a form of CGI where the CGI program takes full responsibility for sending the correst HTTP headers to the browser, although is was originally intented to make transfer of large amounts of data be very efficient by by-passing buffering, Pi3Web does not by-pass buffering. This is because Pi3Web maintains a layer of abstraction from the network level (the Pi3 protocol API), this makes server and CGI operation much more portable to different protocols (other than TCP/IP) and allows secure transports to be seemlessly introduced (such as SSL).

The non-parsed header mechanism is also known as "full response" or "direct return". NPH is a program included with this package to demostrate this server's capabilities of handling non-parsed header CGI programs.

URL Action
/cgi-bin/NPH.exe Describes usage of the CGI program
/cgi-bin/NPH.exe?200 Indicate a normal response
/cgi-bin/NPH.exe?401 Cause a password dialog to appear
/cgi-bin/NPH.exe?0 Really confuse your browser


Return to
CGI index.
Return to main features index.


CGI Redirection

CGI programs can cause the client to be redirected to another location by issueing a redirect response. Redirect is a program included with this package to demostrate CGI redirection.
URL Action
/cgi-bin/Redirect.exe Describes usage of the CGI program
/cgi-bin/Redirect.exe/pidocs/Objects/ Redirect to the index of the Pi3 API specification
/cgi-bin/Redirect.exe/cgi-bin/Redirect.exe CGI attempts to redirect back to itself.


Return to
CGI index.
Return to main features index.


Windows CGI

Standard CGI uses a stdin/stdout and environment based mechanism to communicate with a CGI program, however there are other variants of CGI, notably 'Windows CGI' (see
wincgi). This form of CGI transfers data between the HTTP and CGI program using files. All types of CGI responses (simple, redirection and non-parsed headers) can also be used with the windows CGI mechanism. Although originally intended for windows based programming, there is no overwhelming reason why it cannot be used on other platforms. On non-windows platforms extra programming is required to read data from .ini file format, as the native GetPrivateProfileString() API facility is only available on windows platforms. Refer to the source code for WHello.exe, WHello.c.

The following several programs demostrate the use of windows CGI.

URL Action
/cgi-win/WHello.exe "Hello World!" for windows CGI
/cgi-win/WViewEnv.exe View CGI Environment for Windows CGI


Return to CGI index.
Return to main features index.


CGI POST Method

Test CGI form requests using the POST method.

CGI Form Post Example CGI Form Post Environment Windows CGI Form Post Environment
Enter Value1:
Enter Value2:

Enter Value1:
Enter Value2:

Enter Value1:
Enter Value2:


Return to
CGI index.
Return to main features index.