Ejemplo n.º 1
0
        public static Document Load(RiakHttpResponse response)
        {
            Dictionary<string, string> headers = new Dictionary<string, string>
                                                     {
                                                         { HttpWellKnownHeader.ContentLength, response.ContentLength.ToString() },
                                                         { HttpWellKnownHeader.ContentType, response.ContentType },
                                                     };

            foreach(string headerKey in response.Headers.AllKeys)
            {
                headers[headerKey] = response.Headers[headerKey];
            }

            return Load(response.GetResponseStream(), headers, null);
        }
Ejemplo n.º 2
0
        private void LoadFromJson(RiakHttpResponse response)
        {
            using (StreamReader sr = new StreamReader(response.GetResponseStream()))
            {
                string responseText = sr.ReadToEnd();
                Trace.WriteLine(responseText);
                JsonObject bucket = (JsonObject)JsonConvert.Import(responseText);

                if (ContainsKeys)
                {
                    JsonArray keys = (JsonArray) bucket["keys"];
                    foreach (string key in keys)
                    {
                        Keys.Add(Uri.UnescapeDataString(key));
                    }
                }

                JsonObject properties = (JsonObject)bucket["props"];
                Name = Uri.UnescapeDataString((string)properties["name"]);
                AllowMulti = (bool)properties["allow_mult"];
            }
        }
Ejemplo n.º 3
0
 protected virtual void LoadCachedData(RiakHttpResponse response)
 {
     _cachedData = new byte[response.ContentLength];
     Util.CopyStream(response.GetResponseStream(), _cachedData);
 }
Ejemplo n.º 4
0
        private ICollection<RiakObject> LoadConflictSiblings(RiakHttpResponse response, string keyName)
        {
            List<string> siblingIds = new List<string>();

            using (StreamReader sr = new StreamReader(response.GetResponseStream()))
            {
                string siblingHeader = sr.ReadLine();

                if(siblingHeader != "Siblings:")
                {
                    throw new RiakServerException("Expected a sibling header (\"Sibling:\") but was actually: \"{0}\"", siblingHeader);
                }

                while (!sr.EndOfStream)
                {
                    siblingIds.Add(sr.ReadLine());
                }
            }

            List<RiakObject> siblingObjects = new List<RiakObject>(siblingIds.Count);

            siblingObjects.AddRange(siblingIds.Select(siblingId => RiakObject.Load(this, keyName, siblingId)));

            return siblingObjects;
        }