Replies: 1 comment
|
Closing this — see the updated body. Payload checksum validation is already fully achievable today via a custom |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Overview
Response payload checksum validation (e.g. comparing a
Content-MD5/Digestresponse header against a locally computed hash) doesn't need new API in this package — it's already achievable today using the existing publicRequestTaskModifierprotocol, with no changes to the network layer.Why
TaskResult<Element>(returned by bothDataTask.result()andDownloadTask.result()) already exposes:head: ResponseHead, withheaders: HTTPHeaders(public, case-insensitive lookup via.first(name:))payload— eitherData(DataTask) or a streamableAsyncBytes(DownloadTask)A consumer can write their own
RequestTaskModifierthat reads the expected checksum from the response headers, computes the actual hash overpayloadusingswift-crypto/CryptoKit, and throws on mismatch:applied via
.modifier(ChecksumValidator()).This holds even for large/streamed downloads:
DownloadTask'spayloadis anAsyncBytesasync sequence, which a consumer can already feed into an incremental hasher chunk by chunk, without RequestDL needing to buffer or expose anything new.Decision
Closing as out of scope for the network layer — this is response post-processing (the same category as
.decode(...)), not something that needsPropertyNode/Internalsaccess, and the hashing primitives themselves belong inswift-crypto, not this package. If a named convenience (e.g. a bundledModifiers.Checksum) is ever wanted purely for discoverability, that can be revisited as pure sugar — it wouldn't add new capability, just a shortcut for the pattern above.All reactions