public static ElasticRequestException GenerateException(HttpRequest request, HttpResponse response)
        {
            ElasticRequestException basicException = new ElasticRequestException(request, response);
            if (string.IsNullOrWhiteSpace(response.Body))
                return basicException;

            try
            {
                ElasticError error = JsonConvert.DeserializeObject<ElasticError>(response.Body);

                if (error == null)
                    return basicException;

                if (error.Status == 404 && error.Error.Contains("IndexMissingException"))
                {
                    int startIndex = error.Error.IndexOf("[[") + 2;
                    int endIndex = error.Error.IndexOf("]", startIndex);
                    string index = error.Error.Substring(startIndex, endIndex - startIndex);
                    return new IndexMissingException(index, request, response);
                }
            }
            catch { }           

            return basicException;
        }
        public void PASS_Get_WithHeaders()
        {
            string uri = "http://www.google.com";
            HttpRequest request = new HttpRequest(uri);
            request.AddToHeaders("accept-language", "fr;q=1.0");
            HttpResponse response = new HttpLayer().Get(request);

            Assert.IsNotNull(response);
            Assert.AreEqual(System.Net.HttpStatusCode.OK, response.StatusCode);
            Assert.IsNotNull(response.Body);
            Assert.IsTrue(response.Body.ToLower().Contains("google"));
        }