Chinaunix首页 | 论坛 | 博客
  • 博客访问: 508823
  • 博文数量: 130
  • 博客积分: 10060
  • 博客等级: 上将
  • 技术积分: 1720
  • 用 户 组: 普通用户
  • 注册时间: 2007-12-21 12:35
文章分类

全部博文(130)

文章存档

2011年(2)

2010年(9)

2009年(41)

2008年(78)

我的朋友

分类: 系统运维

2008-09-30 15:17:18

SCGI: A Simple Common Gateway Interface alternative
SCGI:另一个简单的公共网关接口

Neil Schemenauer
2008-06-23

1. Introduction
1. 介绍

    The SCGI protocol is a replacement for the Common Gateway Interface
    (CGI) protocol.  It is a standard for applications to interface with
    HTTP servers.  It is similar to FastCGI but is designed to be easier
    to implement.

    SCGI协议是公共网关接口(CGI)协议的一个替代品。
    它是应用接合HTTP服务器的规范。它与FastCGI相似,但是预定更容易实现。

    In this document, a string of 8-bit bytes may be written in two
    different forms: as a series of hexadecimal numbers between angle
    brackets, or as a sequence of ASCII characters between double quotes.
    For example, <68 65 6c 6c 6f 20 77 6f 72 6c 64 21> is a string of
    length 12; it is the same as the string "hello world!". Note that
    these notations are part of this document, not part of the protocol.

    在本文档中,8位字节组成的字符串可写为两种不同的形式:
    作为尖括号中的一串十六进制数,或者作为双引号中的一系列ASCII字符。
    例如,<68 65 6c 6c 6f 20 77 6f 72 6c 64 21>是长度为12的字符串;
    它与字符串"hello world!"是一样的。
    注意,这些符号是本文档的部件,不是协议的部件。


2. Protocol
2. 协议

    The client connects to a SCGI server over a reliable stream protocol
    allowing transmission of 8-bit bytes.  The client begins by sending a
    request.  See section 3 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.

    客户端通过一个允许8位字节传输的可靠流协议连接SCGI服务器。
    客户端通过发送一个请求开始。请求的格式见第3节。
    当SCGI服务器看到请求的结尾,它发回一个响应并关闭连接。
    本协议未规定响应的格式。


3. Request Format
3. 请求格式

    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 a nonempty
    sequence of ASCII digits giving the of the body length 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 variables should be provided as
    SCGI headers.  

    报头中不允许重复命名。首个报头必须名为"CONTENT_LENGTH",
    且其值为非空的ASCII数字序列,以十进制数形式给出了报文主体的长度。
    "CONTENT_LENGTH"报头必须总是存在,即使其值为"0"。
    同时必须始终有名为"SCGI"且值为"1"的报头。
    为了便于从CGI的迁移,标准CGI环境变量应该作为SCGI报头提供。

    The headers are sent encoded as a netstring.  Netstring encoding is
    explained in section 4.  The body is sent following the headers and
    its length is specified by the "CONTENT_LENGTH" header.

    报头被编码为一个netstring再发送。netstring编码方式在第4节说明。
    报文主体在报头之后发送,其长度由"CONTENT_LENGTH"报头指定。


4. Netstrings

    Any string of 8-bit bytes may be encoded as [len]":"[string]",".  Here
    [string] is the string and [len] is a nonempty sequence of ASCII
    digits giving the length of [string] in decimal. The ASCII digits are
    <30> for 0, <31> for 1, and so on up through <39> for 9. Extra zeros
    at the front of [len] are prohibited: [len] begins with <30> exactly
    when [string] is empty.

    任何8位字节的字符串可被编码为[len]":"[string]","。
    此处的[string]是字符串,[len]是非空的ASCII数字序列,
    以十进制数形式给出[string]的长度。这些ASCII数字为:
    <30>表示0,<31>表示1,等等直至<39>表示9。
    禁止在[len]开头出现额外的0:仅当[string]为空时,[len]以<30>开始。

    For example, the string "hello world!" is encoded as <31 32 3a 68 65
    6c 6c 6f 20 77 6f 72 6c 64 21 2c>, i.e., "12:hello world!,". The empty
    string is encoded as "0:,".

    例如,字符串"hello world!"被编码为
    <31 32 3a 68 65 6c 6c 6f 20 77 6f 72 6c 64 21 2c>,
    也就是"12:hello world!,"。空字符串被编码为"0:,"。

    [len]":"[string]"," is called a netstring. [string] is called the
    interpretation of the netstring.

    [len]":"[string]","称为一个netstring。[string]称为netstring的解释。


5. Example
5. 实例

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

    web服务器(一个SCGI客户端)打开一个连接,发送下面字符串的拼接:

        "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 SCGI server sends the following response:

    SCGI服务器发送下面的响应:

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

    The SCGI server closes the connection.

    SCGI服务器关闭连接。


6. Copyright
6. 版权

     This document has been placed in the public domain.

     本文档无版权限制。


/* vim: set ai tw=74 et sw=4 sts=4: */

阅读(1651) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~