예제 #1
0
        internal HttpWebRequest CreatePostHttpWebRequest(CloudFlareCredentials credentials, ApiAction action, HttpPostDataCollection postDataCollection)
        {
            var request = (HttpWebRequest)HttpWebRequest.Create(cloudFlareApiUrl);

            request.ContentType = formUrlEndodedContentType;
            request.Method      = WebRequestMethods.Http.Post;

            if (postDataCollection != null && postDataCollection.Count > 0)
            {
                postDataCollection = AppendApiActionToPostDataCollection(postDataCollection, action);
                postDataCollection = AppendCredentialsToPostDataCollection(postDataCollection, credentials);

                var postData       = postDataCollection.ToString();
                var postDataStream = Encoding.UTF8.GetBytes(postData);

                request.ContentLength = postData.Length;

                using (var requestStream = request.GetRequestStream())
                {
                    requestStream.Write(postDataStream, 0, postDataStream.Length);
                }
            }

            return(request);
        }
예제 #2
0
        internal HttpPostDataCollection AppendCredentialsToPostDataCollection(HttpPostDataCollection postDataCollection, CloudFlareCredentials credentials)
        {
            postDataCollection.Add("tkn", credentials.ApiKey);
            postDataCollection.Add("email", credentials.EmailAddress);

            return(postDataCollection);
        }
예제 #3
0
 public Client(string emailAddress, string apiKey)
 {
     this.credentials = new CloudFlareCredentials(emailAddress, apiKey);
 }
예제 #4
0
 public Client(CloudFlareCredentials credentials)
 {
     this.credentials = credentials;
 }
예제 #5
0
 public Client(string emailAddress, string apiKey)
 {
     this.credentials = new CloudFlareCredentials(emailAddress, apiKey);
 }
예제 #6
0
 public Client(CloudFlareCredentials credentials)
 {
     this.credentials = credentials;
 }