Exemplo n.º 1
0
 public void Set_Fetch_cookie_from_jar_for_https()
 {
     List<DreamCookie> setcookies = new List<DreamCookie>();
     setcookies.Add(DreamCookie.NewSetCookie("authtoken", "1_633698885517217440_64e1d64e732341bde1797f20fe2ab824", new XUri("http:///"), DateTime.UtcNow.AddDays(2)));
     DreamCookieJar jar = new DreamCookieJar();
     jar.Update(setcookies,new XUri("https://*****:*****@wikiaddress//@api/deki/users/authenticate"));
     List<DreamCookie> cookies = jar.Fetch(new XUri("https://wikiaddress//@api/deki/Pages/home/files,subpages"));
     Assert.AreEqual(1,cookies.Count);
     Assert.AreEqual("/", cookies[0].Path);
     Assert.AreEqual("1_633698885517217440_64e1d64e732341bde1797f20fe2ab824", cookies[0].Value);
     Assert.AreEqual("authtoken", cookies[0].Name);
 }
Exemplo n.º 2
0
 public void Fetch_cookie_from_jar()
 {
     DreamCookie setcookie = DreamCookie.NewSetCookie("test", "123", new XUri("http://bar.com/foo"));
     List<DreamCookie> cookies = new List<DreamCookie>();
     cookies.Add(setcookie);
     DreamCookieJar jar = new DreamCookieJar();
     jar.Update(cookies, null);
     List<DreamCookie> cookies2 = jar.Fetch(new XUri("http://bar.com/foo/baz"));
     Assert.AreEqual(1, cookies2.Count);
     Assert.AreEqual("/foo", cookies2[0].Path);
     Assert.AreEqual("bar.com", cookies2[0].Domain);
 }
Exemplo n.º 3
0
Arquivo: Plug.cs Projeto: bjorg/DReAM
        private static DreamMessage PreProcess(string verb, XUri uri, XUri normalizedUri, DreamHeaders headers, DreamCookieJar cookies, DreamMessage message) {

            // check if plug is running in the context of a service
            DreamContext context = DreamContext.CurrentOrNull;
            if(context != null) {

                // set request id header
                message.Headers.DreamRequestId = context.GetState<string>(DreamHeaders.DREAM_REQUEST_ID);

                // set dream service header
                if(context.Service.Self != null) {
                    message.Headers.DreamService = context.AsPublicUri(context.Service.Self).ToString();
                }

                // check if uri is local://
                if(normalizedUri.Scheme.EqualsInvariant("local")) {
                    DreamUtil.AppendHeadersToInternallyForwardedMessage(context.Request, message);
                }
            }

            if(cookies != null) {
                lock(cookies) {
                    message.Cookies.AddRange(cookies.Fetch(uri));
                }
            }

            // transfer plug headers
            message.Headers.AddRange(headers);
            return message;
        }