private static void CompleteTheRead(InetAsyncResult iar) { if ((iar._responseStream != null) && ((iar._exception == null) || !(iar._exception is InetStreamOverflowException))) { iar._responseStream.Close(); } iar._localStream.Position = 0L; iar._isCompleted = true; iar._asyncEvent.Set(); if (iar._callback != null) { iar._callback(iar); } }
// Methods public static IAsyncResult BeginRead(WebRequest req, AsyncCallback callback, object callbackData, uint cbMaxSize) { HttpWebRequest request = req as HttpWebRequest; if (request != null) { request.KeepAlive = false; } InetAsyncResult state = new InetAsyncResult(callback, callbackData, cbMaxSize) { _req = req }; HostProxyInfo hostProxyInfo = null; lock (s_HostProxyInfo) { hostProxyInfo = GetHostProxyInfo(state._req.RequestUri); } if ((hostProxyInfo != null) && (hostProxyInfo.Proxy != null)) { state._req.Proxy = hostProxyInfo.Proxy; } else { state._req.Proxy = null; } state._req.BeginGetResponse(new AsyncCallback(InetStream.RespCallback), state); return state; }