コード例 #1
0
        protected Stream GetBodyStream(MultipartSection section)
        {
            Stream stream = new StreamWithTimeout(GetDecompressedStream(section.Body, section.Headers));

            _context.HttpContext.Response.RegisterForDispose(stream);
            return(stream);
        }
コード例 #2
0
            public override async Task <ResponseDisposeHandling> ProcessResponse(JsonOperationContext context, HttpCache cache, HttpResponseMessage response, string url)
            {
                var  contentType  = response.Content.Headers.TryGetValues("Content-Type", out IEnumerable <string> contentTypeVale) ? contentTypeVale.First() : null;
                var  changeVector = response.GetEtagHeader();
                var  hash         = response.Headers.TryGetValues("Attachment-Hash", out IEnumerable <string> hashVal) ? hashVal.First() : null;
                long size         = 0;

                if (response.Headers.TryGetValues("Attachment-Size", out IEnumerable <string> sizeVal))
                {
                    long.TryParse(sizeVal.First(), out size);
                }

                var attachmentDetails = new AttachmentDetails
                {
                    ContentType  = contentType,
                    Name         = _name,
                    Hash         = hash,
                    Size         = size,
                    ChangeVector = changeVector,
                    DocumentId   = _documentId
                };

                var responseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false);

                var streamReader = new StreamWithTimeout(responseStream);
                var stream       = new AttachmentStream(response, streamReader);

                Result = new AttachmentResult
                {
                    Stream  = stream,
                    Details = attachmentDetails
                };

                return(ResponseDisposeHandling.Manually);
            }
コード例 #3
0
ファイル: RavenDB_14520.cs プロジェクト: syrjgc11006/ravendb
        public void ReadOnlyStreamShouldNotThrow()
        {
            var streamWithTimeout = new StreamWithTimeout(new MyReadOnlyStream());

            streamWithTimeout.ReadTimeout = 10;
        }