A wrapper stream which supresses disposal of the underlying stream.
Наследование: WrapperStream
        /// <summary>
        /// Writes a stream to the request body.
        /// </summary>
        /// <param name="requestContent">The destination where the content stream is written.</param>
        /// <param name="contentStream">The content stream to be written.</param>
        /// <param name="contentHeaders">HTTP content headers.</param>
        /// <param name="requestContext">The request context.</param>
        public void WriteToRequestBody(HttpContent requestContent, Stream contentStream,
                                       IDictionary <string, string> contentHeaders, IRequestContext requestContext)
        {
            var wrapperStream = new Amazon.Runtime.Internal.Util.NonDisposingWrapperStream(contentStream);

            _request.Content = new StreamContent(wrapperStream, requestContext.ClientConfig.BufferSize);
            _request.Content.Headers.ContentLength = contentStream.Length;
            WriteContentHeaders(contentHeaders);
        }
Пример #2
0
        /// <summary>
        /// Writes a stream to the request body.
        /// </summary>
        /// <param name="requestContent">The destination where the content stream is written.</param>
        /// <param name="contentStream">The content stream to be written.</param>
        /// <param name="contentHeaders">HTTP content headers.</param>
        /// <param name="requestContext">The request context.</param>
        public void WriteToRequestBody(HttpContent requestContent, Stream contentStream,
                                       IDictionary <string, string> contentHeaders, IRequestContext requestContext)
        {
            var wrapperStream = new Amazon.Runtime.Internal.Util.NonDisposingWrapperStream(contentStream);

            _request.Content = new StreamContent(wrapperStream, requestContext.ClientConfig.BufferSize);

            var chunkedUploadWrapperStream   = (contentStream as ChunkedUploadWrapperStream);
            var trailingHeadersWrapperStream = (contentStream as TrailingHeadersWrapperStream);

            if ((chunkedUploadWrapperStream == null && trailingHeadersWrapperStream == null) ||
                (chunkedUploadWrapperStream != null && chunkedUploadWrapperStream.HasLength) ||
                (trailingHeadersWrapperStream != null && trailingHeadersWrapperStream.HasLength))
            {
                _request.Content.Headers.ContentLength = contentStream.Length;
            }

            WriteContentHeaders(contentHeaders);
        }