AZ Tools

HTTP メソッドリファレンス

開発

実際に API 設計を形作る 4 つの特性 — 安全 (サーバー側の副作用なし)、冪等 (N 回繰り返した同じ最終状態)、キャッシュ可能 (レスポンスを再利用可能)、ボディを持つ (リクエストとレスポンス) — をメソッドごとに収集し、それぞれが適切な場合の 1 行の要約を含む。

GET

Retrieve a representation of a resource. Should have no side effects.

安全
はい
冪等
はい
キャッシュ可能
はい
Req body
いいえ
Res body
はい
HEAD

Like GET but with no response body. Used to inspect headers (size, ETag, Last-Modified).

安全
はい
冪等
はい
キャッシュ可能
はい
Req body
いいえ
Res body
いいえ
POST

Submit data to the server — create a new resource, send a form, or trigger a side-effecting action. Cacheable only when explicit Cache-Control / Expires headers permit.

安全
いいえ
冪等
いいえ
キャッシュ可能
条件付き
Req body
はい
Res body
はい
PUT

Replace the target resource entirely with the request payload. Calling it twice gives the same result as once.

安全
いいえ
冪等
はい
キャッシュ可能
いいえ
Req body
はい
Res body
はい
DELETE

Remove the target resource. Idempotent in the same sense as PUT — deleting an already-gone resource still ends with the same state.

安全
いいえ
冪等
はい
キャッシュ可能
いいえ
Req body
条件付き
Res body
はい
PATCH

Apply a partial update to the resource. RFC 5789 leaves the patch format up to the API — JSON Patch (RFC 6902) and JSON Merge Patch (RFC 7396) are the common choices.

安全
いいえ
冪等
いいえ
キャッシュ可能
いいえ
Req body
はい
Res body
はい
OPTIONS

Ask what the server supports for the target — methods, CORS preflight, accepted Content-Types. The response usually carries an Allow header.

安全
はい
冪等
はい
キャッシュ可能
いいえ
Req body
いいえ
Res body
はい
TRACE

Echo back the request as the server sees it after proxies. Usually disabled in production for security (Cross-Site Tracing).

安全
はい
冪等
はい
キャッシュ可能
いいえ
Req body
いいえ
Res body
はい
CONNECT

Establish a tunnel to the server, used by HTTP proxies for HTTPS. The client and server exchange raw bytes after the proxy accepts.

安全
いいえ
冪等
いいえ
キャッシュ可能
いいえ
Req body
いいえ
Res body
いいえ

「条件付き」は、明示的なヘッダ (POST の Cache-Control、DELETE のボディ) のもとでのみ特性が成立することを意味する。

使い方

  1. メソッド名 (`patch`) またはキーワード (`cache`、`tunnel`) を入力してフィルタ。
  2. メソッドごとのカードを読む:上に説明、その下に 5 つの特性ドット。
  3. コピーをクリックして fetch コールや curl コマンドにメソッドを入れる。

よくある質問

POST が同じことをできるのに、なぜ PATCH には独自のメソッドがある?
セマンティクス。PATCH は「この部分的な diff を適用」を意味する;POST は「このペイロードを作成または処理する」。パッチ形式がよく設計されていれば、PATCH を 2 回呼ぶと 1 回呼んだのと同じリソース状態になる;その冪等性の保証は追加の動詞の価値がある。
POST は本当にキャッシュ可能?
条件付き — RFC 9111 §3 はレスポンスが明示的な `Cache-Control` / `Expires` ヘッダを持つときに POST レスポンスをキャッシュすることを許可する。実際にはほとんど誰もこれを行わないので、ほとんどのキャッシュは POST をキャッシュ不可として扱う。

関連ツール