Exemplo n.º 1
0
        static public IAsyncOperation <HttpRandomAccessStream> CreateAsync(HttpClient client, Uri uri)
        {
            HttpRandomAccessStream randomStream = new HttpRandomAccessStream(client, uri);

            return(AsyncInfo.Run <HttpRandomAccessStream>(async(cancellationToken) =>
            {
                await randomStream.SendRequesAsync().ConfigureAwait(false);
                return randomStream;
            }));
        }
        public static async Task <HttpRandomAccessStream> ExecuteRequestVideo(string host, string port, string user, string pass, string requestData)
        {
            var httpClient = new Windows.Web.Http.HttpClient();

            var urlString  = "http://" + host + ":" + port + "/" + requestData;
            var authString = user + ":" + pass;

            try
            {
                var uriString = new Uri(urlString);

                var encoded = Convert.ToBase64String(Encoding.UTF8.GetBytes(authString));

                httpClient.DefaultRequestHeaders.Add("Authorization", "Basic " + encoded);

                var stream = await HttpRandomAccessStream.CreateAsync(httpClient, uriString);

                return(stream);
            }
            catch
            {
                return(null);
            }
        }