/// <summary>
        /// Set the specified key, entry and validFor.
        /// </summary>
        /// <returns>The set.</returns>
        /// <param name="key">Key.</param>
        /// <param name="entry">Entry.</param>
        /// <param name="validFor">Valid for.</param>
        public void Set(string key, IResponseCacheEntry entry, TimeSpan validFor)
        {
            if (entry is CachedResponse cachedResponse)
            {
                var segmentStream = new SegmentWriteStream(StreamUtilities.BodySegmentSize);
                cachedResponse.Body.CopyTo(segmentStream);

                _provider.Set(
                    key,
                    new EasyCachingResponse
                {
                    Created      = cachedResponse.Created,
                    StatusCode   = cachedResponse.StatusCode,
                    Headers      = cachedResponse.Headers,
                    BodySegments = segmentStream.GetSegments(),
                    BodyLength   = segmentStream.Length
                },
                    validFor);
            }
            else
            {
                _provider.Set(
                    key,
                    entry,
                    validFor);
            }
        }
 internal Stream GetBufferStream()
 {
     if (!BufferingEnabled)
     {
         throw new InvalidOperationException("Buffer stream cannot be retrieved since buffering is disabled.");
     }
     return(new SegmentReadStream(_segmentWriteStream.GetSegments(), _segmentWriteStream.Length));
 }