Ejemplo n.º 1
0
        /// <summary>
        /// Perform a DELETE request, writing the body through a stream, and return the results as a stream.
        /// </summary>
        /// <param name="prog">Progress tracker (defaults to no progress tracking)</param>
        /// <returns>A stream that contains the response body, and an HTTP status code</returns>
        public static async Task <HttpWebResponse> DeleteAsync(this HttpWebRequest request, Func <BodyInfo> getInfo, Action <Stream> writeBody, IProgress prog)
        {
            if (request is null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            request = request.Method(HttpMethods.DELETE);
            await request
            .WriteBodyAsync(getInfo, writeBody, prog)
            .ConfigureAwait(false);

            return((HttpWebResponse)await request.GetResponseAsync()
                   .ConfigureAwait(false));
        }