Simple Common Gateway Interface
Encyclopedia
The Simple Common Gateway Interface (SCGI) is a protocol for applications to interface with HTTP
Hypertext Transfer Protocol
The Hypertext Transfer Protocol is a networking protocol for distributed, collaborative, hypermedia information systems. HTTP is the foundation of data communication for the World Wide Web....

 servers, as an alternative to the CGI
Common Gateway Interface
The Common Gateway Interface is a standard method for web servers software to delegate the generation of web pages to executable files...

 protocol. It is similar to FastCGI
FastCGI
FastCGI is a protocol for interfacing interactive programs with a web server. FastCGI is a variation on the earlier Common Gateway Interface ; FastCGI's main aim is to reduce the overhead associated with interfacing the web server and CGI programs, allowing a server to handle more web page...

 but is designed to be easier to implement.

The specification document was placed in the public domain by Neil Schemenauer on 12 January 2006.

Specification

The client connects to an SCGI server over a reliable stream protocol allowing transmission of 8-bit bytes. The client begins by sending a request. See below for the format of the request. When the SCGI server sees the end of the request it sends back a response and closes the connection. The format of the response is not specified by this protocol.

Request format

A request consists of a number of headers and a body. The format of the headers is:

headers ::= header*
header ::= name NUL value NUL
name ::= notnull+
value ::= notnull*
notnull ::= <01> | <02> | <03> | … |
NUL = <00>

Duplicate names are not allowed in the headers. The first header must have the name "CONTENT_LENGTH" and a value that is the length of the body in decimal. The "CONTENT_LENGTH" header must always be present, even if its value is "0". There must also always be a header with the name "SCGI" and a value of "1". In order to facilitate the transition from CGI, standard CGI environment variable
Environment variable
Environment variables are a set of dynamic named values that can affect the way running processes will behave on a computer.They can be said in some sense to create the operating environment in which a process runs...

s should be provided as SCGI headers.

The headers are sent to the server application encoded as a netstring
Netstrings
In computer programming, a netstring is a formatting method for byte strings that uses a declarative notation to indicate the size of the string...

. The body is sent following the headers and its length is specified by the "CONTENT_LENGTH" header.

Example

The web server (an SCGI client) opens a connection and sends the concatenation of the following strings:

"70:"
"CONTENT_LENGTH" <00> "27" <00>
"SCGI" <00> "1" <00>
"REQUEST_METHOD" <00> "POST" <00>
"REQUEST_URI" <00> "/deepthought" <00>
","
"What is the answer to life?"

The web application (SCGI server) sends the following response:

"Status: 200 OK" <0d 0a>
"Content-Type: text/plain" <0d 0a>
"" <0d 0a>
"42"

The SCGI server then closes the connection.

Web servers that implement SCGI

  • Apache HTTP Server
    Apache HTTP Server
    The Apache HTTP Server, commonly referred to as Apache , is web server software notable for playing a key role in the initial growth of the World Wide Web. In 2009 it became the first web server software to surpass the 100 million website milestone...

  • Lighttpd
    Lighttpd
    lighttpd is an open-source web server more optimized for speed-critical environments than common products while remaining standards-compliant, secure and flexible...

  • Cherokee
    Cherokee (Webserver)
    Cherokee is an open-source Cross-platform Web server that runs on Linux, BSD variants, Solaris, Mac OS X, and Microsoft Windows. It is a lightweight, high-performance Web Server/reverse proxy licensed under the GNU General Public License. Its goal is to be fast and fully functional yet still light...

  • Mathopd - with unofficial patch
  • nginx
    Nginx
    nginx is a Web server and a reverse proxy server for HTTP, SMTP, POP3 and IMAP protocols, with a strong focus on high concurrency, performance and low memory usage. It is licensed under a BSD-like license and it runs on Unix, Linux, BSD variants, Mac OS X, Solaris, and Microsoft Windows.- Overview...

     (third party module with partial support or module in 0.8.42+)
  • Microsoft Internet Information Services
    Internet Information Services
    Internet Information Services – formerly called Internet Information Server – is a web server application and set of feature extension modules created by Microsoft for use with Microsoft Windows. It is the most used web server after Apache HTTP Server. IIS 7.5 supports HTTP, HTTPS,...

     with ISAPI SCGI extension
  • http://www.myserverproject.net

Language bindings for the SCGI API

  • Cobra
    Cobra (programming language from Cobra Language LLC)
    Cobra is an object-oriented programming language produced by Cobra Language LLC. Cobra is designed by Chuck Esterbrook, and runs on the Microsoft .NET and Mono platforms. It is strongly influenced by Python, C#, Eiffel, Objective-C, and other programming languages. It supports both static and...

  • Haskell
    Haskell (programming language)
    Haskell is a standardized, general-purpose purely functional programming language, with non-strict semantics and strong static typing. It is named after logician Haskell Curry. In Haskell, "a function is a first-class citizen" of the programming language. As a functional programming language, the...

  • Java
    Java (programming language)
    Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities...

  • Lisp
  • Perl
    Perl
    Perl is a high-level, general-purpose, interpreted, dynamic programming language. Perl was originally developed by Larry Wall in 1987 as a general-purpose Unix scripting language to make report processing easier. Since then, it has undergone many changes and revisions and become widely popular...

    , with the SCGI Package
  • PHP
    PHP
    PHP is a general-purpose server-side scripting language originally designed for web development to produce dynamic web pages. For this purpose, PHP code is embedded into the HTML source document and interpreted by a web server with a PHP processor module, which generates the web page document...

  • Python
    Python (programming language)
    Python is a general-purpose, high-level programming language whose design philosophy emphasizes code readability. Python claims to "[combine] remarkable power with very clear syntax", and its standard library is large and comprehensive...

  • Ruby
    Ruby (programming language)
    Ruby is a dynamic, reflective, general-purpose object-oriented programming language that combines syntax inspired by Perl with Smalltalk-like features. Ruby originated in Japan during the mid-1990s and was first developed and designed by Yukihiro "Matz" Matsumoto...

  • Tcl
    Tcl
    Tcl is a scripting language created by John Ousterhout. Originally "born out of frustration", according to the author, with programmers devising their own languages intended to be embedded into applications, Tcl gained acceptance on its own...


See also

  • Rack
    Rack (web server interface)
    Rack provides a minimal, modular and adaptable interface for developing web applications in Ruby. By wrapping HTTP requests and responses in the simplest way possible, it unifies and distills the API for web servers, web frameworks, and software in between into a single method call.Rack is...

     - Ruby
    Ruby (programming language)
    Ruby is a dynamic, reflective, general-purpose object-oriented programming language that combines syntax inspired by Perl with Smalltalk-like features. Ruby originated in Japan during the mid-1990s and was first developed and designed by Yukihiro "Matz" Matsumoto...

     web server interface
  • PSGI
    PSGI
    PSGI or Perl Web Server Gateway Interface is an interface between Web servers and Perl-based Web applications and frameworks that allows writing portable applications that can be run as standalone servers or using CGI, FastCGI, mod_perl, et al...

     - Perl
    Perl
    Perl is a high-level, general-purpose, interpreted, dynamic programming language. Perl was originally developed by Larry Wall in 1987 as a general-purpose Unix scripting language to make report processing easier. Since then, it has undergone many changes and revisions and become widely popular...

     Web Server Gateway Interface
  • Web Server Gateway Interface - WSGI

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK