メインコンテンツまでスキップ

付録 C. Want-Repr-Digest によるダイジェスト要求の例

The following examples demonstrate interactions where a client solicits a Repr-Digest using Want-Repr-Digest. The behavior of Content-Digest and Want-Content-Digest is identical.

以下の例は、クライアントが Want-Repr-Digest を使用して Repr-Digest を要求する相互作用を示しています。Content-Digest と Want-Content-Digest の動作は同じです。

Some examples include JSON objects in the content. For presentation purposes, objects that fit completely within the line-length limits are presented on a single line using compact notation with no leading space. Objects that would exceed line-length limits are presented across multiple lines (one line per key-value pair) with two spaces of leading indentation.

一部の例には、コンテンツに JSON オブジェクトが含まれています。表示の目的で、行長の制限内に完全に収まるオブジェクトは、先頭にスペースのないコンパクトな表記を使用して 1 行で表示されます。行長の制限を超えるオブジェクトは、2 つのスペースの先頭インデントを持つ複数行(キーと値のペアごとに 1 行)で表示されます。

Checksum mechanisms described in this document are media-type agnostic and do not provide canonicalization algorithms for specific formats. Examples are calculated inclusive of any space.

このドキュメントで説明されているチェックサムメカニズムは、メディアタイプに依存せず、特定の形式の正規化アルゴリズムを提供しません。例は、スペースを含めて計算されます。

C.1. サーバーがクライアントの最も好まないアルゴリズムを選択する

The client requests a digest and prefers "sha". The server is free to reply with "sha-256" anyway.

クライアントはダイジェストを要求し、"sha" を優先します。サーバーはとにかく "sha-256" で応答して構いません。

GET /items/123 HTTP/1.1
Host: foo.example
Want-Repr-Digest: sha-256=3, sha=10

Figure 31: GET Request with Want-Repr-Digest

図 31:Want-Repr-Digest を含む GET リクエスト

NOTE: '' line wrapping per RFC 8792

HTTP/1.1 200 OK
Content-Type: application/json
Repr-Digest: \
sha-256=:RK/0qy18MlBSVnWgjwz6lZEWjP/lF5HF9bvEF8FabDg==:

{"hello": "world"}

Figure 32: Response with Different Algorithm

図 32:異なるアルゴリズムでの応答

C.2. サーバーがクライアントでサポートされていないアルゴリズムを選択する

The client requests a "sha" digest because that is the only algorithm it supports. The server is not obliged to produce a response containing a "sha" digest; it instead uses a different algorithm.

クライアントは "sha" ダイジェストを要求します。これは、それがサポートする唯一のアルゴリズムであるためです。サーバーは "sha" ダイジェストを含む応答を生成する義務はありません。代わりに別のアルゴリズムを使用します。

GET /items/123 HTTP/1.1
Host: foo.example
Want-Repr-Digest: sha=10

Figure 33: GET Request with Want-Repr-Digest

図 33:Want-Repr-Digest を含む GET リクエスト

NOTE: '' line wrapping per RFC 8792

HTTP/1.1 200 OK
Content-Type: application/json
Repr-Digest: \
sha-512=:YMAam51Jz/jOATT6/zvHrLVgOYTGFy1d6GJiOHTohq4yP+pgk4vf2aCs\
yRZOtw8MjkM7iw7yZ/WkppmM44T3qg==:

{"hello": "world"}

Figure 34: Response with Unsupported Algorithm

図 34:サポートされていないアルゴリズムでの応答

C.3. サーバーがクライアントアルゴリズムをサポートせず、エラーを返す

Appendix C.2 is an example where a server ignores the client's preferred digest algorithm. Alternatively, a server can also reject the request and return a response with an error status code such as 4xx or 5xx. This specification does not prescribe any requirement on status code selection; the following example illustrates one possible option.

付録 C.2 は、サーバーがクライアントの優先ダイジェストアルゴリズムを無視する例です。あるいは、サーバーはリクエストを拒否し、4xx や 5xx などのエラーステータスコードを含む応答を返すこともできます。この仕様では、ステータスコードの選択に関する要件は規定されていません。以下の例は、考えられる 1 つのオプションを示しています。

In this example, the client requests a "sha" Repr-Digest, and the server returns an error with problem details [RFC9457] contained in the content. The problem details contain a list of the hashing algorithms that the server supports. This is purely an example; this specification does not define any format or requirements for such content.

この例では、クライアントは "sha" Repr-Digest を要求し、サーバーはコンテンツに含まれる問題の詳細 [RFC9457] とともにエラーを返します。問題の詳細には、サーバーがサポートするハッシュアルゴリズムのリストが含まれています。これは単なる例です。この仕様では、そのようなコンテンツの形式や要件は定義されていません。

GET /items/123 HTTP/1.1
Host: foo.example
Want-Repr-Digest: sha=10

Figure 35: GET Request with Want-Repr-Digest

図 35:Want-Repr-Digest を含む GET リクエスト

HTTP/1.1 400 Bad Request
Content-Type: application/problem+json

{
"title": "Bad Request",
"detail": "Supported hashing algorithms: sha-256, sha-512",
"status": 400
}

Figure 36: Response Advertising the Supported Algorithms

図 36:サポートされているアルゴリズムを通知する応答