예제 #1
0
        public virtual void SetLocation(string url)
        {
            Url = url ?? throw new ArgumentNullException(url);
            GetParameter.Clear();
            var match = UrlRegex.Match(url);

            if (!match.Success)
            {
                DocumentPath      = url;
                DocumentPathTiles = new[] { url };
                CompleteGet       = "";
            }
            DocumentPath      = match.Groups[1].Value;
            DocumentPathTiles = match.Groups[2].Captures
                                .OfType <Capture>()
                                .Select(c => WebServerUtils.DecodeUri(c.Value))
                                .ToArray();
            CompleteGet = match.Groups[3].Success ? match.Groups[3].Value ?? "" : "";
            foreach (Capture capture in match.Groups[4].Captures)
            {
                var submatch = ArgsRegex.Match(capture.Value);
                if (submatch.Success)
                {
                    GetParameter[WebServerUtils.DecodeUri(submatch.Groups[1].Value)]
                        = WebServerUtils.DecodeUri(submatch.Groups[2].Value);
                }
                else
                {
                    GetParameter[capture.Value] = "";
                }
            }
        }
예제 #2
0
        public virtual void SetRequestCookieString(string cookie)
        {
            CompleteRequestCookie = cookie ?? throw new ArgumentNullException(nameof(cookie));
            AddedCookies.Clear();
            var reqCookie = new Dictionary <string, Cookie>();

            if (CompleteRequestCookie != "")
            {
                var tiles = CompleteRequestCookie.Split('&', ';');
                foreach (var tile in tiles)
                {
                    var ind = tile.IndexOf('=');
                    if (ind == -1)
                    {
                        var key = WebServerUtils.DecodeUri(tile.Trim());
                        if (!reqCookie.ContainsKey(key))
                        {
                            reqCookie.Add(key, new Cookie(key, ""));
                        }
                    }
                    else
                    {
                        var key   = WebServerUtils.DecodeUri(tile.Remove(ind).Trim());
                        var value = ind + 1 == tile.Length ? "" : WebServerUtils.DecodeUri(tile[(ind + 1)..]);