Skip to content

Commit 34ff9fb

Browse files
authored
Merge pull request #14 from tus/req-res
Add requests to examples
2 parents 193daf2 + 3fe9292 commit 34ff9fb

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
@@ -152,7 +152,17 @@ This section defines the "https://iana.org/assignments/http-problem-types#invali
152152

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

155-
The following example shows a response for a request with an invalid digest value.
155+
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.
156+
157+
~~~ http-message
158+
PUT /items/123 HTTP/1.1
159+
Host: foo.example
160+
Content-Type: application/json
161+
Repr-Digest: sha-512=:YMAam51Jz/jOATT6/zvHrLVgOYTGFy1d6GJiOHTohq4:
162+
163+
{"hello": "world"}
164+
~~~
165+
{: title="A request with a sha-512 integrity field, whose digest has been truncated"}
156166

157167
~~~ http-message
158168
HTTP/1.1 400 Bad Request
@@ -163,6 +173,7 @@ Content-Type: application/problem+json
163173
"title": "digest value for sha-512 is not 64 bytes long"
164174
}
165175
~~~
176+
{: title="Response indicating that the provided digest is too short"}
166177

167178
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.
168179

@@ -173,7 +184,17 @@ This section defines the "https://iana.org/assignments/http-problem-types#mismat
173184

174185
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}}.
175186

176-
The following example shows a response for a request with a mismatching SHA-256 digest value.
187+
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.
188+
189+
~~~ http-message
190+
PUT /items/123 HTTP/1.1
191+
Host: foo.example
192+
Content-Type: application/json
193+
Repr-Digest: sha-256=:RK/0qy18MlBSVnWgjwz6lZEWjP/lF5HF9bvEF8FabDg=:
194+
195+
{"hello": "woXYZ"}
196+
~~~
197+
{: title="A request with a sha-256 integrity field, which does not match the representation"}
177198

178199
~~~ http-message
179200
HTTP/1.1 400 Bad Request
@@ -184,9 +205,10 @@ Content-Type: application/problem+json
184205
"title": "digest value fromr request does not match expected value",
185206
"algorithm": "sha-256",
186207
"provided-digest": ":RK/0qy18MlBSVnWgjwz6lZEWjP/lF5HF9bvEF8FabDg=:",
187-
"calculated-digest": ":d435Qo+nKZ+gLcUHn7GQtQ72hiBVAgqoLsZnZPiTGPk=:"
208+
"calculated-digest": ":8vXo+0QVwf2woEblm4hTAftp0/K5fWSMZG4CKtplwjc=:"
188209
}
189210
~~~
211+
{: title="Response indicating the mismatching digests"}
190212

191213
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.
192214

0 commit comments

Comments
 (0)