Пример #1
0
        public static MemeRequest FromUrl(string url, HttpServerUtilityBase serverUtility)
        {
            // decode any %-encodings
            url = serverUtility.UrlDecode(url) ?? "";
            
            // decode html entities, e.g. >
            // Note: this would technically work for entites with a hash sign, e.g. ', _but_
            // the browser doesn't send anything after the hash sign because it's part of the url
            // fragment...so we're sol when it comes to those
            url = WebUtility.HtmlDecode(url); 

            // strip off any file extensions
            var isDebugMode = url.Contains("debugMode=true");
            url = _StripRegex.Replace(url, "");

            var memeRequest = MemeUtilities.GetMemeRequest(url);
            memeRequest.IsDebugMode = isDebugMode;

            return memeRequest;
        }
Пример #2
0
        private IEnumerable<Cookie> GetCookies(HttpRequestBase httpRequest, HttpServerUtilityBase server)
        {
            if (httpRequest != null)
            {
                var cookies = httpRequest.Cookies;

                if (cookies != null)
                {
                    foreach (var key in cookies.AllKeys)
                    {
                        var cookie = cookies[key];

                        if (cookie != null)
                        {
                            yield return new Cookie
                                {
                                    Name = cookie.Name,
                                    Value = server.UrlDecode(cookie.Value)
                                };
                        }
                    }
                }
            }
        }