[10] [DFN[[CODE(CGI)@en[GATEWAY_INTERFACE]]]] は、[[CGI]] の[[版]]を表す[[メタ変数]]です。
普通、[[CGI/1.1]] を表す値「[CODE(CGI)@en[[[CGI/1.1]]]]」が使われます。

* 仕様書
[REFS[
- [12] [CITE@en[RFC 3875 - The Common Gateway Interface (CGI) Version 1.1]] ([TIME[2011-11-20 06:09:05 +09:00]] 版) <http://tools.ietf.org/html/rfc3875#section-4.1.4>
]REFS]

* 構文

[FIG[
[15] 
[PRE(ABNF code)[
      GATEWAY_INTERFACE = "CGI" "/" 1*digit "." 1*digit
]PRE]
[FIGCAPTION[
[SRC[>>12]]
]FIGCAPTION]
]FIG]

[16] [[整数]]が2つ含まれますが、値の大小はそれぞれの値の大小の組み合わせにより決まります [SRC[>>12]]。
文字列比較による大小とは異なることがあります。

[17] [[先導0]]を[[鯖]]は生成しては[['''なりません''']]が、[[CGIスクリプト]]は無視しなければ[['''なりません''']]。
[SRC[>>12]]

;; [18] 実際には[[CGIスクリプト]]がこの[[メタ変数]]を参照してどうこうするということはないように思います。

* 実際に使われている値

[1]
,[CODE(CGI)[CGI/1.0]],[[CGI/1.0]]
,[CODE(CGI)[CGI/1.1]],"[[CGI/1.1]], [[SSI]], [[w3m]] [[local CGI]]"
,[CODE(CGI)[CGI/1.2 (Win),[[WinCGI]]
,[CODE(CGI)[CGI-Perl/1.1]],[[mod_perl]]
,[CODE(CGI)[CGI-PerlEx]],[[PerlEx]]
,[CODE(CGI)[CGI-Ruby/1.1]],[[mod_ruby]]
,[CODE(CGI)[SIP-CGI/1.1]],SIP-CGI/1.1

[8] PerlEx の書式は仕様書に適合しませんね。

[6] [[Apache]] の実装では、 [[SSI]] でこの変数を参照しても、 SSI から呼んだ CGI script で参照しても, 
[CODE(CGI)[CGI/1.1]] になります。

[2] 
[[CGI]] から派生した [[WSGI]] や [[PSGI]] などは [CODE[GATEWAY_INTERFACE]]
を使っていないため、相当する値はありません。

* 歴史

[5] [NCSA] では、形式を簡単に「CGI/revision」として説明していました。

[FIG(quote)[
[FIGCAPTION[
[13] 6.1.4. GATEWAY_INTERFACE (関門界面) (CGI/1.1 draft 03)
]FIGCAPTION]
>
This metavariable is set to the dialect of CGI being used by
the server to communicate with the script. Syntax:

このメタ変数は、[[鯖]]が[[スクリプト]]と通信するのに使う
CGI の種類に設定されます。構文:

>
[PRE(ABNF code)@en[
    GATEWAY_INTERFACE = "CGI" "/" major "." minor
    major             = 1*digit
    minor             = 1*digit
]PRE]
>
Note that the major and minor numbers are treated as separate
integers and hence each may be more than a single digit. Thus
CGI/2.4 is a lower version than CGI/2.13 which in turn is
lower than CGI/12.3. Leading zeros in either the major or the
minor number MUST be ignored by scripts and SHOULD NOT be
generated by servers.

major (大), minor (小) 番号は別々の整数として扱われるので、
1桁の数以上のものであり得ることに注意して下さい。
ですから CGI/2.4 は CGI/2.13 より小さな版で、 CGI/2.13
は CGI/12.3 より小さな版です。 major・minor 番号の
頭の零を、スクリプトは無視し'''なければなりません'''が、
サーバーは生成する'''べきではありません'''。

>   
This document defines the 1.1 version of the CGI interface ("CGI/1.1").

この文書は CGI 界面の 1.1 版 (「CGI/1.1」) を定義します。

>
Servers MUST provide this metavariable to scripts.

サーバーはこのメタ変数をスクリプトに提供し'''なければなりません'''。   
]FIG]

[FIG(quote)[
[FIGCAPTION[
[14] RFC 3050 (SIP CGI/1.1) 5.5.1.4 GATEWAY_INTERFACE
]FIGCAPTION]

[7]
>This metavariable is set to the dialect of SIP CGI being used by the
server to communicate with the script.  Syntax:

この[[メタ変数]]は、
[[サーバー]]が[[スクリプト]]と通信する
SIP CGI の種類に設定されます。構文:

>
[PRE(ABNF code)[
        GATEWAY_INTERFACE  =  "SIP-CGI" "/" major "." minor
        major              =  1*digit
        minor              =  1*digit
]PRE]
>Note that the major and minor numbers are treated as separate
integers and hence each may be more than a single digit.  Thus SIP-CGI/2.4 is a lower version than SIP-CGI/2.13 which in turn is lower
than SIP-CGI/12.3.  Leading zeros in either the major or the minor
number MUST be ignored by scripts and SHOULD NOT be generated by
servers.

>This document defines the 1.1 version of the SIP CGI interface
("SIP-CGI/1.1").

>Servers MUST provide this metavariable to scripts.

> For maximal compatibility with existing HTTP CGI libraries,
we want to keep this as similar as possible to the syntax
of CGI 1.1.  However, we do want it to be clear that this is
indeed SIP CGI.  Making HTTP CGI's version identifier a
substring of the SIP CGI identifier seemed like a
reasonable compromise. (The existing CGI libraries we
checked do not seem to check the version.)
]FIG]
