Example #1
0
 protected override Task<ElasticsearchResponse<Stream>> DoAsyncRequest(HttpWebRequest request, byte[] data = null, IRequestConnectionConfiguration requestSpecificConfig = null)
 {
     return Task.Factory.StartNew(() =>
     {
         var cs = this.ReturnConnectionStatus(request, data, requestSpecificConfig);
         return cs;
     });
 }
Example #2
0
        private ElasticsearchResponse<Stream> ReturnConnectionStatus(HttpWebRequest request, byte[] data, IRequestConnectionConfiguration requestSpecificConfig = null)
        {
            var method = request.Method;
            var path = request.RequestUri.ToString();

            var cs = ElasticsearchResponse<Stream>.Create(this._ConnectionSettings, 200, method, path, data);
            cs.Response = new MemoryStream(_fixedResultBytes);
            return cs;
        }
Example #3
0
        public ElasticsearchResponse <Stream> GetSync(Uri uri, IRequestConnectionConfiguration deserializationState = null)
        {
            var restRequest = new RestRequest();

            restRequest.Method = Method.GET;
            restRequest.Uri    = uri;

            restRequest.Headers = new Dictionary <string, string>();
            restRequest.Headers.Add("Content-Type", "application/json");
            return(this.Execute(restRequest, deserializationState));
        }
            public override ElasticsearchResponse <Stream> GetSync(Uri uri, IRequestConnectionConfiguration requestConfigurationOverrides = null)
            {
                var statusCode = _rnd.Next(1, 9) % 3 == 0 ? 503 : 200;

                if (uri.Port == 9202)
                {
                    statusCode = 200;
                }

                return(ElasticsearchResponse <Stream> .Create(this.ConnectionSettings, statusCode, "GET", "/", null));
            }
Example #5
0
        public Task <ElasticsearchResponse <Stream> > Head(Uri uri, IRequestConnectionConfiguration deserializationState = null)
        {
            var restRequest = new RestRequest();

            restRequest.Method = Method.HEAD;
            restRequest.Uri    = uri;

            restRequest.Headers = new Dictionary <string, string>();
            restRequest.Headers.Add("Content-Type", "application/json");
            return(Task.Factory.StartNew <ElasticsearchResponse <Stream> >(() =>
            {
                return this.Execute(restRequest, deserializationState);
            }));
        }
        public Task<ElasticsearchResponse<Stream>> Delete(Uri uri, byte[] data, IRequestConnectionConfiguration deserializationState = null)
        {
            var restRequest = new RestRequest();
            restRequest.Method = Method.DELETE;
            restRequest.Uri = uri;

            restRequest.Body = data;
            restRequest.Headers = new Dictionary<string, string>();
            restRequest.Headers.Add("Content-Type", "application/json");
            return Task.Factory.StartNew<ElasticsearchResponse<Stream>>(() =>
            {
                return this.Execute(restRequest, deserializationState);
            });
        }
		/// <summary>
		/// Wraps the DoRequest to run synchronously
		/// </summary>
		/// <param name="method">The method.</param>
		/// <param name="uri">The URI.</param>
		/// <param name="data">The data.</param>
		/// <param name="requestSpecificConfig">The request specific configuration.</param>
		/// <returns>ElasticsearchResponse&lt;Stream&gt;.</returns>
		public ElasticsearchResponse<Stream> DoRequestSync(HttpMethod method, Uri uri, byte[] data = null, IRequestConnectionConfiguration requestSpecificConfig = null)
		{
			ThrowIfDisposed();

			var requestTask = DoRequest(method, uri, data, requestSpecificConfig);

			try
			{
				requestTask.Wait();
				return requestTask.Result;
			}
			catch (AggregateException ex)
			{
				return ElasticsearchResponse<Stream>.CreateError(_settings, ex.Flatten(), method.ToString().ToLowerInvariant(), uri.ToString(), data);
			}
			catch (Exception ex)
			{
				return ElasticsearchResponse<Stream>.CreateError(_settings, ex, method.ToString().ToLowerInvariant(), uri.ToString(), data);
			}
		}
Example #8
0
 ElasticsearchResponse <Stream> IConnection.HeadSync(Uri uri, IRequestConnectionConfiguration requestSpecificConfig)
 {
     return(DoRequestSync(HttpMethod.Head, uri, null, requestSpecificConfig));
 }
Example #9
0
 Task <ElasticsearchResponse <Stream> > IConnection.Delete(Uri uri, IRequestConnectionConfiguration requestSpecificConfig)
 {
     return(DoRequest(HttpMethod.Delete, uri, null, requestSpecificConfig));
 }
Example #10
0
        private ElasticsearchResponse <Stream> ReturnConnectionStatus(HttpWebRequest request, byte[] data, IRequestConnectionConfiguration requestSpecificConfig = null)
        {
            var method = request.Method;
            var path   = request.RequestUri.ToString();

            var cs = ElasticsearchResponse <Stream> .Create(this.ConnectionSettings, 200, method, path, data);

            cs.Response = new MemoryStream(_fixedResultBytes);
            return(cs);
        }
            public override ElasticsearchResponse<Stream> GetSync(Uri uri, IRequestConnectionConfiguration requestConfigurationOverrides = null)
            {
                var statusCode = _rnd.Next(1, 9) % 3 == 0 ? 503 : 200;
                if (uri.Port == 9202)
                    statusCode = 200;

                return ElasticsearchResponse<Stream>.Create(this.ConnectionSettings, statusCode, "GET", "/", null);
            }
		ElasticsearchResponse<Stream> IConnection.DeleteSync(Uri uri, byte[] data, IRequestConnectionConfiguration requestSpecificConfig)
		{
			return DoRequestSync(HttpMethod.Delete, uri, data, requestSpecificConfig);
		}
Example #13
0
        public virtual Task <ElasticsearchResponse <Stream> > Head(Uri uri, IRequestConnectionConfiguration requestSpecificConfig = null)
        {
            var r = this.CreateHttpWebRequest(uri, "HEAD", null, requestSpecificConfig);

            return(this.DoAsyncRequest(r, requestSpecificConfig: requestSpecificConfig));
        }
 public virtual ElasticsearchResponse<Stream> DeleteSync(Uri uri, byte[] data, IRequestConnectionConfiguration requestSpecificConfig = null)
 {
     return this.BodyRequest(uri, data, "DELETE", requestSpecificConfig);
 }
		/// <summary>
		/// Makes an async call to the specified url. Uses the timeout from the IRequestSpecifiConfig is supplied, or the global timeout from settings.
		/// </summary>
		/// <param name="method">The method.</param>
		/// <param name="uri">The URI.</param>
		/// <param name="data">The data.</param>
		/// <param name="requestSpecificConfig">The request specific configuration.</param>
		/// <returns>Task&lt;ElasticsearchResponse&lt;Stream&gt;&gt;.</returns>
		public async Task<ElasticsearchResponse<Stream>> DoRequest(HttpMethod method, Uri uri, byte[] data = null, IRequestConnectionConfiguration requestSpecificConfig = null)
		{
			ThrowIfDisposed();

			try
			{
				var request = new HttpRequestMessage(method, uri);

				if (method != HttpMethod.Get && method != HttpMethod.Head && data != null && data.Length > 0)
				{
					request.Content = new ByteArrayContent(data);

					if (requestSpecificConfig != null && !string.IsNullOrWhiteSpace(requestSpecificConfig.AcceptsContentType))
					{
						request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(requestSpecificConfig.AcceptsContentType));
					}
					else if (!string.IsNullOrWhiteSpace(DefaultContentType))
					{
						request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(DefaultContentType));
					}

					if (!string.IsNullOrWhiteSpace(DefaultContentType))
					{
						request.Content.Headers.ContentType = new MediaTypeHeaderValue(DefaultContentType);
					}
				}

				var response = await Client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead);

				if (method == HttpMethod.Head || response.Content == null || !response.Content.Headers.ContentLength.HasValue || response.Content.Headers.ContentLength.Value <= 0)
				{
					return ElasticsearchResponse<Stream>.Create(_settings, (int)response.StatusCode, method.ToString().ToLowerInvariant(), uri.ToString(), data);
				}

				var responseStream = await response.Content.ReadAsStreamAsync();
				return ElasticsearchResponse<Stream>.Create(_settings, (int)response.StatusCode, method.ToString().ToLowerInvariant(), uri.ToString(), data, responseStream);

			}
			catch (Exception ex)
			{
				return ElasticsearchResponse<Stream>.CreateError(_settings, ex, method.ToString().ToLowerInvariant(), uri.ToString(), data);
			}
		}
 private ElasticsearchResponse<Stream> HeaderOnlyRequest(Uri uri, string method, IRequestConnectionConfiguration requestSpecificConfig)
 {
     var r = this.CreateHttpWebRequest(uri, method, null, requestSpecificConfig);
     return this.DoSynchronousRequest(r, requestSpecificConfig: requestSpecificConfig);
 }
 public virtual Task<ElasticsearchResponse<Stream>> Delete(Uri uri, byte[] data, IRequestConnectionConfiguration requestSpecificConfig = null)
 {
     var r = this.CreateHttpWebRequest(uri, "DELETE", data, requestSpecificConfig);
     return this.DoAsyncRequest(r, data, requestSpecificConfig: requestSpecificConfig);
 }
 private ElasticsearchResponse<Stream> BodyRequest(Uri uri, byte[] data, string method, IRequestConnectionConfiguration requestSpecificConfig)
 {
     var r = this.CreateHttpWebRequest(uri, method, data, requestSpecificConfig);
     return this.DoSynchronousRequest(r, data, requestSpecificConfig);
 }
        protected virtual ElasticsearchResponse<Stream> DoSynchronousRequest(HttpWebRequest request, byte[] data = null, IRequestConnectionConfiguration requestSpecificConfig = null)
        {
            var path = request.RequestUri.ToString();
            var method = request.Method;

            if (data != null)
            {
                using (var r = request.GetRequestStream())
                {
                    r.Write(data, 0, data.Length);
                }
            }
            try
            {
                //http://msdn.microsoft.com/en-us/library/system.net.httpwebresponse.getresponsestream.aspx
                //Either the stream or the response object needs to be closed but not both although it won't
                //throw any errors if both are closed atleast one of them has to be Closed.
                //Since we expose the stream we let closing the stream determining when to close the connection
                var response = (HttpWebResponse)request.GetResponse();
                var responseStream = response.GetResponseStream();
                return WebToElasticsearchResponse(data, responseStream, response, method, path);
            }
            catch (WebException webException)
            {
                return HandleWebException(data, webException, method, path);
            }
        }
        protected virtual Task<ElasticsearchResponse<Stream>> DoAsyncRequest(HttpWebRequest request, byte[] data = null, IRequestConnectionConfiguration requestSpecificConfig = null)
        {
            var tcs = new TaskCompletionSource<ElasticsearchResponse<Stream>>();
            if (this.ConnectionSettings.MaximumAsyncConnections <= 0
              || this._resourceLock == null)
                return this.CreateIterateTask(request, data, requestSpecificConfig, tcs);

            var timeout = this.ConnectionSettings.Timeout;
            var path = request.RequestUri.ToString();
            var method = request.Method;
            if (!this._resourceLock.WaitOne(timeout))
            {
                var m = "Could not start the operation before the timeout of " + timeout +
                  "ms completed while waiting for the semaphore";
                var cs = ElasticsearchResponse<Stream>.CreateError(this.ConnectionSettings, new TimeoutException(m), method, path, data);
                tcs.SetResult(cs);
                return tcs.Task;
            }
            try
            {
                return this.CreateIterateTask(request, data, requestSpecificConfig, tcs);
            }
            finally
            {
                this._resourceLock.Release();
            }
        }
Example #21
0
        /// <summary>
        /// Wraps the DoRequest to run synchronously
        /// </summary>
        /// <param name="method">The method.</param>
        /// <param name="uri">The URI.</param>
        /// <param name="data">The data.</param>
        /// <param name="requestSpecificConfig">The request specific configuration.</param>
        /// <returns>ElasticsearchResponse&lt;Stream&gt;.</returns>
        public ElasticsearchResponse <Stream> DoRequestSync(HttpMethod method, Uri uri, byte[] data = null, IRequestConnectionConfiguration requestSpecificConfig = null)
        {
            ThrowIfDisposed();

            var requestTask = DoRequest(method, uri, data, requestSpecificConfig);

            try
            {
                requestTask.Wait();
                return(requestTask.Result);
            }
            catch (AggregateException ex)
            {
                return(ElasticsearchResponse <Stream> .CreateError(_settings, ex.Flatten(), method.ToString().ToLowerInvariant(), uri.ToString(), data));
            }
            catch (Exception ex)
            {
                return(ElasticsearchResponse <Stream> .CreateError(_settings, ex, method.ToString().ToLowerInvariant(), uri.ToString(), data));
            }
        }
 public virtual ElasticsearchResponse<Stream> GetSync(Uri uri, IRequestConnectionConfiguration requestSpecificConfig = null)
 {
     return this.HeaderOnlyRequest(uri, "GET", requestSpecificConfig);
 }
Example #23
0
 protected override ElasticsearchResponse<Stream> DoSynchronousRequest(HttpWebRequest request, byte[] data = null, IRequestConnectionConfiguration requestSpecificConfig = null)
 {
     return this.ReturnConnectionStatus(request, data, requestSpecificConfig);
 }
 public virtual Task<ElasticsearchResponse<Stream>> Head(Uri uri, IRequestConnectionConfiguration requestSpecificConfig = null)
 {
     var r = this.CreateHttpWebRequest(uri, "HEAD", null, requestSpecificConfig);
     return this.DoAsyncRequest(r, requestSpecificConfig: requestSpecificConfig);
 }
		Task<ElasticsearchResponse<Stream>> IConnection.Put(Uri uri, byte[] data, IRequestConnectionConfiguration requestSpecificConfig)
		{
			return DoRequest(HttpMethod.Put, uri, data, requestSpecificConfig);
		}
        public ElasticsearchResponse<Stream> PutSync(Uri uri, byte[] data, IRequestConnectionConfiguration deserializationState = null)
        {
            var restRequest = new RestRequest();
            restRequest.Method = Method.PUT;
            restRequest.Uri = uri;

            restRequest.Body = data;
            restRequest.Headers = new Dictionary<string, string>();
            restRequest.Headers.Add("Content-Type", "application/json");
            return this.Execute(restRequest, deserializationState);
        }
        protected virtual HttpWebRequest CreateWebRequest(Uri uri, string method, byte[] data, IRequestConnectionConfiguration requestSpecificConfig)
        {
            //TODO append global querystring
            //var url = this._CreateUriString(path);

            var myReq = (HttpWebRequest)WebRequest.Create(uri);

            myReq.Accept = "application/json";
            myReq.ContentType = "application/json";
            if (requestSpecificConfig != null && !string.IsNullOrWhiteSpace(requestSpecificConfig.AcceptsContentType))
            {
                myReq.Accept = requestSpecificConfig.AcceptsContentType;
                myReq.ContentType = requestSpecificConfig.AcceptsContentType;
            }
            var timeout = this.ConnectionSettings.Timeout;
            myReq.Timeout = timeout; // 1 minute timeout.
            myReq.ReadWriteTimeout = timeout; // 1 minute timeout.
            myReq.Method = method;

            //WebRequest won't send Content-Length: 0 for empty bodies
            //which goes against RFC's and might break i.e IIS when used as a proxy.
            //see: https://github.com/elasticsearch/elasticsearch-net/issues/562
            var m = method.ToLowerInvariant();
            if (m != "head" && m != "get" && (data == null || data.Length == 0))
                myReq.ContentLength = 0;

            return myReq;
        }
Example #28
0
 public Task <ElasticsearchResponse <Stream> > Put(Uri uri, byte[] data, IRequestConnectionConfiguration requestSpecificConfig = null)
 {
     throw new NotImplementedException();
 }
Example #29
0
 protected override ElasticsearchResponse <Stream> DoSynchronousRequest(HttpWebRequest request, byte[] data = null, IRequestConnectionConfiguration requestSpecificConfig = null)
 {
     return(this.ReturnConnectionStatus(request, data, requestSpecificConfig));
 }
Example #30
0
        public virtual Task <ElasticsearchResponse <Stream> > Delete(Uri uri, byte[] data, IRequestConnectionConfiguration requestSpecificConfig = null)
        {
            var r = this.CreateHttpWebRequest(uri, "DELETE", data, requestSpecificConfig);

            return(this.DoAsyncRequest(r, data, requestSpecificConfig: requestSpecificConfig));
        }
Example #31
0
 protected override Task <ElasticsearchResponse <Stream> > DoAsyncRequest(HttpWebRequest request, byte[] data = null, IRequestConnectionConfiguration requestSpecificConfig = null)
 {
     return(Task.Factory.StartNew(() =>
     {
         var cs = this.ReturnConnectionStatus(request, data, requestSpecificConfig);
         return cs;
     }));
 }
Example #32
0
        protected virtual HttpWebRequest CreateHttpWebRequest(Uri uri, string method, byte[] data, IRequestConnectionConfiguration requestSpecificConfig)
        {
            var myReq = this.CreateWebRequest(uri, method, data, requestSpecificConfig);

            this.SetBasicAuthorizationIfNeeded(myReq);
            this.SetProxyIfNeeded(myReq);
            return(myReq);
        }
Example #33
0
        /// <summary>
        /// Makes an async call to the specified url. Uses the timeout from the IRequestSpecifiConfig is supplied, or the global timeout from settings.
        /// </summary>
        /// <param name="method">The method.</param>
        /// <param name="uri">The URI.</param>
        /// <param name="data">The data.</param>
        /// <param name="requestSpecificConfig">The request specific configuration.</param>
        /// <returns>Task&lt;ElasticsearchResponse&lt;Stream&gt;&gt;.</returns>
        public async Task <ElasticsearchResponse <Stream> > DoRequest(HttpMethod method, Uri uri, byte[] data = null, IRequestConnectionConfiguration requestSpecificConfig = null)
        {
            ThrowIfDisposed();

            try
            {
                var request = new HttpRequestMessage(method, uri);

                if (method != HttpMethod.Get && method != HttpMethod.Head && data != null && data.Length > 0)
                {
                    request.Content = new ByteArrayContent(data);

                    if (requestSpecificConfig != null && !string.IsNullOrWhiteSpace(requestSpecificConfig.AcceptsContentType))
                    {
                        request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(requestSpecificConfig.AcceptsContentType));
                    }
                    else if (!string.IsNullOrWhiteSpace(DefaultContentType))
                    {
                        request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(DefaultContentType));
                    }

                    if (!string.IsNullOrWhiteSpace(DefaultContentType))
                    {
                        request.Content.Headers.ContentType = new MediaTypeHeaderValue(DefaultContentType);
                    }
                }

                var response = await Client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead);

                if (method == HttpMethod.Head || response.Content == null || !response.Content.Headers.ContentLength.HasValue || response.Content.Headers.ContentLength.Value <= 0)
                {
                    return(ElasticsearchResponse <Stream> .Create(_settings, (int)response.StatusCode, method.ToString().ToLowerInvariant(), uri.ToString(), data));
                }

                var responseStream = await response.Content.ReadAsStreamAsync();

                return(ElasticsearchResponse <Stream> .Create(_settings, (int)response.StatusCode, method.ToString().ToLowerInvariant(), uri.ToString(), data, responseStream));
            }
            catch (Exception ex)
            {
                return(ElasticsearchResponse <Stream> .CreateError(_settings, ex, method.ToString().ToLowerInvariant(), uri.ToString(), data));
            }
        }
Example #34
0
        protected virtual HttpWebRequest CreateWebRequest(Uri uri, string method, byte[] data, IRequestConnectionConfiguration requestSpecificConfig)
        {
            //TODO append global querystring
            //var url = this._CreateUriString(path);

            var myReq = (HttpWebRequest)WebRequest.Create(uri);

            myReq.Accept      = "application/json";
            myReq.ContentType = "application/json";
            if (requestSpecificConfig != null && !string.IsNullOrWhiteSpace(requestSpecificConfig.AcceptsContentType))
            {
                myReq.Accept      = requestSpecificConfig.AcceptsContentType;
                myReq.ContentType = requestSpecificConfig.AcceptsContentType;
            }
            var timeout = this.ConnectionSettings.Timeout;

            myReq.Timeout          = timeout;    // 1 minute timeout.
            myReq.ReadWriteTimeout = timeout;    // 1 minute timeout.
            myReq.Method           = method;

            //WebRequest won't send Content-Length: 0 for empty bodies
            //which goes against RFC's and might break i.e IIS when used as a proxy.
            //see: https://github.com/elasticsearch/elasticsearch-net/issues/562
            var m = method.ToLowerInvariant();

            if (m != "head" && m != "get" && (data == null || data.Length == 0))
            {
                myReq.ContentLength = 0;
            }

            return(myReq);
        }
Example #35
0
 Task <ElasticsearchResponse <Stream> > IConnection.Put(Uri uri, byte[] data, IRequestConnectionConfiguration requestSpecificConfig)
 {
     return(DoRequest(HttpMethod.Put, uri, data, requestSpecificConfig));
 }
Example #36
0
        protected virtual ElasticsearchResponse <Stream> DoSynchronousRequest(HttpWebRequest request, byte[] data = null, IRequestConnectionConfiguration requestSpecificConfig = null)
        {
            var path   = request.RequestUri.ToString();
            var method = request.Method;

            if (data != null)
            {
                using (var r = request.GetRequestStream())
                {
                    r.Write(data, 0, data.Length);
                }
            }
            try
            {
                //http://msdn.microsoft.com/en-us/library/system.net.httpwebresponse.getresponsestream.aspx
                //Either the stream or the response object needs to be closed but not both although it won't
                //throw any errors if both are closed atleast one of them has to be Closed.
                //Since we expose the stream we let closing the stream determining when to close the connection
                var response       = (HttpWebResponse)request.GetResponse();
                var responseStream = response.GetResponseStream();
                return(WebToElasticsearchResponse(data, responseStream, response, method, path));
            }
            catch (WebException webException)
            {
                return(HandleWebException(data, webException, method, path));
            }
        }
Example #37
0
 ElasticsearchResponse <Stream> IConnection.DeleteSync(Uri uri, byte[] data, IRequestConnectionConfiguration requestSpecificConfig)
 {
     return(DoRequestSync(HttpMethod.Delete, uri, data, requestSpecificConfig));
 }
Example #38
0
        protected virtual Task <ElasticsearchResponse <Stream> > DoAsyncRequest(HttpWebRequest request, byte[] data = null, IRequestConnectionConfiguration requestSpecificConfig = null)
        {
            var tcs = new TaskCompletionSource <ElasticsearchResponse <Stream> >();

            if (this.ConnectionSettings.MaximumAsyncConnections <= 0 ||
                this._resourceLock == null)
            {
                return(this.CreateIterateTask(request, data, requestSpecificConfig, tcs));
            }

            var timeout = this.ConnectionSettings.Timeout;
            var path    = request.RequestUri.ToString();
            var method  = request.Method;

            if (!this._resourceLock.WaitOne(timeout))
            {
                var m = "Could not start the operation before the timeout of " + timeout +
                        "ms completed while waiting for the semaphore";
                var cs = ElasticsearchResponse <Stream> .CreateError(this.ConnectionSettings, new TimeoutException(m), method, path, data);

                tcs.SetResult(cs);
                return(tcs.Task);
            }
            try
            {
                return(this.CreateIterateTask(request, data, requestSpecificConfig, tcs));
            }
            finally
            {
                this._resourceLock.Release();
            }
        }
Example #39
0
 public ElasticsearchResponse <Stream> HeadSync(Uri uri, IRequestConnectionConfiguration requestSpecificConfig = null)
 {
     throw new NotImplementedException();
 }
Example #40
0
 public virtual Task <ElasticsearchResponse <Stream> > Get(Uri uri, IRequestConnectionConfiguration requestSpecificConfig = null)
 {
     return(DoAsyncRequest(uri));
 }
Example #41
0
 public virtual ElasticsearchResponse<Stream> HeadSync(Uri uri, IRequestConnectionConfiguration requestSpecificConfig = null)
 {
     _uriObserver.Observe(uri);
     return _responseGenerator.Create();
 }
Example #42
0
 public virtual Task <ElasticsearchResponse <Stream> > Delete(Uri uri, IRequestConnectionConfiguration requestSpecificConfig = null)
 {
     _uriObserver.Observe(uri);
     return(Task.FromResult(_responseGenerator.Create()));
 }
		ElasticsearchResponse<Stream> IConnection.HeadSync(Uri uri, IRequestConnectionConfiguration requestSpecificConfig)
		{
			return DoRequestSync(HttpMethod.Head, uri, null, requestSpecificConfig);
		}
Example #44
0
 public virtual Task<ElasticsearchResponse<Stream>> Head(Uri uri, IRequestConnectionConfiguration requestSpecificConfig = null)
 {
     _uriObserver.Observe(uri);
     return Task.FromResult(_responseGenerator.Create());
 }
		Task<ElasticsearchResponse<Stream>> IConnection.Delete(Uri uri, IRequestConnectionConfiguration requestSpecificConfig)
		{
			return DoRequest(HttpMethod.Delete, uri, null, requestSpecificConfig);
		}
Example #46
0
        private ElasticsearchResponse <Stream> BodyRequest(Uri uri, byte[] data, string method, IRequestConnectionConfiguration requestSpecificConfig)
        {
            var r = this.CreateHttpWebRequest(uri, method, data, requestSpecificConfig);

            return(this.DoSynchronousRequest(r, data, requestSpecificConfig));
        }
Example #47
0
 public virtual ElasticsearchResponse <Stream> HeadSync(Uri uri, IRequestConnectionConfiguration requestSpecificConfig = null)
 {
     return(this.HeaderOnlyRequest(uri, "HEAD", requestSpecificConfig));
 }
 protected virtual HttpWebRequest CreateHttpWebRequest(Uri uri, string method, byte[] data, IRequestConnectionConfiguration requestSpecificConfig)
 {
     var myReq = this.CreateWebRequest(uri, method, data, requestSpecificConfig);
     this.SetBasicAuthorizationIfNeeded(myReq);
     this.SetProxyIfNeeded(myReq);
     return myReq;
 }
Example #49
0
 public virtual ElasticsearchResponse <Stream> PutSync(Uri uri, byte[] data, IRequestConnectionConfiguration requestSpecificConfig = null)
 {
     _uriObserver.Observe(uri);
     return(_responseGenerator.Create());
 }
Example #50
0
 public virtual ElasticsearchResponse <Stream> DeleteSync(Uri uri, byte[] data, IRequestConnectionConfiguration requestSpecificConfig = null)
 {
     return(this.BodyRequest(uri, data, "DELETE", requestSpecificConfig));
 }
Example #51
0
        private ElasticsearchResponse <Stream> HeaderOnlyRequest(Uri uri, string method, IRequestConnectionConfiguration requestSpecificConfig)
        {
            var r = this.CreateHttpWebRequest(uri, method, null, requestSpecificConfig);

            return(this.DoSynchronousRequest(r, requestSpecificConfig: requestSpecificConfig));
        }
Example #52
0
 public virtual Task<ElasticsearchResponse<Stream>> Get(Uri uri, IRequestConnectionConfiguration requestSpecificConfig = null)
 {
     return DoAsyncRequest(uri);
 }