HttpServer.HttpRequest.Clone C# (CSharp) Method

Clone() public method

Creates a new object that is a copy of the current instance.
public Clone ( ) : object
return object
        public object Clone()
        {
            // this method was mainly created for testing.
            // dont use it that much...
            HttpRequest request = new HttpRequest();
            request.Method = _method;
            if (_acceptTypes != null)
            {
                request._acceptTypes = new string[_acceptTypes.Length];
                _acceptTypes.CopyTo(request._acceptTypes, 0);
            }
            request._httpVersion = _httpVersion;
            request._queryString = _queryString;
            request.Uri = _uri;

            byte[] buffer = new byte[_body.Length];
            _body.Read(buffer, 0, (int)_body.Length);
            request.Body = new MemoryStream();
            request.Body.Write(buffer, 0, buffer.Length);
            request.Body.Seek(0, SeekOrigin.Begin);
            request.Body.Flush();

            request._headers.Clear();
            foreach (string key in _headers)
            {
                string[] values = _headers.GetValues(key);
                if (values != null)
                    foreach (string value in values)
                        request.AddHeader(key, value);
            }
            Clear();
            return request;
        }