Ejemplo n.º 1
0
        /// <summary>
        /// Makes an asynchronous http POST 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="postData">form url encoded data.</param>
        /// <returns>A <see cref="Task{IResponse}"/>.</returns>
        public Task <IResponse> Post(string url, Action <IRequest> prepareRequest, IDictionary <string, string> postData)
        {
            Log.WriteLine("POST url: " + url);
            Log.WriteLine("POST-data: " + PostData2String(postData));

            Task <IResponse> t = dhc.Post(url, prepareRequest, postData);

            t.ContinueWith(tr => { Log.WriteLine("Response: " + tr.Result.ReadAsString()); }, TaskContinuationOptions.OnlyOnRanToCompletion);
            return(t);
        }