当前位置: 首页>>代码示例>>C#>>正文


C# CloudFilesProvider.GetContainerCDNHeader方法代码示例

本文整理汇总了C#中net.openstack.Providers.Rackspace.CloudFilesProvider.GetContainerCDNHeader方法的典型用法代码示例。如果您正苦于以下问题:C# CloudFilesProvider.GetContainerCDNHeader方法的具体用法?C# CloudFilesProvider.GetContainerCDNHeader怎么用?C# CloudFilesProvider.GetContainerCDNHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.openstack.Providers.Rackspace.CloudFilesProvider的用法示例。


在下文中一共展示了CloudFilesProvider.GetContainerCDNHeader方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Should_Make_Container_CDN_Disabled

        public void Should_Make_Container_CDN_Disabled()
        {
            var provider = new CloudFilesProvider();
            var cdnEnabledResponse = provider.DisableCDNOnContainer(containerName, identity: _testIdentity);

            var cdnContainerHeaderResponse = provider.GetContainerCDNHeader(containerName, identity: _testIdentity);

            Assert.IsFalse(cdnContainerHeaderResponse.CDNEnabled);
        }
开发者ID:Dan-Pallone-II,项目名称:openstack.net,代码行数:9,代码来源:CloudFilesTests.cs

示例2: Should_Make_Container_CDN_Enabled_With_Log_Retention

        public void Should_Make_Container_CDN_Enabled_With_Log_Retention()
        {
            var provider = new CloudFilesProvider();
            var cdnEnabledResponse = provider.EnableCDNOnContainer(containerName, true, identity: _testIdentity);

            var cdnContainerHeaderResponse = provider.GetContainerCDNHeader(containerName, identity: _testIdentity);

            Assert.AreEqual(259200, cdnContainerHeaderResponse.Ttl);
            Assert.IsTrue(cdnContainerHeaderResponse.LogRetention);
            Assert.IsTrue(cdnContainerHeaderResponse.CDNEnabled);
            Assert.IsTrue(!string.IsNullOrWhiteSpace(cdnContainerHeaderResponse.CDNIosUri));
            Assert.IsTrue(containerName.Equals(cdnContainerHeaderResponse.Name, StringComparison.InvariantCultureIgnoreCase));

        }
开发者ID:Dan-Pallone-II,项目名称:openstack.net,代码行数:14,代码来源:CloudFilesTests.cs

示例3: Should_Make_Container_CDN_Enabled_With_TTL

        public void Should_Make_Container_CDN_Enabled_With_TTL()
        {
            var provider = new CloudFilesProvider();
            var cdnEnabledResponse = provider.EnableCDNOnContainer(containerName, 1000, identity: _testIdentity);

            var cdnContainerHeaderResponse = provider.GetContainerCDNHeader(containerName, identity: _testIdentity);

            Assert.AreEqual(1000, cdnContainerHeaderResponse.Ttl);
            Assert.IsTrue(cdnContainerHeaderResponse.CDNEnabled);

        }
开发者ID:Dan-Pallone-II,项目名称:openstack.net,代码行数:11,代码来源:CloudFilesTests.cs

示例4: Should_Not_Get_CDN_Headers_For_Container

        public void Should_Not_Get_CDN_Headers_For_Container()
        {
            var provider = new CloudFilesProvider();
            var objectHeadersResponse = provider.GetContainerCDNHeader(containerName, identity: _testIdentity);

            Assert.Fail("Expected exception was not thrown.");
        }
开发者ID:Dan-Pallone-II,项目名称:openstack.net,代码行数:7,代码来源:CloudFilesTests.cs

示例5: Should_Get_CDN_Headers_For_Container

        public void Should_Get_CDN_Headers_For_Container()
        {
            var provider = new CloudFilesProvider();
            var objectHeadersResponse = provider.GetContainerCDNHeader(containerName, identity: _testIdentity);

            Assert.IsNotNull(objectHeadersResponse);
        }
开发者ID:Dan-Pallone-II,项目名称:openstack.net,代码行数:7,代码来源:CloudFilesTests.cs

示例6: TestCDNOnContainer

        public void TestCDNOnContainer()
        {
            IObjectStorageProvider provider = new CloudFilesProvider(Bootstrapper.Settings.TestIdentity);
            string containerName = TestContainerPrefix + Path.GetRandomFileName();
            string objectName = Path.GetRandomFileName();
            string fileContents = "File contents!";

            ObjectStore result = provider.CreateContainer(containerName);
            Assert.AreEqual(ObjectStore.ContainerCreated, result);

            Stream stream = new MemoryStream(Encoding.UTF8.GetBytes(fileContents));
            provider.CreateObject(containerName, stream, objectName);

            Dictionary<string, string> cdnHeaders = provider.EnableCDNOnContainer(containerName, false);
            Assert.IsNotNull(cdnHeaders);
            Console.WriteLine("CDN Headers from EnableCDNOnContainer");
            foreach (var pair in cdnHeaders)
                Console.WriteLine("    {0}: {1}", pair.Key, pair.Value);

            ContainerCDN containerHeader = provider.GetContainerCDNHeader(containerName);
            Assert.IsNotNull(containerHeader);
            Console.WriteLine(JsonConvert.SerializeObject(containerHeader, Formatting.Indented));
            Assert.IsTrue(containerHeader.CDNEnabled);
            Assert.IsFalse(containerHeader.LogRetention);
            Assert.IsTrue(
                containerHeader.CDNUri != null
                || containerHeader.CDNIosUri != null
                || containerHeader.CDNSslUri != null
                || containerHeader.CDNStreamingUri != null);

            // Call the other overloads of EnableCDNOnContainer
            cdnHeaders = provider.EnableCDNOnContainer(containerName, containerHeader.Ttl);
            ContainerCDN updatedHeader = provider.GetContainerCDNHeader(containerName);
            Console.WriteLine(JsonConvert.SerializeObject(updatedHeader, Formatting.Indented));
            Assert.IsNotNull(updatedHeader);
            Assert.IsTrue(updatedHeader.CDNEnabled);
            Assert.IsFalse(updatedHeader.LogRetention);
            Assert.IsTrue(
                updatedHeader.CDNUri != null
                || updatedHeader.CDNIosUri != null
                || updatedHeader.CDNSslUri != null
                || updatedHeader.CDNStreamingUri != null);
            Assert.AreEqual(containerHeader.Ttl, updatedHeader.Ttl);

            cdnHeaders = provider.EnableCDNOnContainer(containerName, containerHeader.Ttl, true);
            updatedHeader = provider.GetContainerCDNHeader(containerName);
            Console.WriteLine(JsonConvert.SerializeObject(updatedHeader, Formatting.Indented));
            Assert.IsNotNull(updatedHeader);
            Assert.IsTrue(updatedHeader.CDNEnabled);
            Assert.IsTrue(updatedHeader.LogRetention);
            Assert.IsTrue(
                updatedHeader.CDNUri != null
                || updatedHeader.CDNIosUri != null
                || updatedHeader.CDNSslUri != null
                || updatedHeader.CDNStreamingUri != null);
            Assert.AreEqual(containerHeader.Ttl, updatedHeader.Ttl);

            // update the container CDN properties
            Dictionary<string, string> headers = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
            {
                { CloudFilesProvider.CdnTTL, (updatedHeader.Ttl + 1).ToString() },
                { CloudFilesProvider.CdnLogRetention, false.ToString() },
                //{ CloudFilesProvider.CdnEnabled, true.ToString() },
            };

            provider.UpdateContainerCdnHeaders(containerName, headers);
            updatedHeader = provider.GetContainerCDNHeader(containerName);
            Console.WriteLine(JsonConvert.SerializeObject(updatedHeader, Formatting.Indented));
            Assert.IsNotNull(updatedHeader);
            Assert.IsTrue(updatedHeader.CDNEnabled);
            Assert.IsFalse(updatedHeader.LogRetention);
            Assert.IsTrue(
                updatedHeader.CDNUri != null
                || updatedHeader.CDNIosUri != null
                || updatedHeader.CDNSslUri != null
                || updatedHeader.CDNStreamingUri != null);
            Assert.AreEqual(containerHeader.Ttl + 1, updatedHeader.Ttl);

            // attempt to access the container over the CDN
            if (containerHeader.CDNUri != null || containerHeader.CDNSslUri != null)
            {
                string baseUri = containerHeader.CDNUri ?? containerHeader.CDNSslUri;
                Uri uri = new Uri(containerHeader.CDNUri + '/' + objectName);
                WebRequest request = HttpWebRequest.Create(uri);
                using (WebResponse response = request.GetResponse())
                {
                    Stream cdnStream = response.GetResponseStream();
                    StreamReader reader = new StreamReader(cdnStream, Encoding.UTF8);
                    string text = reader.ReadToEnd();
                    Assert.AreEqual(fileContents, text);
                }
            }
            else
            {
                Assert.Inconclusive("This integration test relies on cdn_uri or cdn_ssl_uri.");
            }

            IEnumerable<ContainerCDN> containers = ListAllCDNContainers(provider);
            Console.WriteLine("Containers");
            foreach (ContainerCDN container in containers)
//.........这里部分代码省略.........
开发者ID:nick-o,项目名称:openstack.net,代码行数:101,代码来源:UserObjectStorageTests.cs


注:本文中的net.openstack.Providers.Rackspace.CloudFilesProvider.GetContainerCDNHeader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。