1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- using COSXML.Common;
- using COSXML.Model.Tag;
- using COSXML.Network;
- using System.Collections.Generic;
- using System.Text;
- namespace COSXML.Model.Bucket
- {
- public sealed class PutBucketWebsiteRequest : BucketRequest
- {
- private WebsiteConfiguration websiteConfiguration;
- public PutBucketWebsiteRequest(string bucket) : base(bucket)
- {
- this.method = CosRequestMethod.PUT;
- this.queryParameters.Add("website", null);
- websiteConfiguration = new WebsiteConfiguration();
- }
- public void SetIndexDocument(string suffix)
- {
- if (suffix != null)
- {
- if (websiteConfiguration.indexDocument == null)
- {
- websiteConfiguration.indexDocument = new WebsiteConfiguration.IndexDocument();
- }
- websiteConfiguration.indexDocument.suffix = suffix;
- }
- }
- public void SetErrorDocument(string key)
- {
- if (key != null)
- {
- if (websiteConfiguration.errorDocument == null)
- {
- websiteConfiguration.errorDocument = new WebsiteConfiguration.ErrorDocument();
- }
- websiteConfiguration.errorDocument.key = key;
- }
- }
- public void SetRedirectAllRequestTo(string protocol)
- {
- if (protocol != null)
- {
- if (websiteConfiguration.redirectAllRequestTo == null)
- {
- websiteConfiguration.redirectAllRequestTo = new WebsiteConfiguration.RedirectAllRequestTo();
- }
- websiteConfiguration.redirectAllRequestTo.protocol = protocol;
- }
- }
- public void SetRoutingRules(List<WebsiteConfiguration.RoutingRule> rules)
- {
- if (rules != null && rules.Count > 0)
- {
- if (websiteConfiguration.routingRules == null)
- {
- websiteConfiguration.routingRules = new List<WebsiteConfiguration.RoutingRule>();
- }
- foreach (WebsiteConfiguration.RoutingRule rule in rules)
- {
- if (rule.contidion != null && rule.contidion.httpErrorCodeReturnedEquals == 0)
- {
- rule.contidion.httpErrorCodeReturnedEqualsStr = null;
- }
- else if (rule.contidion != null && rule.contidion.httpErrorCodeReturnedEquals != 0)
- {
- rule.contidion.httpErrorCodeReturnedEqualsStr = rule.contidion.httpErrorCodeReturnedEquals.ToString();
- }
- websiteConfiguration.routingRules.Add(rule);
- }
- }
- }
- public override Network.RequestBody GetRequestBody()
- {
- return GetXmlRequestBody(websiteConfiguration);
- }
- }
- }
|