Esempio n. 1
0
        private async void OnNodeSelected(object sender, TreeViewEventArgs e)
        {
            var entity    = e.Node.Tag as MimeEntity;
            var multipart = entity as Multipart;
            var part      = entity as MimePart;

            byte[] body = new byte[] { };

            if (multipart != null)
            {
                body = Encoding.UTF8.GetBytes(multipart.Preamble);
            }

            if (part != null && part.ContentObject != null)
            {
                Stream stream = part.ContentObject.Open();

                if (string.Equals(part.ContentType?.MimeType, "application/gzip", System.StringComparison.OrdinalIgnoreCase))
                {
                    stream = await GZipCompressor.DecompressAsync(stream);
                }

                body = await StreamUtilities.ReadFullyAsync(stream);
            }

            var httpHeaders = new HTTPRequestHeaders();

            if (entity != null)
            {
                foreach (var header in entity.Headers)
                {
                    httpHeaders.Add(header.Field, header.Value);
                }
            }
            _headersRequest.headers = httpHeaders;

            _rawRequest.body = body;
            _xmlRequest.body = body;
        }