GetAsync() public static method

public static GetAsync ( string url, Action requestPreparer ) : Task
url string
requestPreparer Action
return Task
Example #1
0
        /// <summary>
        /// Makes an asynchronous http GET request to the specified url.
        /// </summary>
        /// <param name="url">The url to send the request to.</param>
        /// <param name="prepareRequest">A callback that initializes the request with default values.</param>
        /// <returns>A <see cref="T:Task{IResponse}"/>.</returns>
        public Task <IResponse> Get(string url, Action <IRequest> prepareRequest)
        {
            IRequest req = null;

            return(HttpHelper.GetAsync(url, request =>
            {
                req = new HttpWebRequestWrapper(request);
                prepareRequest(req);
            }
                                       ).Then(response => (IResponse) new HttpWebResponseWrapper(response)));
        }
        /// <summary>
        /// Makes an asynchronous http GET request to the specified url.
        /// </summary>
        /// <param name="url">The url to send the request to.</param>
        /// <param name="prepareRequest">A callback that initializes the request with default values.</param>
        /// <param name="isLongRunning">Indicates whether the request is long running</param>
        /// <returns>A <see cref="T:Task{IResponse}"/>.</returns>
        public Task <IResponse> Get(string url, Action <IRequest> prepareRequest, bool isLongRunning)
        {
            return(HttpHelper.GetAsync(url, request =>
            {
                request.ConnectionGroupName = isLongRunning ? _longRunningGroup : _shortRunningGroup;

                var req = new HttpWebRequestWrapper(request);
                prepareRequest(req);
                PrepareClientRequest(req);
            }
                                       ).Then(response => (IResponse) new HttpWebResponseWrapper(response)));
        }
        /// <summary>
        /// Makes an asynchronous http GET request to the specified url.
        /// </summary>
        /// <param name="url">The url to send the request to.</param>
        /// <param name="prepareRequest">A callback that initializes the request with default values.</param>
        /// <param name="isLongRunning">Indicates whether the request is long running</param>
        /// <returns>A <see cref="T:Task{IResponse}"/>.</returns>
        public Task <IResponse> Get(string url, Action <IRequest> prepareRequest, bool isLongRunning)
        {
            return(HttpHelper.GetAsync(this._httpClient, url, request =>
            {
                // Todo: Find out where to put the connectiongroup name
                //request.ConnectionGroupName = isLongRunning ? _longRunningGroup : _shortRunningGroup;

                var req = new HttpRequestMessageWrapper(request, () => {});
                prepareRequest(req);
                PrepareClientRequest(req);
            }
                                       ).Then(response => (IResponse) new HttpResponseMessageWrapper(response)));
        }