
![]() |
Home |
Download |
Getting Started |
Contact |
White Paper |
Examples |
Documentation |
Troubleshooting |
Newsgroup |
Mailing List |
Source Code |
Bugs |
Screenshots |
Protozilla Examples
(Note: Many of the non-standard hyperlinks on this page are for illustration only. They will work only if you are using Mozilla with Protozilla installed! To try out these protocols, first initialize Protozilla using the Tasks menu of the browser.)During Protozilla installation, a directory (or folder) named protozilla is created in the user's current profile. Within this directory, two sub-directories named protocol and cgi+ are also created.
The Protozilla configuration window may be loaded from the Tasks menu, or from the command line using the -protozilla option, which are the preferred ways to load it. There are two predefined protocols in Protozilla: protozilla and cgi+. For example, the URI protozilla: will load the Protozilla configuration window. A Protozilla session begins when you first load an URI using any of the protocols registered by Protozilla.
A protocol handler is usually just an executable file in the protocol directory. Defining a new protocol is as simple as creating a file in this directory. You can drag-and-drop the file from the desk to the Protozilla configuration window, or create it in site using the Create option. The protocol name is the filename (excluding any extension). Protocol names consist of a sequence of characters beginning with a lower case letter and followed by any combination of lower case letters, digits, plus ("+"), period ("."), or hyphen ("-") (RFC2396). Protocol names ending in "+" are treated specially by Protozilla, as discussed later.
Protozilla automatically registers all protocols when the Protozilla configuration window is loaded. For example, if the Perl script foo.pl is present in the protocol directory, then the protocol foo: is automatically registered. When an URI using this protocol needs to be loaded, Protozilla executes the script foo.pl, much like a CGI program, and displays the output from the script. The script may output MIME headers to identify the content type as being HTML, XML, XUL etc. If MIME headers are not found, Protozilla attempts to guess the content type from the filename portion of the URL, failing which Protozilla tries to display the output as plain text. (In addition to handling the usual suspects for scripting languages, such as Perl or Python, Protozilla can also execute scripts written in Javascript! Try jsproto:.
Though the protocol handler is usually an executable CGI program, there two special cases:
- A protocol handler with the extension .url is treated as an
"URL re-direction" specifier, rather than an executable program. For
example, a handler named moz.url may contain an
URL prefix, such as http://mozilla.org/. In this case, the URI moz:docs is translated to
http://mozilla.org/docs. The peer-to-peer
freenet protocol
uses a local proxy server accessible on port 8081. To be able to use
freenet: URLs in the browser, all you need to do is to create
a file named freenet.url containing the text
http://localhost:8081/. (Of course, you need to be running the
freenet proxy server as well.)
- A protocol handler named foo may be a directory, rather than a file. In this case, directory foo is expected to contain a file named client.*, where ".*" denotes any extension (or even no extension at all). The client program handles URIs for the protocol. Additionally, directory foo may also contain files with the following names: index.*, server.*, start-server.*, stop-server.*. The index file is the index page for the protocol, typically named index.htm or index.xul. It is loaded when the user types the special URI foo:. The server is a protocol server (a daemon, in Unix terminology) that is started when Protozilla is first activated during the browsing session and killed at the end of the session. Output from the server is displayed in the Protozilla console. (This functionality is somewhat like that provided by daemontools.) start-server and stop-server are programs that are executed at the start and the end of the Protozilla session as detached processes, i.e., their output is not captured.
Protocol names ending in "+" are treated as restricted protocols by Protozilla. URIs using these protocols may only be loaded from scripts with system privileges. They may not be loaded simply by clicking HTML hyperlinks or from unprivileged scripts. An example is the predefined cgi+ protocol described below. (The protocol index page URI, e.g. foo+:, is not subject to these restrictions.)
Files in the cgi+ directory are treated as CGI programs. For example, typing the URL cgi+:/testcgi.pl in the URL box executes the Perl script testcgi.pl in the CGI directory. The query portion of the URL may be used to transmit information to the CGI script, e.g., cgi+:/testcgi.pl?param1=value1¶m2=value2 In addition to the environment variables required by the standard CGI specification, Protozilla defines some additional environment variables. Click cgi+:/testcgi.pl for a list. (At present, the POST method is not implemented in the CGI+ protocol.)
You may simply drag-and-drop a CGI program from the desktop into the CGI+ index page, or use the Copy button in the index page to copy the program to the CGI directory. Error messages (stderr) from the CGI script will appear in the Protozilla console.