示例#1
0
 public EtcdClient(Uri etcdLocation)
 {
     var uriBuilder = new UriBuilder(etcdLocation)
     {
        Path = ""
     };
     _root = uriBuilder.Uri;
     _keysRoot = _root.AppendPath("v2").AppendPath("keys");
     _client = new RestClient(_root.ToString());
 }
 private static string AppendRelativeURLString(Uri remote, string relativePath)
 {
     var uri = remote.AppendPath(relativePath);
     return uri.AbsoluteUri;
 }
        public virtual void TestAppendPathURLString([Values("http://10.0.0.3:4984/connect-2014", "http://10.0.0.3:4984/connect-2014/")] String baseUri, [Values("/_bulk_get?revs=true&attachments=true", "_bulk_get?revs=true&attachments=true")] String newPath)
        {
            if (!Boolean.Parse((string)GetProperty("replicationTestsEnabled")))
            {
                Assert.Inconclusive("Replication tests disabled.");
                return;
            }

            var dbUrlString = new Uri(baseUri);
            var relativeUrlString = dbUrlString.AppendPath(newPath).AbsoluteUri;
            var expected = "http://10.0.0.3:4984/connect-2014/_bulk_get?revs=true&attachments=true";
            Assert.AreEqual(expected, relativeUrlString);
        }
        private static string AppendRelativeURLString(Uri remote, string relativePath)
        {
            var uri = remote.AppendPath(relativePath);
            return uri.AbsoluteUri;
            // the following code is a band-aid for a system problem in the codebase
            // where it is appending "relative paths" that start with a slash, eg:
            //     http://dotcom/db/ + /relpart == http://dotcom/db/relpart
            // which is not compatible with the way the java url concatonation works.
//            var remoteUrlString = remote.AbsolutePath;
//            if (remoteUrlString.EndsWith ("/", StringComparison.Ordinal) 
//                && relativePath.StartsWith ("/", StringComparison.Ordinal))
//            {
//                remoteUrlString = remoteUrlString.Substring(0, remoteUrlString.Length - 1);
//            }
//            return remoteUrlString + relativePath;
        }