/// <summary>
        /// Creates a new HTTPHeader, which is a clone of the given response.
        /// If the given HTTPHeader is not a response header this method returns null.
        /// If the given HTTPHeader was initialized empty and is not yet complete this method returns null.
        /// Otherwise it returns a clone of the given header.
        /// That is, it will have the same HTTP version, status code and description.
        /// Also, the headers will be a clone of the headers in the given response,
        /// but changes to the new headers will not affect the original headers.
        /// </summary>
        /// <param name="response">
        ///		A complete HTTPHeader response instance to create a clone of.
        /// </param>
        /// <returns>
        ///		Null if given an improper parameter. A clone of the original HTTPHeader otherwise.
        /// </returns>
        public static HTTPHeader CreateResponse(HTTPHeader response)
        {
            if (response.isRequest)
            {
                return(null);
            }

            if (response.isEmpty)
            {
                if (!response.IsHeaderComplete())
                {
                    return(null);
                }
                if (response.headers == null)
                {
                    response.ParseResponse();
                }
            }

            HTTPHeader clone = new HTTPHeader(false, false);

            clone.httpVersion       = response.httpVersion;
            clone.statusCode        = response.statusCode;
            clone.statusDescription = response.statusDescription;
            clone.headers           = new Dictionary <String, String>(response.headers, StringComparer.OrdinalIgnoreCase);

            return(clone);
        }
        /// <summary>
        /// Creates a new HTTPHeader, which is a clone of the given request.
        /// If the given HTTPHeader is not a request header this method returns null.
        /// If the given HTTPHeader was initialized empty and is not yet complete this method returns null.
        /// Otherwise it returns a clone of the given header.
        /// That is, it will have the same HTTP version, request method and URL.
        /// Also, the headers will be a clone of the headers in the given request,
        /// but changes to the new headers will not affect the original headers.
        /// </summary>
        /// <param name="request">
        ///		A complete HTTPHeader request instance to create a clone of.
        /// </param>
        /// <returns>
        ///		Null if given an improper parameter. A clone of the original HTTPHeader otherwise.
        /// </returns>
        public static HTTPHeader CreateRequest(HTTPHeader request)
        {
            if (!request.isRequest)
            {
                return(null);
            }

            if (request.isEmpty)
            {
                if (!request.IsHeaderComplete())
                {
                    return(null);
                }
                if (request.headers == null)
                {
                    request.ParseRequest();
                }
            }

            HTTPHeader clone = new HTTPHeader(true, false);

            clone.httpVersion   = request.httpVersion;
            clone.requestMethod = request.requestMethod;
            clone.requestURL    = request.requestURL;
            clone.headers       = new Dictionary <String, String>(request.headers, StringComparer.OrdinalIgnoreCase);

            return(clone);
        }
        /// <summary>
        /// Creates a new HTTPHeader, which is a clone of the given response.
        /// If the given HTTPHeader is not a response header this method returns null.
        /// If the given HTTPHeader was initialized empty and is not yet complete this method returns null.
        /// Otherwise it returns a clone of the given header.
        /// That is, it will have the same HTTP version, status code and description.
        /// Also, the headers will be a clone of the headers in the given response,
        /// but changes to the new headers will not affect the original headers.
        /// </summary>
        /// <param name="response">
        ///		A complete HTTPHeader response instance to create a clone of.
        /// </param>
        /// <returns>
        ///		Null if given an improper parameter. A clone of the original HTTPHeader otherwise.
        /// </returns>
        public static HTTPHeader CreateResponse(HTTPHeader response)
        {
            if (response.isRequest) return null;

            if (response.isEmpty)
            {
                if (!response.IsHeaderComplete()) return null;
                if (response.headers == null) response.ParseResponse();
            }

            HTTPHeader clone = new HTTPHeader(false, false);
            clone.httpVersion = response.httpVersion;
            clone.statusCode = response.statusCode;
            clone.statusDescription = response.statusDescription;
            clone.headers = new Dictionary<String, String>(response.headers, StringComparer.OrdinalIgnoreCase);

            return clone;
        }
        /// <summary>
        /// Creates a new HTTPHeader, which is a clone of the given request.
        /// If the given HTTPHeader is not a request header this method returns null.
        /// If the given HTTPHeader was initialized empty and is not yet complete this method returns null.
        /// Otherwise it returns a clone of the given header.
        /// That is, it will have the same HTTP version, request method and URL.
        /// Also, the headers will be a clone of the headers in the given request,
        /// but changes to the new headers will not affect the original headers.
        /// </summary>
        /// <param name="request">
        ///		A complete HTTPHeader request instance to create a clone of.
        /// </param>
        /// <returns>
        ///		Null if given an improper parameter. A clone of the original HTTPHeader otherwise.
        /// </returns>
        public static HTTPHeader CreateRequest(HTTPHeader request)
        {
            if (!request.isRequest) return null;

            if (request.isEmpty)
            {
                if (!request.IsHeaderComplete()) return null;
                if (request.headers == null) request.ParseRequest();
            }

            HTTPHeader clone = new HTTPHeader(true, false);
            clone.httpVersion = request.httpVersion;
            clone.requestMethod = request.requestMethod;
            clone.requestURL = request.requestURL;
            clone.headers = new Dictionary<String, String>(request.headers, StringComparer.OrdinalIgnoreCase);

            return clone;
        }