Exemplo n.º 1
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);
            }
Exemplo n.º 2
0
 public AttachmentEnumeratorResult(AttachmentDetails details, Stream stream)
 {
     Details = details;
     Stream  = stream;
 }