[10] [DFN[[CODE(HTTP)@en[[[GET]]]]]] は、[[対象資源]]を転送することを要求する
[[HTTP]] [[要求メソッド]]です。

[12] [CODE(HTTP)@en[[[GET]]]] は [[HTTP]] における最も重要で基本的な[[メソッド]]です。
単に [[HTTP]] によってアクセスするというとき、ほとんどの場合は
[CODE(HTTP)@en[[[GET]]]] [[要求]]を送信して[[応答]]を受け取ることをいいます。

* 仕様書

[REFS[
- [19] [CITE@en[RFC 7231 - Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content]] ([TIME[2014-07-01 17:07:49 +09:00]] 版) <https://tools.ietf.org/html/rfc7231#page-22>
-- [9] '''[CITE@en[RFC 7231 - Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content]] ([TIME[2014-06-07 01:55:45 +09:00]] 版) <https://tools.ietf.org/html/rfc7231#section-4.3.1>'''
-- [3] [CITE@en[RFC 7231 - Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content]] ([TIME[2014-06-07 01:55:45 +09:00]] 版) <https://tools.ietf.org/html/rfc7231#section-4.2.1>
-- [5] [CITE@en[RFC 7231 - Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content]] ([TIME[2014-06-07 01:55:45 +09:00]] 版) <https://tools.ietf.org/html/rfc7231#section-4.2.2>
-- [6] [CITE@en[RFC 7231 - Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content]] ([TIME[2014-06-07 01:55:45 +09:00]] 版) <https://tools.ietf.org/html/rfc7231#section-4.2.3>
- [24] [CITE@en[RFC 7231 - Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content]] ([TIME[2014-08-07 05:54:02 +09:00]] 版) <https://tools.ietf.org/html/rfc7231#appendix-B>
- [26] [CITE@en[RFC 1945 - Hypertext Transfer Protocol -- HTTP/1.0]] ([TIME[2014-09-07 13:12:32 +09:00]] 版) <http://tools.ietf.org/html/rfc1945#section-4.1>
- [28] [CITE@en[RFC 4918 - HTTP Extensions for Web Distributed Authoring and Versioning (WebDAV)]] ([TIME[2014-09-21 17:04:59 +09:00]] 版) <http://tools.ietf.org/html/rfc4918#section-9.4>
- [2] [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.3.1>
- [8] [CITE@en[RFC 7252 - The Constrained Application Protocol (CoAP)]]
( ([TIME[2014-06-27 00:59:37 +09:00]] 版))
<http://tools.ietf.org/html/rfc7252#section-5.8.1>
- [33] [CITE@en-US[XMLHttpRequest Standard]] ([TIME[2015-01-14 22:14:17 +09:00]] 版) <https://xhr.spec.whatwg.org/#dom-xmlhttprequest-send>
- [34] [CITE@en-US[Fetch Standard]] ([TIME[2015-02-19 19:33:04 +09:00]] 版) <https://fetch.spec.whatwg.org/#dom-request>
]REFS]

* 意味

[11] [CODE(HTTP)@en[[[GET]]]] [[メソッド]]は、[[対象資源]]の現在の選択されている[[表現]]を転送することを要求するものです
[SRC[>>9]]。

[13] [CODE(HTTP)@en[[[Range:]]]] [[ヘッダー]]を[[要求]]に含めることで、
[CODE(HTTP)@en[[[GET]]]] [[要求]]は[[範囲要求]]となり、
選択された[[表現]]の部分を転送することを要求するものとなります [SRC[>>9]]。

* 構文

[14] [CODE(HTTP)@en[[[GET]]]] [[要求]]の [[payload]] の意味は、定義されていません [SRC[>>9]]。

[15] [[実装]]によってはそのような[[要求]]を却下するものもあります [SRC[>>9]]。

;; [23] これは[[要求メソッド]]に依存しない[[メッセージ]]の[[構文解析]]のために規定を緩和したもの
[SRC[>>24]] とされています。しかし [[RFC 2616]] のどこでそのような制限が規定されていたのか不明です。

[35] [CODE(DOMi)@en[[[XMLHttpRequest]]]] および [CODE(DOMi)@en[[[Request]]]]
では、[[要求]]の [[payload body]] を指定することはできません [SRC[>>33, >>34]]。

[31] 一般的には [CODE(HTTP)@en[[[GET]]]] [[要求]]の [[payload body]]
の指定は使われておらず、[[クライアント]]も対応していないものが大多数と思われます。
しかし、中にはこれを使っているもの (例えば >>30) もあります。
[[相互運用性]]のためには [[payload body]] は使うべきではありません。

;; [32] [[HTTP]] 仕様も明示的に禁止すれば良いものを、なぜ敢えて「undefined」
のような曖昧な状態にするのでしょうね。仕様が曖昧で[[相互運用性]]の問題を放置するなら、
[[標準化]]の意義は一体何なのでしょうか。

* 文脈

[27] [[HTTP/0.9]] では [CODE(HTTP)@en[[[GET]]]] が唯一認められている[[要求メソッド]]となっています [SRC[>>26]]。

* 性質

[20] 一般目的の [[HTTP]] [[鯖]]は、 [CODE(HTTP)@en[[[GET]]]]
を実装しなければ[['''なりません''']] [SRC[>>19]]。

[4] [CODE(HTTP)@en[[[GET]]]] は、[[安全なメソッド]] [SRC[>>3]] で、
[[冪等なメソッド]]です [SRC[>>5]]。

[7] [CODE(HTTP)@en[[[GET]]]] は、[[キャッシュ可能]]です [SRC[>>6, >>9]]。
[[キャッシュ]]は、 [CODE(HTTP)@en[[[Cache-Control:]]]] によって別途指定がない限り、
[CODE(HTTP)@en[[[GET]]]] [[要求]]に対する[[応答]]を以後の [CODE(HTTP)@en[[[GET]]]]
や [CODE(HTTP)@en[[[HEAD]]]] の処理のために使って構いません [SRC[>>9]]。

[21] [CODE(HTTP)@en[[[POST]]]] に対する[[応答]]が [CODE(HTTP)@en[[[GET]]]]
[[要求]]の処理に使われることがあります。

;; [CODE(HTTP)@en[[[POST]]]] の項を参照してください。

[22] [CODE(HTTP)@en[[[HEAD]]]] に対する[[応答]]によって既存の
[CODE(HTTP)@en[[[HEAD]]]] に対する[[応答]]の[[キャッシュ]]が影響されることがあります。

* 処理

[29] [[WebDAV]] [[コレクション]]に対する [CODE(HTTP)@en[[[GET]]]] では、
([[WebDAV]] でない[[資源]]と同じく) 任意の内容を返すことができます [SRC[>>28]]。

* 歴史

[FIG(quote)[
[FIGCAPTION[
[16] RFC 1945 (HTTP/1.0) 8.1; RFC 2068・2616 (HTTP/1.1) 9.3 GET
]FIGCAPTION]

> The GET method means retrieve whatever information (in the form of an
entity) is identified by the Request-URI. If the Request-URI refers
to a data-producing process, it is the produced data which shall be
returned as the entity in the response and not the source text of the
process, unless that text happens to be the output of the process.

[CODE(HTTP)[GET]] 方式は、 [CODE(ABNF)[[[Request-URI]]]] でどんな
([[実体]]の形の) 情報が識別されるのであれ、それを取り出すことを意味します。
[CODE(ABNF)[Request-URI]] がデータ生成過程を指しているのであれば、
応答で実体として返されるものは生成されたデータであって、
その過程の原始文ではありません。
(その原始文が過程の出力であったりする場合を除いて。)

> The semantics of the GET method change[DEL[s]]
to a "conditional GET" if the request message includes an If-Modified-Since[INS[, If-Unmodified-Since, If-Match, If-None-Match, or If-Range]] header field.
A conditional GET method requests that the [DEL[identified resource]] [INS[entity]] be transferred only [DEL[if it has been modified since the date given by the If-Modified-Since header, as described in Section 10.9]] [INS[under the circumstances described by the conditional header field(s)]].
The conditional GET method is intended to reduce [INS[unnecessary]]
network usage by allowing cached entities to be refreshed without requiring multiple requests or transferring [DEL[unnecessary data]] [INS[data already held by the client]].

[CODE(HTTP)[GET]] 方式の意味は、要求メッセージが
[CODE(HTTP)[[[If-Modified-Since]]]], [CODE(HTTP)[[[If-Unmodified-Since]]]],
[CODE(HTTP)[[[If-Match]]]], [CODE(HTTP)[[[If-None-Match]]]],
あるいは [CODE(HTTP)[[[If-Range]]]] 頭欄を含んでいるときは
「条件付 [CODE(HTTP)[GET]]」に変わります。
条件付 [CODE(HTTP)[GET]] 方式は、実体が[[条件頭欄]](群)で説明される状況にあるときにのみ実体を転送することを要求します。
条件付 [CODE(HTTP)[GET]] 方式は、キャッシュされた実態を複数の要求を必要としたり既にクライアントが持っているデータを転送したりせずに更新することを可能とし、
不必要なネットワーク使用を削減することを意図したものです。

[INS[

> The semantics of the GET method change to a "partial GET" if the
request message includes a Range header field. A partial GET requests
that only part of the entity be transferred, as described in section [DEL[14.36]] [INS[14.35]]. The partial GET method is intended to reduce unnecessary
network usage by allowing partially-retrieved entities to be
completed without transferring data already held by the client.

要求メッセージが [CODE(HTTP)[[[Range]]]] 頭欄を含んでいる時、
[CODE(HTTP)[GET]] 方式の意味は「部分 [CODE(HTTP)[GET]]」
に変わります。
部分 [CODE(HTTP)[GET]] 要求は、実体の一部のみを転送します。
部分 [CODE(HTTP)[GET]] 方式は、部分的に取り出した実体を、クライアントが既に持っているデータを転送せずに完全にすることを可能とし、不必要なネットワーク使用を削減することを意図しています。

> The response to a GET request is cach[INS[e]]able if and only if it meets the
requirements for HTTP caching described in section 13.

[CODE(HTTP)[GET]] 要求への応答は、13章で説明している [[HTTP]] [[キャッシュ]]要件に合致すれば、
その場合に限って、[[キャッシュ可能]]です。

[INS[

> See section 15.1.3 for security considerations when used for forms.

[[フォーム]]での使用時の安全性についての考察 15.1.3節をご覧あれ。
]INS]
]INS]
]FIG]

[REFS[
- [25] [CITE@en[RFC 2324 - Hyper Text Coffee Pot Control Protocol (HTCPCP/1.0)]] ([TIME[2014-10-06 15:21:16 +09:00]] 版) <http://tools.ietf.org/html/rfc2324#section-2.1.2>
]REFS]

[FIG(quote)[
[FIGCAPTION[
[17] RFC 2324 (HTCPCP/1.0) 2.1.2 GET method
]FIGCAPTION]

> In HTTP, the GET method is used to mean "retrieve whatever
information (in the form of an entity) identified by the Request-URI." If the Request-URI refers to a data-producing process, it is
the produced data which shall be returned as the entity in the
response and not the source text of the process, unless that text
happens to be the output of the process.

HTTP では、 [CODE(HTTP)[GET]] method
は「([[実体]]の形で) [[Request-URI]] 
で識別される何かの情報を取り出す」ことを意味するのに使っています。
Request-URI がデータ生産過程を参照しているなら、
応答で実体として返されるのは処理したデータであって、
(処理の原始文が処理の出力でない限り) 
処理の原始文ではありません。

> In HTCPCP, the resources associated with a coffee pot are physical,
and not information resources. The "data" for most coffee URIs
contain no caffeine.

HTCPCP では、珈琲ポットと関連付けられた資源は物理的存在であり、
情報資源ではありません。
ほとんどの珈琲 URI の「データ」はカフェインを含みません。
]FIG]

[REFS[
- [36] [CITE@en[Disallow body when method is GET or HEAD for now https://www.w3.org/Bugs... · 3d9655c · whatwg/fetch]] ([TIME[2015-02-24 00:24:27 +09:00]] 版) <https://github.com/whatwg/fetch/commit/3d9655c4024e67fe4e20e8812e96e8ffa2b3cc0d>
]REFS]

* 関連

[18] [CODE(HTTP)@en[[[HEAD]]]] は、 [CODE(HTTP)@en[[[GET]]]] の[[応答]]のうち[[ヘッダー]]部分のみの転送を要求するものです。

* メモ

[1]
[CODE(HTTP)@en[[[GET]]]] でも[[実体]]を[[要求メッセージ]]に含めることはできます。
が、世間からは忘れ去られているのでしょうか。。。

[FIG(quote)[
[FIGCAPTION[
[30] [CITE[Request Body Search]]
([TIME[2015-02-21 09:03:23 +09:00]] 版)
<http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-body.html>
]FIGCAPTION]

> Both HTTP GET and HTTP POST can be used to execute search with body. Since not all clients support GET with body, POST is allowed as well.

]FIG]

[FIG(quote)[
[FIGCAPTION[
[37] [CITE@en-GB-x-hixie[HTML Standard]]
([TIME[2015-03-05 09:33:40 +09:00]] 版)
<https://html.spec.whatwg.org/#concept-http-equivalent-get>
]FIGCAPTION]

> The HTTP GET method is equivalent to the default retrieval action of the protocol. For example, RETR in FTP. Such actions are idempotent and safe, in HTTP terms.

]FIG]


[38] [CITE@en[Fix #44 in a better way. (Avoid "extracting" undefined.) · whatwg/fetch@b33de72]]
([TIME[2015-04-15 23:07:22 +09:00]] 版)
<https://github.com/whatwg/fetch/commit/b33de725823d1a2ab99708b717e83112e4ebeb6b>

[39] [CITE@en[Also throw when new Request() is passed a Request instance with a non-nu... · whatwg/fetch@5be0642]]
([TIME[2015-04-15 23:07:42 +09:00]] 版)
<https://github.com/whatwg/fetch/commit/5be0642d1ad5b93ed8467ea9acc28f5786981599>

[40] [CITE@en[RFC 3253 - Versioning Extensions to WebDAV (Web Distributed Authoring and Versioning)]]
([TIME[2017-09-17 18:19:04 +09:00]])
<https://tools.ietf.org/html/rfc3253#section-8.5>