예제 #1
0
        public void silly_with_works()
        {
            var state = new CookieState("key").With("a", "1").With("b", "2");

            state["a"].ShouldBe("1");
            state["b"].ShouldBe("2");
        }
예제 #2
0
        public static Cookie ToCookie(string headerValue)
        {
            if (headerValue.IsEmpty())
            {
                return(null);
            }

            var cookie = new Cookie();

            var segments = headerValue.TrimEnd().TrimEnd(';').Split(';').Select(x => new Segment(x.Trim()));

            segments.Each(segment => {
                string canonicalKey = segment.Key.ToLowerInvariant();

                if (_setters.Has(canonicalKey))
                {
                    _setters[canonicalKey](cookie, segment.Value);
                }
                else
                {
                    var state = CookieState.For(segment);
                    cookie.Add(state);
                }
            });

            return(cookie);
        }
예제 #3
0
 public Cookie(string name, string value)
 {
     var state = new CookieState(name, value);
     _states.Add(state);
 }
예제 #4
0
 public Cookie Add(CookieState state)
 {
     _states.Add(state);
     return this;
 }
예제 #5
0
        public Cookie(string name, string value)
        {
            var state = new CookieState(name, value);

            _states.Add(state);
        }
예제 #6
0
 public Cookie Add(CookieState state)
 {
     _states.Add(state);
     return(this);
 }