internal bool DumpCorrupttedData(ClientResponseContext context) { if (context.BytesTransferred == 0) { context.Clear(); return(false); } if (this.Manager.Configuration.DumpCorruptResponse) { #if !SILVERLIGHT using (var dumpStream = OpenDumpStream(context.SessionStartedAt, context.RemoteEndPoint, context.SessionId, MessageType.Response, context.MessageId)) #else using (var storage = IsolatedStorageFile.GetUserStoreForApplication()) using (var dumpStream = OpenDumpStream(storage, context.SessionStartedAt, context.RemoteEndPoint, context.SessionId, MessageType.Response, context.MessageId)) #endif { dumpStream.Write(context.CurrentReceivingBuffer, context.CurrentReceivingBufferOffset, context.BytesTransferred); dumpStream.Flush(); } } context.ShiftCurrentReceivingBuffer(); return(true); }
/// <summary> /// Returns the response context to the pool. /// </summary> /// <param name="context">The response to the pool.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="context"/> is <c>null</c>. /// </exception> protected internal void ReturnResponseContext(ClientResponseContext context) { if (context == null) { throw new ArgumentNullException("context"); } Contract.EndContractBlock(); context.Clear(); context.UnboundTransport(); this.ResponseContextPool.Return(context); }
public void TestClear() { var target = new ClientResponseContext(); MakeBufferDirty(target); target.Clear(); Assert.That(target.BoundTransport, Is.Not.Null); Assert.That(target.CurrentReceivingBuffer, Is.Not.Null); Assert.That(target.CurrentReceivingBufferOffset, Is.Not.EqualTo(0)); Assert.That(target.ErrorBuffer, Is.Null); Assert.That(target.ErrorStartAt, Is.EqualTo(-1)); Assert.That(target.HeaderUnpacker, Is.Null); Assert.That(target.MessageId, Is.Null); Assert.That(target.NextProcess, Is.Not.Null); Assert.That(target.ReceivedData, Is.Not.Null); Assert.That(target.ResultBuffer, Is.Null); Assert.That(target.ResultStartAt, Is.EqualTo(-1)); Assert.That(target.RootUnpacker, Is.Null); Assert.That(target.SessionId, Is.EqualTo(0)); Assert.That(target.SessionStartedAt, Is.EqualTo(default(DateTimeOffset))); Assert.That(target.UnpackingBuffer, Is.Null); }
internal bool DumpCorrupttedData( ClientResponseContext context ) { if ( context.BytesTransferred == 0 ) { context.Clear(); return false; } if ( this.Manager.Configuration.DumpCorruptResponse ) { #if !SILVERLIGHT using ( var dumpStream = OpenDumpStream( context.SessionStartedAt, context.RemoteEndPoint, context.SessionId, MessageType.Response, context.MessageId ) ) #else using( var storage = IsolatedStorageFile.GetUserStoreForApplication() ) using( var dumpStream = OpenDumpStream( storage, context.SessionStartedAt, context.RemoteEndPoint, context.SessionId, MessageType.Response, context.MessageId ) ) #endif { dumpStream.Write( context.CurrentReceivingBuffer, context.CurrentReceivingBufferOffset, context.BytesTransferred ); dumpStream.Flush(); } } context.ShiftCurrentReceivingBuffer(); return true; }
/// <summary> /// Returns the response context to the pool. /// </summary> /// <param name="context">The response to the pool.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="context"/> is <c>null</c>. /// </exception> protected internal void ReturnResponseContext( ClientResponseContext context ) { if ( context == null ) { throw new ArgumentNullException( "context" ); } Contract.EndContractBlock(); context.Clear(); context.UnboundTransport(); this.ResponseContextPool.Return( context ); }