Appendice C. Esempi di Digest richiesto con 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.
I seguenti esempi mostrano interazioni in cui un client richiede un Repr-Digest utilizzando Want-Repr-Digest. Il comportamento di Content-Digest e Want-Content-Digest è identico.
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.
Alcuni esempi includono oggetti JSON nel contenuto. A scopo di presentazione, gli oggetti che rientrano completamente nei limiti di lunghezza della riga vengono presentati su una singola riga utilizzando una notazione compatta senza spazi iniziali. Gli oggetti che supererebbero i limiti di lunghezza della riga vengono presentati su più righe (una riga per coppia chiave-valore) con due spazi di rientro iniziale.
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.
I meccanismi di checksum descritti in questo documento sono indipendenti dal tipo di supporto e non forniscono algoritmi di canonicalizzazione per formati specifici. Gli esempi sono calcolati includendo qualsiasi spazio.
C.1. Il server seleziona l'algoritmo meno preferito dal client
The client requests a digest and prefers "sha". The server is free to reply with "sha-256" anyway.
Il client richiede un digest e preferisce "sha". Il server è libero di rispondere comunque con "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
Figura 31: Richiesta GET con 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
Figura 32: Risposta con algoritmo diverso
C.2. Il server seleziona un algoritmo non supportato dal client
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.
Il client richiede un digest "sha" perché è l'unico algoritmo che supporta. Il server non è obbligato a produrre una risposta contenente un digest "sha"; utilizza invece un algoritmo diverso.
GET /items/123 HTTP/1.1
Host: foo.example
Want-Repr-Digest: sha=10
Figure 33: GET Request with Want-Repr-Digest
Figura 33: Richiesta GET con 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
Figura 34: Risposta con algoritmo non supportato
C.3. Il server non supporta l'algoritmo del client e restituisce un errore
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.
L'Appendice C.2 è un esempio in cui un server ignora l'algoritmo di digest preferito dal client. In alternativa, un server può anche rifiutare la richiesta e restituire una risposta con un codice di stato di errore come 4xx o 5xx. Questa specifica non prescrive alcun requisito sulla selezione del codice di stato; l'esempio seguente illustra una possibile opzione.
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 questo esempio, il client richiede un Repr-Digest "sha" e il server restituisce un errore con i dettagli del problema [RFC9457] contenuti nel contenuto. I dettagli del problema contengono un elenco degli algoritmi di hashing supportati dal server. Questo è puramente un esempio; questa specifica non definisce alcun formato o requisito per tale contenuto.
GET /items/123 HTTP/1.1
Host: foo.example
Want-Repr-Digest: sha=10
Figure 35: GET Request with Want-Repr-Digest
Figura 35: Richiesta GET con 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
Figura 36: Risposta che pubblicizza gli algoritmi supportati