public static HttpWebRequest Create(Request request, TimeSpan timeout, WebRequestTransportSettings settings, ILog log)
        {
            var webRequest = WebRequest.CreateHttp(request.Url);

            webRequest.Method = request.Method;

            WebRequestTuner.Tune(webRequest, timeout, settings);

            if (settings.FixNonAsciiHeaders)
            {
                request = NonAsciiHeadersFixer.Fix(request);
            }

            WebRequestHeadersFiller.Fill(request, webRequest, log);

            return(webRequest);
        }
        private Headers CreateResponseHeaders(WebRequestState state)
        {
            var headers = Headers.Empty;

            if (state.Response == null)
            {
                return(headers);
            }

            foreach (var key in state.Response.Headers.AllKeys)
            {
                var headerValue = state.Response.Headers[key];

                if (settings.FixNonAsciiHeaders)
                {
                    headerValue = NonAsciiHeadersFixer.FixResponseHeaderValue(headerValue);
                }

                headers = headers.Set(key, headerValue);
            }

            return(headers);
        }