/// <summary> /// Executes a request using the default context and processes the /// response using the given response handler. /// </summary> /// <remarks> /// Executes a request using the default context and processes the /// response using the given response handler. The content entity associated /// with the response is fully consumed and the underlying connection is /// released back to the connection manager automatically in all cases /// relieving individual /// <see cref="Apache.Http.Client.ResponseHandler{T}">Apache.Http.Client.ResponseHandler<T> /// </see> /// s from having to manage /// resource deallocation internally. /// </remarks> /// <param name="request">the request to execute</param> /// <param name="responseHandler">the response handler</param> /// <param name="context"> /// the context to use for the execution, or /// <code>null</code> to use the default context /// </param> /// <returns>the response object as generated by the response handler.</returns> /// <exception cref="System.IO.IOException">in case of a problem or the connection was aborted /// </exception> /// <exception cref="Apache.Http.Client.ClientProtocolException">in case of an http protocol error /// </exception> public virtual T Execute <T, _T1>(IHttpUriRequest request, ResponseHandler <_T1> responseHandler , HttpContext context) where _T1 : T { HttpHost target = DetermineTarget(request); return(Execute(target, request, responseHandler, context)); }
internal HttpRequestTaskCallable(HttpClient httpClient, IHttpUriRequest request, HttpContext context, ResponseHandler <V> responseHandler, FutureCallback <V> callback , FutureRequestExecutionMetrics metrics) { this.httpclient = httpClient; this.responseHandler = responseHandler; this.request = request; this.context = context; this.callback = callback; this.metrics = metrics; }
/// <summary>Schedule a request for execution.</summary> /// <remarks>Schedule a request for execution.</remarks> /// <?></?> /// <param name="request">request to execute</param> /// <param name="context">optional context; use null if not needed.</param> /// <param name="responseHandler">handler that will process the response.</param> /// <param name="callback"> /// callback handler that will be called when the request is scheduled, /// started, completed, failed, or cancelled. /// </param> /// <returns>HttpAsyncClientFutureTask for the scheduled request.</returns> /// <exception cref="System.Exception">System.Exception</exception> public virtual HttpRequestFutureTask <T> Execute <T>(IHttpUriRequest request, HttpContext context, ResponseHandler <T> responseHandler, FutureCallback <T> callback) { if (closed.Get()) { throw new InvalidOperationException("Close has been called on this httpclient instance." ); } metrics.GetScheduledConnections().IncrementAndGet(); HttpRequestTaskCallable <T> callable = new HttpRequestTaskCallable <T>(httpclient, request, context, responseHandler, callback, metrics); HttpRequestFutureTask <T> httpRequestFutureTask = new HttpRequestFutureTask <T>(request , callable); executorService.Execute(httpRequestFutureTask); return(httpRequestFutureTask); }
/// <exception cref="Apache.Http.Client.ClientProtocolException"></exception> private static HttpHost DetermineTarget(IHttpUriRequest request) { // A null target may be acceptable if there is a default target. // Otherwise, the null target is detected in the director. HttpHost target = null; URI requestURI = request.GetURI(); if (requestURI.IsAbsolute()) { target = URIUtils.ExtractHost(requestURI); if (target == null) { throw new ClientProtocolException("URI does not specify a valid host name: " + requestURI ); } } return(target); }
/// <summary>Schedule a request for execution.</summary> /// <remarks>Schedule a request for execution.</remarks> /// <?></?> /// <param name="request">request to execute</param> /// <param name="responseHandler">handler that will process the response.</param> /// <returns>HttpAsyncClientFutureTask for the scheduled request.</returns> /// <exception cref="System.Exception">System.Exception</exception> public virtual HttpRequestFutureTask <T> Execute <T>(IHttpUriRequest request, HttpContext context, ResponseHandler <T> responseHandler) { return(Execute(request, context, responseHandler, null)); }
public static IHttpResponse execute(this AbstractHttpClient httpClient, IHttpUriRequest request) { return(httpClient.Execute(request)); }
/// <summary><inheritDoc></inheritDoc></summary> /// <exception cref="System.IO.IOException"></exception> /// <exception cref="Apache.Http.Client.ClientProtocolException"></exception> public virtual CloseableHttpResponse Execute(IHttpUriRequest request) { return(Execute(request, (HttpContext)null)); }
/// <summary><inheritDoc></inheritDoc></summary> /// <exception cref="System.IO.IOException"></exception> /// <exception cref="Apache.Http.Client.ClientProtocolException"></exception> public virtual CloseableHttpResponse Execute(IHttpUriRequest request, HttpContext context) { Args.NotNull(request, "HTTP request"); return(DoExecute(DetermineTarget(request), request, context)); }
/// <summary> /// Executes a request using the default context and processes the /// response using the given response handler. /// </summary> /// <remarks> /// Executes a request using the default context and processes the /// response using the given response handler. The content entity associated /// with the response is fully consumed and the underlying connection is /// released back to the connection manager automatically in all cases /// relieving individual /// <see cref="Apache.Http.Client.ResponseHandler{T}">Apache.Http.Client.ResponseHandler<T> /// </see> /// s from having to manage /// resource deallocation internally. /// </remarks> /// <param name="request">the request to execute</param> /// <param name="responseHandler">the response handler</param> /// <returns>the response object as generated by the response handler.</returns> /// <exception cref="System.IO.IOException">in case of a problem or the connection was aborted /// </exception> /// <exception cref="Apache.Http.Client.ClientProtocolException">in case of an http protocol error /// </exception> public virtual T Execute <T, _T1>(IHttpUriRequest request, ResponseHandler <_T1> responseHandler ) where _T1 : T { return(Execute(request, responseHandler, null)); }
public HttpRequestFutureTask(IHttpUriRequest request, HttpRequestTaskCallable <V> httpCallable) : base(httpCallable) { this.request = request; this.callable = httpCallable; }