Anhang C. Beispiele für Want-Repr-Digest angeforderten 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.
Die folgenden Beispiele zeigen Interaktionen, bei denen ein Client einen Repr-Digest mit Want-Repr-Digest anfordert. Das Verhalten von Content-Digest und Want-Content-Digest ist identisch.
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 described in this document are media-type agnostic and do not provide canonicalization algorithms for specific formats. Examples are calculated inclusive of any space.
In diesem Dokument beschriebene Prüfsummenmechanismen sind medientypunabhängig und bieten keine Kanonisierungsalgorithmen für bestimmte Formate. Beispiele werden unter Einbeziehung aller Leerzeichen berechnet.
C.1. Server wählt den vom Client am wenigsten bevorzugten Algorithmus
The client requests a digest and prefers "sha". The server is free to reply with "sha-256" anyway.
Der Client fordert einen Digest an und bevorzugt "sha". Der Server kann trotzdem mit "sha-256" antworten.
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
Abbildung 31: GET-Anfrage mit Want-Repr-Digest
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
Abbildung 32: Antwort mit anderem Algorithmus
C.2. Server wählt Algorithmus, der vom Client nicht unterstützt wird
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.
Der Client fordert einen "sha"-Digest an, da dies der einzige Algorithmus ist, den er unterstützt. Der Server ist nicht verpflichtet, eine Antwort mit einem "sha"-Digest zu erstellen; er verwendet stattdessen einen anderen Algorithmus.
GET /items/123 HTTP/1.1
Host: foo.example
Want-Repr-Digest: sha=10
Figure 33: GET Request with Want-Repr-Digest
Abbildung 33: GET-Anfrage mit Want-Repr-Digest
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
Abbildung 34: Antwort mit nicht unterstütztem Algorithmus
C.3. Server unterstützt Client-Algorithmus nicht und gibt einen Fehler zurück
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.
Anhang C.2 ist ein Beispiel, bei dem ein Server den bevorzugten Digest-Algorithmus des Clients ignoriert. Alternativ kann ein Server die Anfrage auch ablehnen und eine Antwort mit einem Fehlerstatuscode wie 4xx oder 5xx zurückgeben. Diese Spezifikation schreibt keine Anforderung an die Auswahl des Statuscodes vor; das folgende Beispiel veranschaulicht eine mögliche Option.
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.
In diesem Beispiel fordert der Client einen "sha"-Repr-Digest an, und der Server gibt einen Fehler mit Problemdetails [RFC9457] im Inhalt zurück. Die Problemdetails enthalten eine Liste der Hashing-Algorithmen, die der Server unterstützt. Dies ist nur ein Beispiel; diese Spezifikation definiert kein Format oder Anforderungen für solche Inhalte.
GET /items/123 HTTP/1.1
Host: foo.example
Want-Repr-Digest: sha=10
Figure 35: GET Request with Want-Repr-Digest
Abbildung 35: GET-Anfrage mit Want-Repr-Digest
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
Abbildung 36: Antwort, die die unterstützten Algorithmen ankündigt