/// <summary>cleanup work to do once the request has completed</summary> protected override void CompletedRequest() { byte[] buffer = this.asyncStreamCopyBuffer; this.asyncStreamCopyBuffer = null; if ((null != buffer) && !this.usingBuffer) { this.PutAsyncResponseStreamCopyBuffer(buffer); } if (this.responseStreamOwner) { if (null != this.outputResponseStream) { this.outputResponseStream.Position = 0; } } Debug.Assert(null != this.responseMessage || null != this.Failure || this.IsAborted, "should have response or exception"); if (null != this.responseMessage) { if (!this.AllowDirectNetworkStreamReading) { // we've cached off what we need, headers still accessible after close WebUtil.DisposeMessage(this.responseMessage); } Version responseVersion; Exception ex = SaveResult.HandleResponse( this.RequestInfo, this.StatusCode, this.responseMessage.GetHeader(XmlConstants.HttpDataServiceVersion), this.GetResponseStream, false, out responseVersion); if (null != ex) { this.HandleFailure(ex); } else { this.responseInfo = this.CreateResponseInfo(); } } }
/// <summary>invoked for derived classes to cleanup before callback is invoked</summary> protected override void CompletedRequest() { Debug.Assert(null != this.responseMessage || null != this.Failure, "should have response or exception"); if (null != this.responseMessage) { // Can't use DataServiceContext.HandleResponse as this request didn't necessarily go to our server // the MR could have been served by arbitrary server. InvalidOperationException failure = null; if (!WebUtil.SuccessStatusCode((HttpStatusCode)this.responseMessage.StatusCode)) { failure = SaveResult.GetResponseText( this.responseMessage.GetStream, (HttpStatusCode)this.responseMessage.StatusCode); } if (failure != null) { // we've cached off what we need, headers still accessible after close WebUtil.DisposeMessage(this.responseMessage); this.HandleFailure(failure); } } }