Skip to content

Commit 3fe9292

Browse files
committed
Add requests to examples
1 parent 97cc1f4 commit 3fe9292

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

draft-kleidl-digest-fields-problem-types.md

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,17 @@ This section defines the "https://iana.org/assignments/http-problem-types#invali
100100

101101
The server SHOULD include a human-readable description why the value is considered invalid in the `title` member.
102102

103-
The following example shows a response for a request with an invalid digest value.
103+
The following example shows a request with the content `{"hello": "world"}` (plus LF), but the digest has been truncated. The subsequent response indicates the invalid SHA-512 digest.
104+
105+
~~~ http-message
106+
PUT /items/123 HTTP/1.1
107+
Host: foo.example
108+
Content-Type: application/json
109+
Repr-Digest: sha-512=:YMAam51Jz/jOATT6/zvHrLVgOYTGFy1d6GJiOHTohq4:
110+
111+
{"hello": "world"}
112+
~~~
113+
{: title="A request with a sha-512 integrity field, whose digest has been truncated"}
104114

105115
~~~ http-message
106116
HTTP/1.1 400 Bad Request
@@ -111,6 +121,7 @@ Content-Type: application/problem+json
111121
"title": "digest value for sha-512 is not 64 bytes long"
112122
}
113123
~~~
124+
{: title="Response indicating that the provided digest is too short"}
114125

115126
This problem type indicates a fault in the sender's calculation or encoding of the digest value. A retry of the same request without modification will likely not yield a successful response.
116127

@@ -121,7 +132,17 @@ This section defines the "https://iana.org/assignments/http-problem-types#mismat
121132

122133
Three problem type extension members are defined: the `algorithm`, `provided-digest`, and `calculated-digest` members. A response using this problem type SHOULD populate all members, with the value of `algorithm` being the algorithm key of the used hashing algorithm, with the value of `provided-digest` being the digest value taken from the request's integrity fields, and the value of `calculated-digest` being the calculated digest. The digest values MUST BE serialized as byte sequences as described in {{Section 4.1.8 of STRUCTURED-FIELDS}}.
123134

124-
The following example shows a response for a request with a mismatching SHA-256 digest value.
135+
The following example shows a request with the content `{"hello": "woXYZ"}` (plus LF), but the representation digest for `{"hello": "world"}` (plus LF). The subsequent response indicates the mismatching SHA-256 digest values.
136+
137+
~~~ http-message
138+
PUT /items/123 HTTP/1.1
139+
Host: foo.example
140+
Content-Type: application/json
141+
Repr-Digest: sha-256=:RK/0qy18MlBSVnWgjwz6lZEWjP/lF5HF9bvEF8FabDg=:
142+
143+
{"hello": "woXYZ"}
144+
~~~
145+
{: title="A request with a sha-256 integrity field, which does not match the representation"}
125146

126147
~~~ http-message
127148
HTTP/1.1 400 Bad Request
@@ -132,9 +153,10 @@ Content-Type: application/problem+json
132153
"title": "digest value fromr request does not match expected value",
133154
"algorithm": "sha-256",
134155
"provided-digest": ":RK/0qy18MlBSVnWgjwz6lZEWjP/lF5HF9bvEF8FabDg=:",
135-
"calculated-digest": ":d435Qo+nKZ+gLcUHn7GQtQ72hiBVAgqoLsZnZPiTGPk=:"
156+
"calculated-digest": ":8vXo+0QVwf2woEblm4hTAftp0/K5fWSMZG4CKtplwjc=:"
136157
}
137158
~~~
159+
{: title="Response indicating the mismatching digests"}
138160

139161
If the sender receives this problem type, the request might be modified unintentionally by an intermediary. The sender could use this information to retry the request without modification to address temporary transmission issues.
140162

0 commit comments

Comments
 (0)