Example #1
0
        /// <summary>
        /// Copies a HttpWebResponse stream to HttpResponse output stream; also by default copies response internals such as cookies, status, content type
        /// </summary>
        /// <param name="input"></param>
        /// <param name="output"></param>
        public static void CopyResponse(this System.Net.HttpWebResponse input, System.Web.HttpResponse output, bool copyInternals = true)
        {
            if (input != null)
            {
                if (copyInternals)
                {
                    input.CopyResponseInternals(output);
                }

                //copy web request response stream to System.Web.HttpResponse (context.Response) OutputStrem
                var responseStream = input.GetResponseStream();
                responseStream?.CopyTo(output.OutputStream);

                //Close web request
                input.Close();
            }
        }