本文整理汇总了C#中net.openstack.Providers.Rackspace.CloudFilesProvider.UpdateContainerCdnHeaders方法的典型用法代码示例。如果您正苦于以下问题:C# CloudFilesProvider.UpdateContainerCdnHeaders方法的具体用法?C# CloudFilesProvider.UpdateContainerCdnHeaders怎么用?C# CloudFilesProvider.UpdateContainerCdnHeaders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.openstack.Providers.Rackspace.CloudFilesProvider
的用法示例。
在下文中一共展示了CloudFilesProvider.UpdateContainerCdnHeaders方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Should_Add_CDN_Headers_For_Container
public void Should_Add_CDN_Headers_For_Container()
{
var provider = new CloudFilesProvider();
Dictionary<string, string> headers = new Dictionary<string, string>();
headers.Add("X-Log-Retention", "false");
provider.UpdateContainerCdnHeaders(containerName, headers, identity: _testIdentity);
}
示例2: Should_Not_Add_CDN_Headers_For_Container
public void Should_Not_Add_CDN_Headers_For_Container()
{
var provider = new CloudFilesProvider();
Dictionary<string, string> headers = new Dictionary<string, string>();
headers.Add("X-Log-Retention", "false");
provider.UpdateContainerCdnHeaders(containerName, headers, identity: _testIdentity);
Assert.Fail("Expected exception was not thrown.");
}
示例3: 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)
//.........这里部分代码省略.........