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

付録 B. 未承諾ダイジェストの例

The following examples demonstrate interactions where a server responds with a Content-Digest or Repr-Digest field, even though the client did not solicit one using Want-Content-Digest or Want-Repr-Digest.

以下の例は、クライアントが Want-Content-Digest または Want-Repr-Digest を使用して要求していないにもかかわらず、サーバーが Content-Digest または Repr-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 defined in this document are media-type agnostic and do not provide canonicalization algorithms for specific formats. Examples are calculated inclusive of any space. While examples can include both fields, Content-Digest and Repr-Digest can be returned independently.

このドキュメントで定義されているチェックサムメカニズムは、メディアタイプに依存せず、特定の形式の正規化アルゴリズムを提供しません。例は、スペースを含めて計算されます。例には両方のフィールドを含めることができますが、Content-Digest と Repr-Digest は個別に返すことができます。

B.1. サーバーが完全な表現データを返す

In this example, the message content conveys complete representation data. This means that in the response, Content-Digest and Repr-Digest are both computed over the JSON object {"hello": "world"} followed by an LF; thus, they have the same value.

この例では、メッセージコンテンツは完全な表現データを伝えます。つまり、応答では、Content-Digest と Repr-Digest の両方が、LF が続く JSON オブジェクト {"hello": "world"} に対して計算されます。したがって、それらは同じ値を持ちます。

GET /items/123 HTTP/1.1
Host: foo.example

Figure 11: GET Request for an Item

図 11:アイテムの GET リクエスト

NOTE: '' line wrapping per RFC 8792

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

{"hello": "world"}

Figure 12: Response with Identical Repr-Digest and Content-Digest

図 12:同一の Repr-Digest と Content-Digest を含む応答

B.2. サーバーが表現データを返さない

In this example, a HEAD request is used to retrieve the checksum of a resource.

この例では、HEAD リクエストを使用してリソースのチェックサムを取得します。

The response Content-Digest field-value is computed on empty content. Repr-Digest is calculated over the JSON object {"hello": "world"} followed by an LF, which is not shown because there is no content.

応答 Content-Digest フィールド値は、空のコンテンツに対して計算されます。Repr-Digest は、LF が続く JSON オブジェクト {"hello": "world"} に対して計算されますが、コンテンツがないため表示されません。

HEAD /items/123 HTTP/1.1
Host: foo.example

Figure 13: HEAD Request for an Item

図 13:アイテムの HEAD リクエスト

NOTE: '' line wrapping per RFC 8792

HTTP/1.1 200 OK
Content-Type: application/json
Content-Digest: \
sha-256=:47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=:
Repr-Digest: \
sha-256=:RK/0qy18MlBSVnWgjwz6lZEWjP/lF5HF9bvEF8FabDg=:

Figure 14: Response with Both Content-Digest and Digest (Empty Content)

図 14:Content-Digest と Digest の両方を含む応答(空のコンテンツ)

B.3. サーバーが部分的な表現データを返す

In this example, the client makes a range request and the server responds with partial content.

この例では、クライアントは範囲リクエストを行い、サーバーは部分的なコンテンツで応答します。

GET /items/123 HTTP/1.1
Host: foo.example
Range: bytes=10-18

Figure 15: Request for Partial Content

図 15:部分コンテンツのリクエスト

NOTE: '' line wrapping per RFC 8792

HTTP/1.1 206 Partial Content
Content-Type: application/json
Content-Range: bytes 10-18/19
Content-Digest: \
sha-256=:jjcgBDWNAtbYUXI37CVG3gRuGOAjaaDRGpIUFsdyepQ=:
Repr-Digest: \
sha-256=:RK/0qy18MlBSVnWgjwz6lZEWjP/lF5HF9bvEF8FabDg=:

"world"}

Figure 16: Partial Response with Both Content-Digest and Repr-Digest

図 16:Content-Digest と Repr-Digest の両方を含む部分応答

In the response message above, note that the Repr-Digest and Content-Digests are different. The Repr-Digest field-value is calculated across the entire JSON object {"hello": "world"} followed by an LF, and the field appears as follows:

上記の応答メッセージでは、Repr-Digest と Content-Digest が異なることに注意してください。Repr-Digest フィールド値は、LF が続く JSON オブジェクト {"hello": "world"} 全体に対して計算され、フィールドは次のように表示されます。

NOTE: '' line wrapping per RFC 8792

Repr-Digest: \
sha-256=:RK/0qy18MlBSVnWgjwz6lZEWjP/lF5HF9bvEF8FabDg=:

However, since the message content is constrained to bytes 10-18, the Content-Digest field-value is calculated over the sequence "world"} followed by an LF, thus resulting in the following:

ただし、メッセージコンテンツはバイト 10-18 に制限されているため、Content-Digest フィールド値は、LF が続くシーケンス "world"} に対して計算され、次のようになります。

NOTE: '' line wrapping per RFC 8792

Content-Digest: \
sha-256=:jjcgBDWNAtbYUXI37CVG3gRuGOAjaaDRGpIUFsdyepQ=:

B.4. クライアントとサーバーが完全な表現データを提供する

The request contains a Repr-Digest field-value calculated on the enclosed representation. It also includes an Accept-Encoding: br header field that advertises that the client supports Brotli encoding.

リクエストには、同封された表現に対して計算された Repr-Digest フィールド値が含まれています。また、クライアントが Brotli エンコーディングをサポートしていることを通知する Accept-Encoding: br ヘッダーフィールドも含まれています。

The response includes a Content-Encoding: br that indicates the selected representation is Brotli-encoded. The Repr-Digest field-value is therefore different compared to the request.

応答には、選択された表現が Brotli エンコードされていることを示す Content-Encoding: br が含まれています。したがって、Repr-Digest フィールド値はリクエストとは異なります。

For presentation purposes, the response body is displayed as a sequence of hex-encoded bytes because it contains non-printable characters.

表示の目的で、応答本文には印刷不可能な文字が含まれているため、16進エンコードされたバイトのシーケンスとして表示されます。

NOTE: '' line wrapping per RFC 8792

PUT /items/123 HTTP/1.1
Host: foo.example
Content-Type: application/json
Accept-Encoding: br
Repr-Digest: \
sha-256=:RK/0qy18MlBSVnWgjwz6lZEWjP/lF5HF9bvEF8FabDg=:

{"hello": "world"}

Figure 17: PUT Request with Digest

図 17:ダイジェスト付きの PUT リクエスト

NOTE: '' line wrapping per RFC 8792

HTTP/1.1 200 OK
Content-Type: application/json
Content-Location: /items/123
Content-Encoding: br
Content-Length: 23
Repr-Digest: \
sha-256=:d435Qo+nKZ+gLcUHn7GQtQ72hiBVAgqoLsZnZPiTGPk=:

8B 08 80 7B 22 68 65 6C 6C 6F
22 3A 20 22 77 6F 72 6C 64 22
7D 0A 03

Figure 18: Response with Digest of Encoded Response

図 18:エンコードされた応答のダイジェストを含む応答

B.5. クライアントが完全な表現データを提供し、サーバーが表現データを提供しない

The request Repr-Digest field-value is calculated on the enclosed content, which is the JSON object {"hello": "world"} followed by an LF.

リクエストの Repr-Digest フィールド値は、同封されたコンテンツ、つまり LF が続く JSON オブジェクト {"hello": "world"} に対して計算されます。

The response Repr-Digest field-value depends on the representation metadata header fields, including Content-Encoding: br, even when the response does not contain content.

応答の Repr-Digest フィールド値は、応答にコンテンツが含まれていない場合でも、Content-Encoding: br を含む表現メタデータヘッダーフィールドに依存します。

NOTE: '' line wrapping per RFC 8792

PUT /items/123 HTTP/1.1
Host: foo.example
Content-Type: application/json
Content-Length: 19
Accept-Encoding: br
Repr-Digest: \
sha-256=:RK/0qy18MlBSVnWgjwz6lZEWjP/lF5HF9bvEF8FabDg==:

{"hello": "world"}
HTTP/1.1 204 No Content
Content-Type: application/json
Content-Encoding: br
Repr-Digest: sha-256=:d435Qo+nKZ+gLcUHn7GQtQ72hiBVAgqoLsZnZPiTGPk=:

Figure 19: Empty Response with Digest

図 19:ダイジェストを含む空の応答

B.6. クライアントとサーバーが完全な表現データを提供する

The response contains two digest values using different algorithms.

応答には、異なるアルゴリズムを使用した 2 つのダイジェスト値が含まれています。

For presentation purposes, the response body is displayed as a sequence of hex-encoded bytes because it contains non-printable characters.

表示の目的で、応答本文には印刷不可能な文字が含まれているため、16進エンコードされたバイトのシーケンスとして表示されます。

NOTE: '' line wrapping per RFC 8792

PUT /items/123 HTTP/1.1
Host: foo.example
Content-Type: application/json
Accept-Encoding: br
Repr-Digest: \
sha-256=:RK/0qy18MlBSVnWgjwz6lZEWjP/lF5HF9bvEF8FabDg==:

{"hello": "world"}

Figure 20: PUT Request with Digest

図 20:ダイジェスト付きの PUT リクエスト

NOTE: '' line wrapping per RFC 8792

HTTP/1.1 200 OK
Content-Type: application/json
Content-Encoding: br
Content-Location: /items/123
Repr-Digest: \
sha-256=:d435Qo+nKZ+gLcUHn7GQtQ72hiBVAgqoLsZnZPiTGPk=:,\
sha-512=:db7fdBbgZMgX1Wb2MjA8zZj+rSNgfmDCEEXM8qLWfpfoNY0sCpHAzZbj\
09X1/7HAb7Od5Qfto4QpuBsFbUO3dQ==:

8B 08 80 7B 22 68 65 6C 6C 6F
22 3A 20 22 77 6F 72 6C 64 22
7D 0A 03

Figure 21: Response with Digest of Encoded Content

図 21:エンコードされたコンテンツのダイジェストを含む応答

B.7. POST 応答がリクエスト URI を参照していない

The request Repr-Digest field-value is computed on the enclosed representation (see Section 3.1), which is the JSON object {"title": "New Title"} followed by an LF.

リクエストの Repr-Digest フィールド値は、同封された表現(セクション 3.1 を参照)、つまり LF が続く JSON オブジェクト {"title": "New Title"} に対して計算されます。

The representation enclosed in the response is a multiline JSON object followed by an LF. It refers to the resource identified by Content-Location (see Section 6.4.2 of [HTTP]); thus, an application can use Repr-Digest in association with the resource referenced by Content-Location.

応答に含まれる表現は、LF が続く複数行の JSON オブジェクトです。これは、Content-Location([HTTP] のセクション 6.4.2 を参照)によって識別されるリソースを参照します。したがって、アプリケーションは、Content-Location によって参照されるリソースに関連して Repr-Digest を使用できます。

POST /books HTTP/1.1
Host: foo.example
Content-Type: application/json
Accept: application/json
Accept-Encoding: identity
Repr-Digest: sha-256=:mEkdbO7Srd9LIOegftO0aBX+VPTVz7/CSHes2Z27gc4=:

{"title": "New Title"}

Figure 22: POST Request with Digest

図 22:ダイジェスト付きの POST リクエスト

HTTP/1.1 201 Created
Content-Type: application/json
Content-Location: /books/123
Location: /books/123
Repr-Digest: sha-256=:uVSlinTTdQUwm2On4k8TJUikGN1bf/Ds8WPX4oe0h9I=:

{
"id": "123",
"title": "New Title"
}

Figure 23: Response with Digest of Resource

図 23:リソースのダイジェストを含む応答

B.8. POST 応答がリクエストステータスを記述している

The request Repr-Digest field-value is computed on the enclosed representation (see Section 3.1), which is the JSON object {"title": "New Title"} followed by an LF.

リクエストの Repr-Digest フィールド値は、同封された表現(セクション 3.1 を参照)、つまり LF が続く JSON オブジェクト {"title": "New Title"} に対して計算されます。

The representation enclosed in the response describes the status of the request, so Repr-Digest is computed on that enclosed representation. It is a multiline JSON object followed by an LF.

応答に含まれる表現はリクエストのステータスを記述しているため、Repr-Digest はその含まれる表現に対して計算されます。これは、LF が続く複数行の JSON オブジェクトです。

Response Repr-Digest has no explicit relation with the resource referenced by Location.

応答 Repr-Digest は、Location によって参照されるリソースと明示的な関係はありません。

POST /books HTTP/1.1
Host: foo.example
Content-Type: application/json
Accept: application/json
Accept-Encoding: identity
Repr-Digest: sha-256=:mEkdbO7Srd9LIOegftO0aBX+VPTVz7/CSHes2Z27gc4=:

{"title": "New Title"}

Figure 24: POST Request with Digest

図 24:ダイジェスト付きの POST リクエスト

HTTP/1.1 201 Created
Content-Type: application/json
Repr-Digest: sha-256=:yXIGDTN5VrfoyisKlXgRKUHHMs35SNtyC3szSz1dbO8=:
Location: /books/123

{
"status": "created",
"id": "123",
"ts": 1569327729,
"instance": "/books/123"
}

Figure 25: Response with Digest of Representation

図 25:表現のダイジェストを含む応答

B.9. PATCH を使用したダイジェスト

This case is analogous to a POST request where the target resource reflects the target URI.

このケースは、ターゲットリソースがターゲット URI を反映する POST リクエストに類似しています。

The PATCH request uses the application/merge-patch+json media type defined in [RFC7396]. Repr-Digest is calculated on the content that corresponds to the patch document and is the JSON object {"title": "New Title"} followed by an LF.

PATCH リクエストは、[RFC7396] で定義されている application/merge-patch+json メディアタイプを使用します。Repr-Digest は、パッチドキュメントに対応するコンテンツに対して計算され、LF が続く JSON オブジェクト {"title": "New Title"} です。

The response Repr-Digest field-value is computed on the complete representation of the patched resource. It is a multiline JSON object followed by an LF.

応答 Repr-Digest フィールド値は、パッチが適用されたリソースの完全な表現に対して計算されます。これは、LF が続く複数行の JSON オブジェクトです。

PATCH /books/123 HTTP/1.1
Host: foo.example
Content-Type: application/merge-patch+json
Accept: application/json
Accept-Encoding: identity
Repr-Digest: sha-256=:mEkdbO7Srd9LIOegftO0aBX+VPTVz7/CSHes2Z27gc4=:

{"title": "New Title"}

Figure 26: PATCH Request with Digest

図 26:ダイジェスト付きの PATCH リクエスト

HTTP/1.1 200 OK
Content-Type: application/json
Repr-Digest: sha-256=:uVSlinTTdQUwm2On4k8TJUikGN1bf/Ds8WPX4oe0h9I=:

{
"id": "123",
"title": "New Title"
}

Figure 27: Response with Digest of Representation

図 27:表現のダイジェストを含む応答

Note that a 204 No Content response without content, but with the same Repr-Digest field-value, would have been legitimate too. In that case, Content-Digest would have been computed on an empty content.

コンテンツはないが同じ Repr-Digest フィールド値を持つ 204 No Content 応答も正当であったことに注意してください。その場合、Content-Digest は空のコンテンツに対して計算されます。

B.10. エラー応答

In error responses, the representation data does not necessarily refer to the target resource. Instead, it refers to the representation of the error.

エラー応答では、表現データは必ずしもターゲットリソースを参照するとは限りません。代わりに、エラーの表現を参照します。

In the following example, a client sends the same request from Figure 26 to patch the resource located at /books/123. However, the resource does not exist and the server generates a 404 response with a body that describes the error in accordance with [RFC9457].

次の例では、クライアントは図 26 と同じリクエストを送信して、/books/123 にあるリソースにパッチを適用します。ただし、リソースは存在せず、サーバーは [RFC9457] に従ってエラーを記述する本文を含む 404 応答を生成します。

The response Repr-Digest field-value is computed on this enclosed representation. It is a multiline JSON object followed by an LF.

応答 Repr-Digest フィールド値は、この同封された表現に対して計算されます。これは、LF が続く複数行の JSON オブジェクトです。

HTTP/1.1 404 Not Found
Content-Type: application/problem+json
Repr-Digest: sha-256=:EXB0S2VF2H7ijkAVJkH1Sm0pBho0iDZcvVUHHXTTZSA=:

{
"title": "Not Found",
"detail": "Cannot PATCH a non-existent resource",
"status": 404
}

Figure 28: Response with Digest of Error Representation

図 28:エラー表現のダイジェストを含む応答

B.11. トレーラーフィールドと転送コーディングでの使用

An origin server sends Repr-Digest as trailer field, so it can calculate digest-value while streaming content and thus mitigate resource consumption. The Repr-Digest field-value is the same as in Appendix B.1 because Repr-Digest is designed to be independent of the use of one or more transfer codings (see Section 3).

オリジンサーバーは、Repr-Digest をトレーラーフィールドとして送信するため、コンテンツをストリーミングしながらダイジェスト値を計算でき、リソース消費を軽減できます。Repr-Digest は 1 つ以上の転送コーディングの使用とは無関係になるように設計されているため、Repr-Digest フィールド値は 付録 B.1 と同じです(セクション 3 を参照)。

In the response content below, the string "\r\n" represents the CRLF bytes.

以下の応答コンテンツでは、文字列 "\r\n" は CRLF バイトを表します。

GET /items/123 HTTP/1.1
Host: foo.example

Figure 29: GET Request

図 29:GET リクエスト

NOTE: '' line wrapping per RFC 8792

HTTP/1.1 200 OK
Content-Type: application/json
Transfer-Encoding: chunked
Trailer: Repr-Digest

8\r\n
{"hello"\r\n
8\r\n
: "world\r\n
3\r\n
"}\n\r\n
0\r\n
Repr-Digest: \
sha-256=:RK/0qy18MlBSVnWgjwz6lZEWjP/lF5HF9bvEF8FabDg==:\r\n

Figure 30: Chunked Response with Digest

図 30:ダイジェスト付きのチャンク応答