Anhang B. Beispiele für unaufgeforderte Digests
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.
Die folgenden Beispiele zeigen Interaktionen, bei denen ein Server mit einem Content-Digest- oder Repr-Digest-Feld antwortet, obwohl der Client keines mit Want-Content-Digest oder Want-Repr-Digest angefordert hat.
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.
Einige Beispiele enthalten JSON-Objekte im Inhalt. Zu Präsentationszwecken werden Objekte, die vollständig in die Zeilenlängenbeschränkungen passen, in einer einzigen Zeile in kompakter Notation ohne führendes Leerzeichen dargestellt. Objekte, die die Zeilenlängenbeschränkungen überschreiten würden, werden über mehrere Zeilen (eine Zeile pro Schlüssel-Wert-Paar) mit zwei führenden Leerzeichen dargestellt.
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.
In diesem Dokument definierte Prüfsummenmechanismen sind medientypunabhängig und bieten keine Kanonisierungsalgorithmen für bestimmte Formate. Beispiele werden unter Einbeziehung aller Leerzeichen berechnet. Obwohl Beispiele beide Felder enthalten können, können Content-Digest und Repr-Digest unabhängig voneinander zurückgegeben werden.
B.1. Server gibt vollständige Darstellungsdaten zurück
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.
In diesem Beispiel übermittelt der Nachrichteninhalt vollständige Darstellungsdaten. Das bedeutet, dass in der Antwort sowohl Content-Digest als auch Repr-Digest über das JSON-Objekt {"hello": "world"} gefolgt von einem LF berechnet werden; somit haben sie denselben Wert.
GET /items/123 HTTP/1.1
Host: foo.example
Figure 11: GET Request for an Item
Abbildung 11: GET-Anfrage für ein Element
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
Abbildung 12: Antwort mit identischem Repr-Digest und Content-Digest
B.2. Server gibt keine Darstellungsdaten zurück
In this example, a HEAD request is used to retrieve the checksum of a resource.
In diesem Beispiel wird eine HEAD-Anfrage verwendet, um die Prüfsumme einer Ressource abzurufen.
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.
Der Content-Digest-Feldwert der Antwort wird auf leerem Inhalt berechnet. Repr-Digest wird über das JSON-Objekt {"hello": "world"} gefolgt von einem LF berechnet, das nicht angezeigt wird, da kein Inhalt vorhanden ist.
HEAD /items/123 HTTP/1.1
Host: foo.example
Figure 13: HEAD Request for an Item
Abbildung 13: HEAD-Anfrage für ein Element
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)
Abbildung 14: Antwort mit sowohl Content-Digest als auch Digest (leerer Inhalt)
B.3. Server gibt teilweise Darstellungsdaten zurück
In this example, the client makes a range request and the server responds with partial content.
In diesem Beispiel stellt der Client eine Range-Anfrage und der Server antwortet mit partiellem Inhalt.
GET /items/123 HTTP/1.1
Host: foo.example
Range: bytes=10-18
Figure 15: Request for Partial Content
Abbildung 15: Anfrage für Teilinhalt
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
Abbildung 16: Teilantwort mit sowohl Content-Digest als auch 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:
Beachten Sie in der obigen Antwortnachricht, dass sich Repr-Digest und Content-Digest unterscheiden. Der Repr-Digest-Feldwert wird über das gesamte JSON-Objekt {"hello": "world"} gefolgt von einem LF berechnet, und das Feld sieht wie folgt aus:
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:
Da der Nachrichteninhalt jedoch auf die Bytes 10-18 beschränkt ist, wird der Content-Digest-Feldwert über die Sequenz "world"} gefolgt von einem LF berechnet, was zu folgendem Ergebnis führt:
NOTE: '' line wrapping per RFC 8792
Content-Digest: \
sha-256=:jjcgBDWNAtbYUXI37CVG3gRuGOAjaaDRGpIUFsdyepQ=:
B.4. Client und Server stellen vollständige Darstellungsdaten bereit
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.
Die Anfrage enthält einen Repr-Digest-Feldwert, der auf der enthaltenen Darstellung berechnet wurde. Sie enthält auch ein Accept-Encoding: br-Headerfeld, das angibt, dass der Client die Brotli-Codierung unterstützt.
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.
Die Antwort enthält ein Content-Encoding: br, das angibt, dass die ausgewählte Darstellung Brotli-codiert ist. Der Repr-Digest-Feldwert unterscheidet sich daher von der Anfrage.
For presentation purposes, the response body is displayed as a sequence of hex-encoded bytes because it contains non-printable characters.
Zu Präsentationszwecken wird der Antworttext als Folge von hexadezimal codierten Bytes angezeigt, da er nicht druckbare Zeichen enthält.
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
Abbildung 17: PUT-Anfrage mit Digest
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
Abbildung 18: Antwort mit Digest der codierten Antwort
B.5. Client stellt vollständige Darstellungsdaten bereit und Server stellt keine Darstellungsdaten bereit
The request Repr-Digest field-value is calculated on the enclosed content, which is the JSON object {"hello": "world"} followed by an LF.
Der Repr-Digest-Feldwert der Anfrage wird auf dem enthaltenen Inhalt berechnet, bei dem es sich um das JSON-Objekt {"hello": "world"} gefolgt von einem LF handelt.
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.
Der Repr-Digest-Feldwert der Antwort hängt von den Headerfeldern der Repräsentationsmetadaten ab, einschließlich Content-Encoding: br, auch wenn die Antwort keinen Inhalt enthält.
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
Abbildung 19: Leere Antwort mit Digest
B.6. Client und Server stellen vollständige Darstellungsdaten bereit
The response contains two digest values using different algorithms.
Die Antwort enthält zwei Digest-Werte unter Verwendung unterschiedlicher Algorithmen.
For presentation purposes, the response body is displayed as a sequence of hex-encoded bytes because it contains non-printable characters.
Zu Präsentationszwecken wird der Antworttext als Folge von hexadezimal codierten Bytes angezeigt, da er nicht druckbare Zeichen enthält.
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
Abbildung 20: PUT-Anfrage mit Digest
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
Abbildung 21: Antwort mit Digest des codierten Inhalts
B.7. POST-Antwort verweist nicht auf die Anfrage-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.
Der Repr-Digest-Feldwert der Anfrage wird auf der enthaltenen Darstellung berechnet (siehe Abschnitt 3.1), bei der es sich um das JSON-Objekt {"title": "New Title"} gefolgt von einem LF handelt.
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.
Die in der Antwort enthaltene Darstellung ist ein mehrzeiliges JSON-Objekt gefolgt von einem LF. Sie bezieht sich auf die durch Content-Location identifizierte Ressource (siehe Abschnitt 6.4.2 von [HTTP]); somit kann eine Anwendung Repr-Digest in Verbindung mit der durch Content-Location referenzierten Ressource verwenden.
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
Abbildung 22: POST-Anfrage mit Digest
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
Abbildung 23: Antwort mit Digest der Ressource
B.8. POST-Antwort beschreibt den Anfragestatus
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.
Der Repr-Digest-Feldwert der Anfrage wird auf der enthaltenen Darstellung berechnet (siehe Abschnitt 3.1), bei der es sich um das JSON-Objekt {"title": "New Title"} gefolgt von einem LF handelt.
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.
Die in der Antwort enthaltene Darstellung beschreibt den Status der Anfrage, daher wird Repr-Digest auf dieser enthaltenen Darstellung berechnet. Es ist ein mehrzeiliges JSON-Objekt gefolgt von einem LF.
Response Repr-Digest has no explicit relation with the resource referenced by Location.
Die Antwort Repr-Digest hat keine explizite Beziehung zu der durch Location referenzierten Ressource.
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
Abbildung 24: POST-Anfrage mit Digest
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
Abbildung 25: Antwort mit Digest der Darstellung
B.9. Digest mit PATCH
This case is analogous to a POST request where the target resource reflects the target URI.
Dieser Fall ist analog zu einer POST-Anfrage, bei der die Zielressource die Ziel-URI widerspiegelt.
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.
Die PATCH-Anfrage verwendet den in [RFC7396] definierten Medientyp application/merge-patch+json. Repr-Digest wird auf dem Inhalt berechnet, der dem Patch-Dokument entspricht und das JSON-Objekt {"title": "New Title"} gefolgt von einem LF ist.
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.
Der Repr-Digest-Feldwert der Antwort wird auf der vollständigen Darstellung der gepatchten Ressource berechnet. Es ist ein mehrzeiliges JSON-Objekt gefolgt von einem LF.
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
Abbildung 26: PATCH-Anfrage mit Digest
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
Abbildung 27: Antwort mit Digest der Darstellung
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.
Beachten Sie, dass eine 204 No Content-Antwort ohne Inhalt, aber mit demselben Repr-Digest-Feldwert ebenfalls legitim gewesen wäre. In diesem Fall wäre Content-Digest auf einem leeren Inhalt berechnet worden.
B.10. Fehlerantworten
In error responses, the representation data does not necessarily refer to the target resource. Instead, it refers to the representation of the error.
In Fehlerantworten beziehen sich die Darstellungsdaten nicht unbedingt auf die Zielressource. Stattdessen beziehen sie sich auf die Darstellung des Fehlers.
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].
Im folgenden Beispiel sendet ein Client dieselbe Anfrage wie in Abbildung 26, um die Ressource unter /books/123 zu patchen. Die Ressource existiert jedoch nicht, und der Server generiert eine 404-Antwort mit einem Text, der den Fehler gemäß [RFC9457] beschreibt.
The response Repr-Digest field-value is computed on this enclosed representation. It is a multiline JSON object followed by an LF.
Der Repr-Digest-Feldwert der Antwort wird auf dieser enthaltenen Darstellung berechnet. Es ist ein mehrzeiliges JSON-Objekt gefolgt von einem LF.
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
Abbildung 28: Antwort mit Digest der Fehlerdarstellung
B.11. Verwendung mit Trailer-Feldern und Transfer-Codierung
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).
Ein Ursprungsserver sendet Repr-Digest als Trailer-Feld, damit er den Digest-Wert während des Streamings von Inhalten berechnen und so den Ressourcenverbrauch verringern kann. Der Repr-Digest-Feldwert ist derselbe wie in Anhang B.1, da Repr-Digest so konzipiert ist, dass es unabhängig von der Verwendung einer oder mehrerer Transfer-Codierungen ist (siehe Abschnitt 3).
In the response content below, the string "\r\n" represents the CRLF bytes.
Im folgenden Antwortinhalt stellt die Zeichenfolge "\r\n" die CRLF-Bytes dar.
GET /items/123 HTTP/1.1
Host: foo.example
Figure 29: GET Request
Abbildung 29: GET-Anfrage
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
Abbildung 30: Chunked-Antwort mit Digest