From 0f4438e7f5107d8b06142894d2d9cd5186b721ab Mon Sep 17 00:00:00 2001 From: Nathaniel McCallum Date: Wed, 30 Mar 2022 12:52:46 -0400 Subject: [PATCH] feat: add support for the digest headers This commit adds support for the following headers: * Repr-Digest * Content-Digest * Want-ReprDigest * Want-Content-Digest These headers are defined in the following upcoming RFC: https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-digest-headers-08 Signed-off-by: Nathaniel McCallum --- src/header/mod.rs | 4 ++++ src/header/name.rs | 52 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/src/header/mod.rs b/src/header/mod.rs index 6c1b4955..b5948f6e 100644 --- a/src/header/mod.rs +++ b/src/header/mod.rs @@ -102,6 +102,7 @@ pub use self::name::{ AUTHORIZATION, CACHE_CONTROL, CONNECTION, + CONTENT_DIGEST, CONTENT_DISPOSITION, CONTENT_ENCODING, CONTENT_LANGUAGE, @@ -139,6 +140,7 @@ pub use self::name::{ REFERER, REFERRER_POLICY, REFRESH, + REPR_DIGEST, RETRY_AFTER, SEC_WEBSOCKET_ACCEPT, SEC_WEBSOCKET_EXTENSIONS, @@ -156,6 +158,8 @@ pub use self::name::{ USER_AGENT, VARY, VIA, + WANT_CONTENT_DIGEST, + WANT_REPR_DIGEST, WARNING, WWW_AUTHENTICATE, X_CONTENT_TYPE_OPTIONS, diff --git a/src/header/name.rs b/src/header/name.rs index eb17a423..902ae854 100644 --- a/src/header/name.rs +++ b/src/header/name.rs @@ -350,6 +350,18 @@ standard_headers! { /// is not mandatory. (Connection, CONNECTION, "connection"); + /// A cryptographic digest over the message contents. + /// + /// For example: + /// + /// ``` + /// Content-Digest: sha-256=:4REjxQ4yrqUVicfSKYNO/cF9zNj5ANbzgDZt3/h3Qxo=: + /// ``` + /// + /// As this is a structured field (dictionary), multiple digests may be + /// specified. This header may be used in either requests or responses. + (ContentDigest, CONTENT_DIGEST, "content-digest"); + /// Indicates if the content is expected to be displayed inline. /// /// In a regular HTTP response, the Content-Disposition response header is a @@ -778,6 +790,18 @@ standard_headers! { /// refreshed. (Refresh, REFRESH, "refresh"); + /// A cryptographic digest over the "selected representation data." + /// + /// For example: + /// + /// ``` + /// Repr-Digest: sha-256=:4REjxQ4yrqUVicfSKYNO/cF9zNj5ANbzgDZt3/h3Qxo=: + /// ``` + /// + /// As this is a structured field (dictionary), multiple digests may be + /// specified. This header may be used in either requests or responses. + (ReprDigest, REPR_DIGEST, "repr-digest"); + /// The Retry-After response HTTP header indicates how long the user agent /// should wait before making a follow-up request. There are two main cases /// this header is used: @@ -902,6 +926,34 @@ standard_headers! { /// request/response chain. (Via, VIA, "via"); + /// Indicates preference for a particular content digest algorithm. + /// + /// For example: + /// + /// ``` + /// Want-Content-Digest: sha-512=3, sha-256=10, unixsum=0 + /// ``` + /// + /// This dictionary structured field contains digest algorithms as keys + /// and the preference (`0`-`10`, inclusive) for that algorithm. `10` + /// indicates the most preferred algorithm and `0` indicates "not + /// acceptable". + (WantContentDigest, WANT_CONTENT_DIGEST, "want-content-digest"); + + /// Indicates preference for a particular representation digest algorithm. + /// + /// For example: + /// + /// ``` + /// Want-Repr-Digest: sha-512=3, sha-256=10, unixsum=0 + /// ``` + /// + /// This dictionary structured field contains digest algorithms as keys + /// and the preference (`0`-`10`, inclusive) for that algorithm. `10` + /// indicates the most preferred algorithm and `0` indicates "not + /// acceptable". + (WantReprDigest, WANT_REPR_DIGEST, "want-repr-digest"); + /// General HTTP header contains information about possible problems with /// the status of the message. ///