Difference between revisions of "CGI, FastCGI, SCGI, WSGI, servlets and such"

From Helpful
Jump to: navigation, search
m (FastCGI and SCGI)
m (Others/Unsorted)
Line 132: Line 132:
 
* Java servlet API
 
* Java servlet API
  
* NSAPI (Netscape Server API): No formal standard, not too common.
+
* NSAPI (Netscape Server API): No formal standard, not very common.
  
 
* [http://www.w3.org/TR/WD-ilu-requestor ILU Requester]
 
* [http://www.w3.org/TR/WD-ilu-requestor ILU Requester]

Revision as of 17:40, 7 June 2011

These are primarily notes
It won't be complete in any sense.
It exists to contain fragments of useful information.

CGI

CGI (Common Gateway Interface) refers to a basic standardization to the input and output of a process that serves a HTTP request, mostly used by web servers to run an external programs.

It is now somewhat dated, but still arguably useful for minimal implementations, such as embedded devices.

See also:


Things newer than CGI (see below) often have code loaded into a webserver, to offload a bunch of basic parsing, the sending work (particularly HTTP 1.1 fanciness like chunked transfers) and other responsibilities. I would guess there are few CGI apps that really conform to HTTP 1.1. Entangling with a web server makes that easier, and allows some things (e.g. persistent interpreter, worker pools, and such) that lower the response latency and scale a little better than just starting a new process for each request.


CGI/HTTP/Environment variables

This article/section is a stub — probably a pile of half-sorted notes, is not well-checked so may have incorrect bits. (Feel free to ignore, fix, or tell me)

The canonical set defined by CGI 1.1 (see RFC 3875) are:

  • REQUEST_METHOD (values such as "GET", "POST", "HEAD", etc. )
  • QUERY_STRING
  • SCRIPT_NAME
  • PATH_INFO
  • PATH_TRANSLATED - local path after any applicable virtual-to-physical translation
  • SERVER_NAME
  • SERVER_PORT
  • CONTENT_LENGTH (of request)
  • CONTENT_TYPE (of request)
  • REMOTE_ADDR
  • REMOTE_HOST
  • AUTH_TYPE ("Basic" or "Digest", if used)
  • REMOTE_IDENT (see RFC 1413)
  • REMOTE_USER (as part of auth)
  • GATEWAY_INTERFACE - version of CGI, e.g. "CGI 1.1"
  • SERVER_PROTOCOL
  • SERVER_SOFTWARE

You'll also frequently see these in post-CGI things, largely because they're a settled, standard way of communicating basic things interesting to apps.


You may also see:

  • extension meta-variables - which should be prefixed with X_
  • Protocol-Specific Meta-Variables, for example:
    • Specific servers may set some HTTP_... variables with content copied from HTTP headers, such as:
      • HTTP_HOST
      • HTTP_REFERER
      • HTTP_USER_AGENT
      • HTTP_ACCEPT
      • HTTP_COOKIE
      • ...and others
    • When SSL is used you'll see often see:
      • HTTPS (set, and often with value 'on') if used
      • SSL_* - quite a few, depending a little on the context/implementation (see e.g. [1])

FastCGI and SCGI

FastCGI most broadly refers to the concept of running a persistent process to handle many requests over its lifetime, avoiding the process startup overhead that basic CGI implies.

FastCGI and SCGI are protocols to communicate to such servers; SCGI (Simple CGI) is an alternative to FastCGI for which the protocol is a little easier to implement.


Notes:

  • It is fairly easy to make many public-facing web servers gateways to your internal SCGI and FastCGI apps. For example, apache has mod_scgi, mod_fastcgi.
  • Such a gateway can be a nice and flexible way
    • to apply per-app or per-process security policies - and separate them
    • to do SSL in one spot
    • potentially to load-balance


See also:

WSGI

This article/section is a stub — probably a pile of half-sorted notes, is not well-checked so may have incorrect bits. (Feel free to ignore, fix, or tell me)

WSGI (Web Server Gateway Interface) is a callback-based API for Python web apps, which eases application hosting and wrapping.

Comparable to various APIs in other languages.

See Python notes - WSGI for more detail

AJP

This article/section is a stub — probably a pile of half-sorted notes, is not well-checked so may have incorrect bits. (Feel free to ignore, fix, or tell me)

AJP (Apache JServ Protocol) seems to be a simple and fast binary protocol, which makes it play in the same area as FastCGI, and has functionality similar to WSGI.

It is used in Tomcat, Jetty, and more. See also Java notes#Servlets_and_such

Some non-servlet and non-Java things speak the protocol too, for more cross-service pluggability. This also makes it useful in FastCGI sorts of ways.

Others/Unsorted

  • Apache API
  • ISAPI (Internet Server API), mostly library loading (so comparable to CGI without the process start overhead)
  • Java servlet API
  • NSAPI (Netscape Server API): No formal standard, not very common.
  • Oracle's WRB
  • SAPI Spyglass Server API