Example #1
0
        public string Source(Request request)
        {
            Dictionary <string, string> sourceHeaders         = request.Headers;
            Dictionary <string, string> lowerKeySourceHeaders = new Dictionary <string, string>(sourceHeaders.Count);

            foreach (KeyValuePair <string, string> pair in sourceHeaders)
            {
                lowerKeySourceHeaders.Add(pair.Key.ToLower(), pair.Value);
            }
            try
            {
                lowerKeySourceHeaders.Add("host", request.Host);
            }
            catch (Exception)
            {
            }
            try
            {
                lowerKeySourceHeaders.Add("user-agent", request.UserAgent);
            }
            catch (Exception)
            { }
            Dictionary <string, string> sourceParameters         = request.Url.GetQueryParameters();
            Dictionary <string, string> lowerKeySourceParameters = new Dictionary <string, string>(sourceParameters.Count);

            foreach (KeyValuePair <string, string> pair in sourceParameters)
            {
                lowerKeySourceParameters.Add(pair.Key.ToLower(), pair.Value);
            }
            string path = URLEncodeUtils.Decode(request.Url.Path);

            return(GenerateSource(request.Method, path, lowerKeySourceParameters, lowerKeySourceHeaders));
        }
Example #2
0
        public string Source(Request request)
        {
            Dictionary <string, string> sourceHeaders         = request.Headers;
            Dictionary <string, string> lowerKeySourceHeaders = new Dictionary <string, string>(sourceHeaders.Count);

            foreach (KeyValuePair <string, string> pair in sourceHeaders)
            {
                lowerKeySourceHeaders.Add(pair.Key.ToLower(), pair.Value);
                if (signAll)
                {
                    headerKeys.Add(pair.Key.ToLower());
                }
            }
            try
            {
                lowerKeySourceHeaders.Add("host", request.Host);
                headerKeys.Add("host");
            }
            catch (Exception)
            {
            }
            if (signAll)
            {
                try
                {
                    long contentLength = 0;
                    if (request.Body != null)
                    {
                        contentLength = request.Body.ContentLength;
                    }
                    if (contentLength > 0)
                    {
                        lowerKeySourceHeaders.Add("content-length", contentLength.ToString());
                        headerKeys.Add("content-length");
                    }
                }
                catch (Exception) {}
            }
            Dictionary <string, string> sourceParameters         = request.Url.GetQueryParameters();
            Dictionary <string, string> lowerKeySourceParameters = new Dictionary <string, string>(sourceParameters.Count);

            foreach (KeyValuePair <string, string> pair in sourceParameters)
            {
                lowerKeySourceParameters.Add(pair.Key.ToLower(), pair.Value);
                if (signAll)
                {
                    parameterKeys.Add(pair.Key.ToLower());
                }
            }
            string path = URLEncodeUtils.Decode(request.Url.Path);

            return(GenerateSource(request.Method, path, lowerKeySourceParameters, lowerKeySourceHeaders));
        }