/// <summary>
        /// Gets the request status.
        /// </summary>
        /// <param name="settings">The settings.</param>
        /// <returns>A <see cref="HttpRequestStatus"/>.</returns>
        protected HttpRequestStatus GetRequestStatus(HttpRequestSettings settings)
        {
            HttpRequestStatus ret = new HttpRequestStatus {
                Settings = settings, Success = false
            };

            HttpWebRequest  request  = (HttpWebRequest)WebRequest.Create(settings.Uri);
            HttpWebResponse response = null;

            if (settings.HasHeaders)
            {
                foreach (HttpRequestHeader header in settings.Headers)
                {
                    request.Headers.Set(header.Name, header.Value);
                }
            }

            if (settings.HasTimeout || settings.HasOverrideTimeout)
            {
                request.Timeout = (settings.OverrideTimeout ?? settings.Timeout).Millis;
            }

            if (settings.HasReadWriteTimeout)
            {
                request.ReadWriteTimeout = settings.ReadWriteTimeout.Millis;
            }

            request.Method = settings.Method;
            if (settings.HasCredentials)
            {
                request.Credentials = settings.Credentials;
            }
            else
            {
                request.UseDefaultCredentials = settings.UseDefaultCredentials;
            }

            ret.RequestTime = DateTime.Now;
            long    start   = Stopwatch.GetTimestamp();
            Timeout timeout = new Timeout(request.Timeout);

            timeout.Normalize();
            Timeout readWriteTimeout = new Timeout(request.ReadWriteTimeout);

            readWriteTimeout.Normalize();
            Log.Debug("Requesting uri (timeout: {0}, read/write-timeout: {1})...", timeout.ToString(), readWriteTimeout.ToString());
            try
            {
                // TODO this could be better, support chunked transfer etc?
                if (settings.HasBody || settings.HasSendFile)
                {
                    using (Stream requestStream = request.GetRequestStream())
                    {
                        if (settings.HasBody)
                        {
                            using (TextWriter writer = new StreamWriter(requestStream, new UTF8Encoding(false, true)))
                            {
                                writer.Write(settings.Body);
                            }
                        }
                        else
                        {
                            using (FileStream inputFile = File.OpenRead(settings.SendFile))
                            {
                                int    read;
                                byte[] buff = new byte[16384];
                                do
                                {
                                    read = inputFile.Read(buff, 0, buff.Length);
                                    requestStream.Write(buff, 0, read);
                                }while (read > 0);
                            }
                        }

                        requestStream.Close();
                    }
                }

                response = (HttpWebResponse)request.GetResponse();
            }
            catch (WebException wEx)
            {
                ret.Exception = wEx;
                if (wEx.Status == WebExceptionStatus.Timeout)
                {
                    ret.TimedOut = true;
                }

                if (wEx.Response is HttpWebResponse)
                {
                    response = (HttpWebResponse)wEx.Response;
                }
            }

            if (response != null)
            {
                ret.StatusCode        = response.StatusCode;
                ret.StatusDescription = response.StatusDescription;
                ret.ContentEncoding   = response.ContentEncoding;
                ret.CharacterSet      = response.CharacterSet;
                ret.ContentType       = response.ContentType;
                ret.Headers           = response.Headers;
                if (this.IncludeContent)
                {
                    try
                    {
                        using (Stream responseStream = response.GetResponseStream())
                        {
                            try
                            {
                                ret.ResponseEncoding = Encoding.GetEncoding(response.CharacterSet);
                            }
                            catch (ArgumentException)
                            {
                                ret.ResponseEncoding = null;
                            }

                            if (ret.ResponseEncoding != null)
                            {
                                using (TextReader reader = new StreamReader(responseStream, ret.ResponseEncoding))
                                {
                                    ret.Content = reader.ReadToEnd();
                                }
                            }
                            else
                            {
                                // BASE64 encode a blob
                                using (MemoryStream memBuffer = new MemoryStream())
                                {
                                    int    read;
                                    byte[] buff = new byte[512];
                                    do
                                    {
                                        read = responseStream.Read(buff, 0, buff.Length);
                                        memBuffer.Write(buff, 0, read);
                                    }while (read > 0);

                                    if (memBuffer.Length > 0)
                                    {
                                        ret.ContentIsBase64Encoded = true;
                                        ret.Content = Convert.ToBase64String(
                                            memBuffer.ToArray(),
                                            Base64FormattingOptions.InsertLineBreaks);
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        // keep the first exception
                        if (ret.Exception == null)
                        {
                            ret.Exception = ex;
                        }

                        ret.Content = null;
                    }
                }

                ret.Success = true;
            }

            ret.Duration = TimeSpan.FromSeconds((double)(Stopwatch.GetTimestamp() - start) / Stopwatch.Frequency);
            return(ret);
        }