/// <summary>
        /// Transfers the <paramref name="response"/> data to <paramref name="httpResponse"/>.
        /// </summary>
        /// <param name="response">The <see cref="WebResponse"/>.</param>
        /// <param name="httpResponse">The <see cref="HttpResponseBase"/>.</param>
        /// <exception cref="ArgumentNullException">Thrown if one of the parameters is null.</exception>
        public static void Transfer(WebResponse response, HttpResponseBase httpResponse)
        {
            // validate arguments
            if (response == null)
                throw new ArgumentNullException("response");
            if (httpResponse == null)
                throw new ArgumentNullException("httpResponse");

            // map the response to the http output
            httpResponse.ContentEncoding = response.ContentEncoding;
            httpResponse.ContentType = response.ContentType;
            httpResponse.StatusCode = (int) response.StatusCode;
            httpResponse.StatusDescription = response.StatusDescription;

            // flush the content
            response.Contents(httpResponse.OutputStream);

            // copy headers
            foreach (var header in response.Headers)
                httpResponse.AddHeader(header.Key, header.Value);

            // transfer all the cookies to the http response
            TransferCookies(response, httpResponse);

            // set cache properties
            if (response.CacheSettings.OutputCacheEnabled)
            {
                httpResponse.Cache.SetCacheability(HttpCacheability.ServerAndPrivate);
                if (response.CacheSettings.Expires.HasValue)
                    httpResponse.Cache.SetExpires(response.CacheSettings.Expires.Value);
                else if (!string.IsNullOrEmpty(response.CacheSettings.ETag))
                {
                    httpResponse.Cache.SetLastModified(response.CacheSettings.LastModified);
                    httpResponse.Cache.SetETag(response.CacheSettings.ETag);
                }
            }

            // check for redirect
            if (!string.IsNullOrEmpty(response.RedirectLocation))
                httpResponse.RedirectLocation = response.RedirectLocation;
        }