void _EndRequest(IAsyncResult result) { RequestStruct obj = (RequestStruct)result.AsyncState; try { // must catch "NotFoundError" when 5xx occurs (likely is) HttpWebResponse response = obj.Request.EndGetResponse(result) as HttpWebResponse; DAVRequestResult requestResult = new DAVRequestResult(this, response, _relativeHost); obj.Callback(requestResult, obj.UserObject); } catch (WebException we) { LastException = we; obj.Callback(new DAVRequestResult(this, ((HttpWebResponse)we.Response).StatusCode, ((HttpWebResponse)we.Response).StatusDescription), obj.UserObject); } }
void _EndRequestStream(IAsyncResult result) { RequestStruct obj = (RequestStruct)result.AsyncState; DAVRequestBody body = obj.Body; try { Stream stream = obj.Request.EndGetRequestStream(result); body.XmlBody.Seek(0, SeekOrigin.Begin); body.XmlBody.CopyTo(stream, 4096); stream.Close(); obj.Request.BeginGetResponse(_EndRequest, obj); } catch (WebException we) { LastException = we; obj.Callback(new DAVRequestResult(this, ((HttpWebResponse)we.Response).StatusCode, ((HttpWebResponse)we.Response).StatusDescription), obj.UserObject); } }