/// <summary>
        /// Closes a response stream, if present.
        /// </summary>
        /// <param name="disposing">Not used.</param>
        protected override void Dispose(bool disposing)
        {
            if (m_responseStream != null)
            {
                bool closeConnection = true;
                if (m_httpWebRequest.KeepAlive)
                {
                    string connValue = null;

                    // Check if server have sent use "Connection:Close"
                    if (m_httpResponseHeaders != null)
                    {
                        connValue = m_httpResponseHeaders[HttpKnownHeaderNames.Connection];
                    }

                    // If server had not send this header or value is not "close", then we keep connection.
                    closeConnection = connValue == null || connValue.ToLower() == HttpKnownHeaderValues.close;
                }

                // If it is not in the list - Add it
                if (closeConnection)
                {
                    // Add new socket and port used to connect to the list of sockets.
                    // Save connected socket and Destination IP End Point, so it can be used next time.
                    // But first we need to validate that this socket is already not in the list. We do not want same socket to be twice in the list.

                    HttpWebRequest.RemoveStreamFromPool(m_responseStream);

                    // Closing connection socket.
                    m_responseStream.Dispose();
                }
                else
                {
                    m_responseStream.ReleaseStream();
                }

                // Set flag that we already completed work on this stream.
                m_responseStream = null;
            }

            base.Dispose(disposing);
        }