[14] [DFN[[RUBYB[[[臨時応答]]]@en[adhoc response]]]]は、[[透過内容折衝]]を正しく扱えない[[クライアント]]に向けた特別な[[応答]]です。

* 仕様書

[REFS[
- [4] [CITE@en[RFC 2295 - Transparent Content Negotiation in HTTP]] ([TIME[2014-08-31 19:36:42 +09:00]] 版) <http://tools.ietf.org/html/rfc2295#page-8>
- [6] [CITE@en[RFC 2295 - Transparent Content Negotiation in HTTP]] ([TIME[2014-08-31 19:36:42 +09:00]] 版) <http://tools.ietf.org/html/rfc2295#section-8.5>
- [7] '''[CITE@en[RFC 2295 - Transparent Content Negotiation in HTTP]] ([TIME[2014-08-31 19:36:42 +09:00]] 版) <http://tools.ietf.org/html/rfc2295#section-10.3>'''
]REFS]

* 構文

[9] [[臨時応答]]は [CODE(HTTP)@en[[[TCN:]] [DFN[[[adhoc]]]]]]
を含まなければ[['''なりません''']] [SRC[>>7]]。

[10] [[臨時応答]]は、[[キャッシュ可能]]な場合には 
[CODE(HTTP)@en[[[Vary:]]]] [[ヘッダー]]を含まなければ[['''なりません''']] [SRC[>>7]]。
これは通常の[[キャッシュ串]]が適切に取り扱えるようなものとする[['''べき''']]で、
[CODE(HTTP)@en[[[Vary:]] [[*]]]] でも構いませんし、より詳細なものでも構いません [SRC[>>7]]。

[11] [[臨時応答]]は[[折衝可能資源]]に束縛された [CODE(HTTP)@en[[[Alternates:]]]]
[[ヘッダー]]を含んで構いません [SRC[>>7]]。

* 文脈

[8] [[臨時応答]]は、[[リスト応答]]や[[選択応答]]では[[透過内容折衝]]に対応しない、
あるいは不具合のある[[クライアント]]と互換性が無くなってしまう場合に送ることができるものです
[SRC[>>7, >>4]]。

[EG[
[13] 例えば[[選択応答]]が [CODE(HTTP)@en[[[Location:]]]] と
[CODE(HTTP)@en[[[Content-Location:]]]] の両方を含む [CODE(HTTP)[[[302]]]]
[[応答]]となるような場合、両[[ヘッダー]]があると誤動作する[[利用者エージェント]]があるなら、
[CODE(HTTP)@en[[[Location:]]]] のみを含めた[[臨時応答]]を返すことができます。 [SRC[>>7]]
]EG]

;; [15] [[透過的折衝可能資源]]も参照。

* 処理モデル

[12] [[臨時応答]]は、[[状態符号]]その他に依存して[[キャッシュ可能]]です [SRC[>>7]]。

* 歴史

[FIG(quote)[
[FIGCAPTION[
[1] [[RFC 2295]] 2.2 抜粋
]FIGCAPTION]
>
:adhoc response:
An adhoc response can be sent by an origin server as an extreme
measure, to achieve compatibility with a non-negotiating or buggy
client if this compatibility cannot be achieved by sending a list
or choice response.  There are very little requirements on the
contents of an adhoc response.  Adhoc responses are defined in section 10.3.

>
[[起源サーバー]]は、[[目録応答]]や[[選択応答]]を送ることで[[折衝]]しない[[クライアント]]や蝕んだクライアントとの互換を達成できないときに、
この互換のために最後の手段として[DFN[臨時応答]]を送ることができます。
臨時応答の内容には非常にわずかの要件があります。
臨時応答は10.3節で定義します。
]FIG]

[FIG(quote)[
[FIGCAPTION[
[3] RFC 2295 (HTTP 透過内容折衝) 10.3 Adhoc response
]FIGCAPTION]

> An adhoc response can be sent by an origin server as an extreme
measure, to achieve compatibility with a non-negotiating or buggy
client if this compatibility cannot be achieved by sending a list or
choice response.  There are very little requirements on the contents
of an adhoc response.  An adhoc response MUST have a TCN header which
specifies the "adhoc" response-type, and a Vary header if the
response is cacheable.  It MAY contain the Alternates header bound to
the negotiable resource.

臨時応答は非折衝クライアントや蝕んだクライアントとの互換性達成が[[目録応答]]や[[選択応答]]では不可能なときに最後の手段として[[起源サーバー]]が送ることが出来ます。
臨時応答の内容には非常にわずかの要件があります。
臨時応答は [CODE(HTTP)[[[adhoc]]]] [CODE(ABNF)[response-type]]
の [CODE(HTTP)[[[TCN]]]] 頭を持たなければ'''ならず'''、
応答が[[キャッシュ可能]]であれば [CODE(HTTP)[[[Vary]]]]
頭も持たなければ'''なりません'''。
臨時応答は折衝可能資源に束縛された [CODE(HTTP)[[[Alternates]]]]
頭を含んでも'''構いません'''。

> Any Vary header in the response SHOULD ensure correct handling by
plain HTTP/1.1 caching proxies.  This header can either be
-        Vary: *

> or a more elaborate header, see section 10.6.1.  Depending on the
status code, an adhoc response is cacheable unless indicated otherwise.

> As an example of the use of an adhoc response, suppose that the
variant resource "redirect-to-blah" yields redirection (302)
responses.  A choice response with this variant could look as follows:
[PRE[
     HTTP/1.1 302 Moved Temporarily
     Date: Tue, 11 Jun 1996 20:02:28 GMT
     TCN: choice
     Content-location: redirect-to-blah
     Location: http://blah.org/
     Content-Type: text/html
     Content-Length: 62

     This document is available <a href=http://blah.org/>here</a>.
]PRE]

> Suppose that the server knows that the receiving user agent has a
bug, which causes it to crash on responses which contain both a
Content-Location and a Location header.  The server could then work
around this bug by performing a server-side override and sending the
following adhoc response instead:

受信する利用者エージェントに虫がいて応答に [CODE(HTTP)[[[Content-Location]]]]
頭と [CODE(HTTP)[[[Location]]]] 頭があると狂うとサーバーが知っているとします。
このサーバーは[[サーバー側上書き]]を行って代わりに次の臨時応答を送ることでこの虫を避けることができるでしょう。

>
[PRE[
        HTTP/1.1 302 Moved Temporarily
        Date: Tue, 11 Jun 1996 20:02:28 GMT
        TCN: adhoc, keep
        Location: http://blah.org/
        Content-Type: text/html
        Content-Length: 62

        This document is available <a href=http://blah.org/>here</a>.
]PRE]
]FIG]

* 関連

[5] [[RFC 2295]] には他に[[リスト応答]]や[[選択応答]]があります。

* メモ

[2] [CODE[臨時応答]]と訳すのと[CODE[特別応答]]と訳すのと、どちらが適当かすごく迷うのですが・・・。
[CODE[Special]] との区別ができる方がましかなあと思って今のところ[CODE[臨時]]にしています。