private void RequestCallback(IAsyncResult asyncResult, IHttpWebRequest httpWebRequest, Stream requestBody, AsyncCallback callback, object state) { Stream requestStream = null; Exception exception = null; IHttpWebResponse httpWebResponse = null; try { requestStream = httpWebRequest.EndGetRequestStream(asyncResult); } catch (WebException ex) { var webException = new WebExceptionWrapper(ex); httpWebResponse = webException.GetResponse(); exception = webException; } finally { if (exception == null) { // we got the stream, so copy to the stream CopyRequestStream(httpWebRequest, requestBody, requestStream, callback, state); } else { // there was an error if (httpWebResponse == null) { if (callback != null) { callback(new HttpWebHelperResult(httpWebRequest, null, exception, null, false, false, null, state)); } } else { var args = new ResponseReceivedEventArgs(httpWebResponse, exception, state); OnResponseReceived(args); ReadResponseStream(httpWebRequest, httpWebResponse, exception, args.ResponseSaveStream, callback, state); } } } }
private void RequestCallback(IAsyncResult asyncResult, IHttpWebRequest httpWebRequest, Stream requestBody, AsyncCallback callback, object state) { Stream requestStream = null; Exception exception = null; IHttpWebResponse httpWebResponse = null; try { requestStream = httpWebRequest.EndGetRequestStream(asyncResult); } catch (WebException ex) { var webException = new WebExceptionWrapper(ex); httpWebResponse = webException.GetResponse(); exception = webException; } finally { if (exception == null) { // we got the stream, so copy to the stream CopyRequestStream(httpWebRequest, requestBody, requestStream, callback, state); } else { // there was an error if (httpWebResponse == null) { if (callback != null) callback(new HttpWebHelperResult(httpWebRequest, null, exception, null, false, false, null, state)); } else { var args = new ResponseReceivedEventArgs(httpWebResponse, exception, state); OnResponseReceived(args); ReadResponseStream(httpWebRequest, httpWebResponse, exception, args.ResponseSaveStream, callback, state); } } } }