/// <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 ResponseCachingStream(Stream innerStream, long maxBufferSize, int segmentSize, Action startResponseCallback, Func <Task> startResponseCallbackAsync)
 {
     _innerStream                = innerStream;
     _maxBufferSize              = maxBufferSize;
     _segmentSize                = segmentSize;
     _startResponseCallback      = startResponseCallback;
     _startResponseCallbackAsync = startResponseCallbackAsync;
     _segmentWriteStream         = new SegmentWriteStream(_segmentSize);
 }