///<summary> ///Creates a new object that is a copy of the current instance. ///</summary> /// ///<returns> ///A new object that is a copy of this instance. ///</returns> ///<filterpriority>2</filterpriority> public object Clone() { // this method was mainly created for testing. // dont use it that much... var 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; var 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); }