Example #1
0
        /// <summary>
        /// Checks the validity of the contents MD5 hash.
        /// </summary>
        /// <param name="content"></param>
        /// <returns></returns>
        public static async Task <bool> IsMd5Valid(this HttpContent content)
        {
            var hashHeader = content?.Headers.ContentMD5;

            if (hashHeader == null)
            {
                // TODO: Should we always require one if we have non-null content?
                // No MD5 hash so true
                return(true);
            }

            var hash = await content.ComputeMd5HashByte().ConfigureAwait(false);

            return(hash.SequenceEqual(hashHeader));
        }
Example #2
0
 /// <summary>
 /// Compute the MD5 hash of the content.
 /// </summary>
 /// <param name="httpContent"></param>
 /// <returns></returns>
 public static Task <byte[]> ComputeMd5Hash(this HttpContent httpContent)
 {
     // NB Using HashStream here causes some tests to fail
     return(httpContent.ComputeMd5HashByte());
 }
Example #3
0
 /// <summary>
 /// Compute the MD5 hash of the content.
 /// </summary>
 /// <param name="httpContent"></param>
 /// <returns></returns>
 public static async Task <byte[]> ComputeMd5Hash(this HttpContent httpContent)
 {
     // NB Using HashStream here causes some tests to fail
     return(await httpContent.ComputeMd5HashByte().ConfigureAwait(false));
 }