Post() public method

public Post ( ) : CouchRequest
return CouchRequest
Ejemplo n.º 1
0
        public Cookie GetSession()
        {
            var authCookie = cookiestore["authcookie"];

            if (authCookie != null)
                return authCookie;

            if (string.IsNullOrEmpty(username)) return null;
            var request = new CouchRequest(baseUri + "_session");
            request.GetRequest().Headers.Add("Authorization:Basic " + Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(username + ":" + password)));
            using (HttpWebResponse response = request.Post()
                .Form()
                .Data("name=" + username + "&password="******"Set-Cookie");
                if (header != null)
                {
                    var parts = header.Split(';')[0].Split('=');
                    authCookie = new Cookie(parts[0], parts[1]);
                    authCookie.Domain = response.Server;
                    cookiestore.Add("authcookie", authCookie, TimeSpan.FromMinutes(9));
                }
                return authCookie;
            }
        }
Ejemplo n.º 2
0
        public Cookie GetSession()
        {
            var authCookie = cookiestore["authcookie"];

            if (authCookie != null)
            {
                return(authCookie);
            }

            if (string.IsNullOrEmpty(username))
            {
                return(null);
            }
            var request = new CouchRequest(baseUri + "_session");

            request.GetRequest().Headers.Add("Authorization:Basic " + Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(username + ":" + password)));
            using (HttpWebResponse response = request.Post()
                                              .Form()
                                              .Data("name=" + username + "&password="******"Set-Cookie");
                if (header != null)
                {
                    var parts = header.Split(';')[0].Split('=');
                    authCookie        = new Cookie(parts[0], parts[1]);
                    authCookie.Domain = response.Server;
                    cookiestore.Add("authcookie", authCookie, TimeSpan.FromMinutes(9));
                }
                return(authCookie);
            }
        }
Ejemplo n.º 3
0
        protected Cookie GetSession()
        {
            var authCookie = cookiestore["authcookie"];

            if (authCookie != null)
                return authCookie;

            if (string.IsNullOrEmpty(username)) return null;
            var request = new CouchRequest(baseUri + "_session");
            var response = request.Post()
                .ContentType("application/x-www-form-urlencoded")
                .Data("name=" + username + "&password="******"Response from authentication post yielded a null reference exception.");
            }

            var header = response.Headers.Get("Set-Cookie");
            if (header != null)
            {
                var parts = header.Split(';')[0].Split('=');
                authCookie = new Cookie(parts[0], parts[1]);
                authCookie.Domain = response.Server;
                cookiestore.Add("authcookie", authCookie, TimeSpan.FromMinutes(9));
            }
            return authCookie;
        }
Ejemplo n.º 4
0
 public static bool Authenticate(string baseUri, string userName, string password)
 {
     if (!baseUri.Contains("http://"))
         baseUri = "http://" + baseUri;
     var request = new CouchRequest(baseUri + "/_session");
     var response = request.Post()
         .ContentType("application/x-www-form-urlencoded")
         .Data("name=" + userName + "&password=" + password)
         .Timeout(3000)
         .GetCouchResponse();
     return response.StatusCode == HttpStatusCode.OK;
 }
Ejemplo n.º 5
0
        public static bool Authenticate(string baseUri, string userName, string password)
        {
            if (!baseUri.Contains("http://"))
            {
                baseUri = "http://" + baseUri;
            }
            var request  = new CouchRequest(baseUri + "/_session");
            var response = request.Post()
                           .ContentType("application/x-www-form-urlencoded")
                           .Data("name=" + userName + "&password=" + password)
                           .Timeout(3000)
                           .GetCouchResponse();

            return(response.StatusCode == HttpStatusCode.OK);
        }
Ejemplo n.º 6
0
        protected Cookie GetSession()
        {
            if (string.IsNullOrEmpty(username)) return null;
            var request = new CouchRequest(baseUri + "_session");
            var response = request.Post()
                .ContentType("application/x-www-form-urlencoded")
                .Data("name=" + username + "&password="******"Set-Cookie");
            if (header != null)
            {
                var parts = header.Split(';')[0].Split('=');
                var authCookie = new Cookie(parts[0], parts[1]);
                authCookie.Domain = response.Server;
                return authCookie;
            }
            return null;
        }