PGI: Porthole Gateway Interface

PGI Spec: Naming, Case-Folding and Escaping

Introduction

PGI uses a number of name spaces, which must be managed, and has a number of escaping conventions which should be described carefully. This document covers those two topics.

Methods of Escaping

Line Escape

Definition: Line escape consists of key-value pairs. They are emitted in blocks comprising a set of key/values. Keys are constrained in their contents. They may contain alphanumerics, digits, minus and underscore. The key is transmitted first, followed by a colon, then any number of SPC or HT. Text after this is the value. The value is terminated by CRLF, though a receiver must accept CR or LF as terminating too. CR/LF and NUL may not occur in the value. Values which may contain these characters or significant leading/trailing/multiple SPC or HT will be specified as additionally url-escaped.

A CRLF CR or LF may occur at any point. If followed by one or more SPC or HT, all these characters are discarded, and the value continues. If it is followed by another CR LF or CRLF, then this marks the block end. Otherwise it marks the end of this pair.

Uses: Line escape is used on stdin/stdout, it forms a single block which never terminates. There should be a flush at least after each key/value pair. In PGI modes where the environment is sent on stdin, a single header block represents the transmission of the environment. After exactly content-length bytes, the system reverts to header mode for the next request. stdout uses this escaping system for output to the assembler.

URL Escape

Definition: URL escaping is used throughout PGI, not only in URLs. Its definition is specific. Any character other than alphanumerics, minus or underscore must be escaped with a two digit hex code follwoing a PERCENT. Decoders may accept other carachters as valid. Encoding is byte-literal, without reference to a character set.

Uses: The Pgi-Request: environment variable is URL escaped, as are values in telegraphics (after stratum specs), and lifetime list values.

Unescapable keys

Keys in line escape environments, preferons, product keys, PGI IDs, and in arguments are unescapable. They can contain only alphanumerics, minus and underscore.

Methods of Case-folding

Case folding is the process of reducing a form with variant representaions, such as case-insensitivity into a canonical form.

Key-Folding

Keys are case insensitive, and they do not distinguish minus from underscore. The canonical form uses lower-case and minus. All unescapable keys are case-folded, as are values of the PGI_REVISION environment variable, the will and wont responses of mode negotiation, pgi-*-status responses, telegraphics stratum names, preferons, product prefixes, lifetime list keys and atom names.

stdin/stdout communication

Different namespaces cover requests and responses. Headers beginning X- can be used for experimentation.

Requests

KeyDefined inValue escaping
pgi-modespec1key-folded
pgi-telegram-setspec2URL escaped after stratum spec
pgi-telegram-getspec2URL escaped after stratum spec
pgi-telegram-delspec2URL escaped after stratum spec

Responses

KeyDefined inValue escaping
pgi-mode-statusspec1key-folded
pgi-telegram-set-statusspec2none
pgi-telegram-get-statusspec2none
pgi-telegram-del-statusspec2none
pgi-telegram-get-valuespec2url-escaped

Output Headers

These headers occupy the same space as claimed by both HTTP and CGI. Future headers may be defined by future revisions of this standard. Headers beginning X- are reserved for experimentation.
KeyDefined inValue escaping
burst spec2 none
session spec2 none
preferon-set spec3 none
preferon-add spec3 none
preferon-remove spec3 none
sales-line spec3 none
various CGI and HTTP none

Environment

The environment key namespace should only be expanded by future revisions of this specification apart from those beginning X_ which may be used for experementaion and extensions.
KeyDefined inValue escaping
variousCGI as modified by PGI in spec1none
pgi-revisionspec1key-folded
pgi-requestspec1url-escaped
pgi-fontedspec2none
pgi-get-salesspec3none
pgi-preferonsspec3none
pgi-productspec3none

Request Key/Value pairs

Request key value pairs are arguments, with the addition of further values to specify the reuqest. All these begin pgi- which is prohibited as a prefix in arguments.
KeyDefined inValue escaping
pgi-pathspec1All values are URL encoded
pgi-keyspec1
pgi-idspec1

Inclusion and Arguments

Arguments can be any key-value, excluding those beginning pgi-. The pgi-name argument in HTML inclusion specifies the name of the included portlet. A namespace-partitioning scheme is established to allow the division of argument space amongst applications. Agruments containing at least two hyphens are managed by this convention, other arguments are local in scope. Preceding the first hyphen is a name coding a naming authority. Between the two hyphens is a name corresponding to a project, after is freeform.

Naming Authorities

PrefixAllocation
pgireserved
xExperimental/Local
othersCurrently unallocated

HTML Parameters

Parameters beginning _pgi_ are reserved, PGI applications should avoid using them.
ParameterAllocation
_pgi_frontedFronting (see spec2)
othersCurrently unused

Telegraphics Strata

Strata are key-folded.
NameStratum
scope-globalFirst
scope-sessionFirst
scope-requestFirst
nest-allSecond
nest-onlySecond
porthole-thisThird
porthole-allThird

Interoperation with Arguments/Telegraphics

Telegraphics notionally occupy the same namespace as arguments, and use the same namespace-partitioning system. Porthole names for paths are also conventional, if they contain a single hyphen.
PrefixUse
rRelationships
xExperimental/Local
othersCurrently unallocated

The relationships namespace is used to denote nesting in pre-established ways. It is defined below, and may be extended.
NameApplication
r-mainPrincipal inner porthole which this outer porthole surrounds in ephemora.
othersCurrently unallocated

Preferons

Preferons with two or more hyphens operate in a de facto managed namespace. Before the first hyphen, the managed namespace to be used is specified, followed by the base name of the preferon. Following the hyphen is a value field which is open to user indexes.

The following namespaces are defined.
PrefixUse
gGeneric preferons, common in web-applications.
xLocal/experimental use
othersCurrently unallocated

The following is the current contents of the generic preferons.
PrefixApplication
g-user-User ID
g-class-Member of user class
g-skin-Skin/Appearance chosen by user
g-mode-Website 'mode' (eg edit/view/minimal, etc)
othersCurrently unallocated

Product Prefixes

Product prefixes have a managed filespace for common classes of product, though products may well find few advantages to using them, it can do no harm, particularly as the future of the PGI spec is unknown, and it will help debugging programmers, and those who use product inputs and library code for scripts. A single hyphen is used in managed products. A managed space within this system is provided as an alternative to hyphenless product prefixes.
PrefixApplication
gGeneric product prefixes, common in web-applications.
uUser prefixes, unmanaged.
xLocal/experimental use
othersCurrently unallocated

The following is the current contents of the generic product prefixes.
PrefixApplication
g-forbiddenPage indicating permission denied
g-viewView mode product (usual pages)
g-editEdit/Admin mode product
g-error-*Error page of some type

Lifetime List

Keys in lifetime lists are defined in this specification. Those beginning X- are reserved for experimentation or local use. They are defined in spec3. Values are url-escaped. Currently defined keys are as follows.
KeyValue Type
not-used-fortime string
last-checkedtime string
check-filefile path
x-*local/experimental use
othersCurrently unallocated

Predicate Atoms

Predicate atoms are key-folded. They are defined below, those beginning x are available for local/experimental use.
Predicate Summary Arguments
ttruenone
ffalsenone
prpreferonpreferon name
pipathinfopathinfo name
kpkey presencekey name
kvkey valuekey name,key value
aparg presencearg name
avarg valuearg name,arg value


main spec page | Basic Spec (spec1) | Fronting, Bursting and Telegraphics (spec 2) | Caching (spec 3) | Naming (spec 4)

This project was executed as an infrastructure component of an EPSRC CTA award at CARET.