Пример #1
0
        protected SailthruResponse SendRequest(HttpWebRequest request, String action)
        {
            SailthruResponse sailthruResponse;
            try 
            {
                sailthruResponse = new SailthruResponse((HttpWebResponse)request.GetResponse());
            } 
            catch (WebException e) 
            {
                using (HttpWebResponse errorResponse = (HttpWebResponse)e.Response)
                {
                    sailthruResponse = new SailthruResponse((HttpWebResponse)errorResponse);
                }
            }

            Hashtable rateLimitInfo = sailthruResponse.getRateLimitInfo();
            if (rateLimitInfo.Count > 0)
            {
                if (lastRateLimitInfo.ContainsKey(action))
                {
                    Hashtable rateLimitPerMethod = (Hashtable) lastRateLimitInfo[action];
                    rateLimitPerMethod[request.Method] = rateLimitInfo;
                }
                else
                {
                    Hashtable rateLimitPerMethod = new Hashtable();
                    rateLimitPerMethod.Add(request.Method, rateLimitInfo);
                    lastRateLimitInfo.Add(action, rateLimitPerMethod);
                }
            }

            return sailthruResponse;
        }
Пример #2
0
        /// <summary>
        /// Receive and verify the output of a Post.
        /// </summary>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public bool ReceiveVerifyPost(NameValueCollection parameters)
        {
            List<string> requiredParams = new List<string> { "action", "email", "send_id", "sig" };
            foreach (String key in parameters.Keys) {
                if (!requiredParams.Contains(key)) {
                    return false;
                }
            }

            if (parameters.Get("action") != "verify" && parameters.Get("send_id") != null) {
                return false;
            }

            //check signature of request against parameter data
            string providedSignature = parameters["sig"];
            parameters.Remove("sig");
            if (providedSignature != GetSignatureHash(parameters)) {
                return false;
            }

            SailthruResponse response = GetSend(parameters["send_id"]);
            var hash = response.HashtableResponse;
            if (hash.ContainsKey("email"))
            {
                return ((String)hash["email"] == parameters["email"]);
            }
            return false;
        }
        protected SailthruResponse SendRequest(HttpWebRequest request, String action)
        {
            SailthruResponse sailthruResponse;
            try
            {
                sailthruResponse = new SailthruResponse((HttpWebResponse)request.GetResponse());
            }
            catch (WebException e)
            {
                using (HttpWebResponse errorResponse = (HttpWebResponse)e.Response)
                {
                    sailthruResponse = new SailthruResponse((HttpWebResponse)errorResponse);
                }
            }

            Hashtable rateLimitInfo = sailthruResponse.getRateLimitInfo();
            if (rateLimitInfo.Count > 0)
            {
                if (lastRateLimitInfo.ContainsKey(action))
                {
                    Hashtable rateLimitPerMethod = (Hashtable) lastRateLimitInfo[action];
                    rateLimitPerMethod.Add(request.Method, rateLimitInfo);
                }
                else
                {
                    Hashtable rateLimitPerMethod = new Hashtable();
                    rateLimitPerMethod.Add(request.Method, rateLimitInfo);
                    lastRateLimitInfo.Add(action, rateLimitPerMethod);
                }
            }

            return sailthruResponse;
        }