public void Abort() { object locker = HTTPManager.Locker; lock (locker) { HTTPConnection connectionWith = HTTPManager.GetConnectionWith(this); if (connectionWith == null) { if (!HTTPManager.RemoveFromQueue(this)) { HTTPManager.Logger.Warning("HTTPRequest", "Abort - No active connection found with this request! (The request may already finished?)"); } this.State = HTTPRequestStates.Aborted; } else { if (this.Response != null && this.Response.IsStreamed) { this.Response.Dispose(); } connectionWith.Abort(HTTPConnectionStates.AbortRequested); } } }
/// <summary> /// Aborts an already estabilished connection, so no further download or upload are done. /// </summary> public void Abort() { lock (HTTPManager.Locker) { // Get the parent connection var connection = HTTPManager.GetConnectionWith(this); // No Connection found for this request, maybe not even started if (connection == null) { // so try to remove from the request queue if (!HTTPManager.RemoveFromQueue(this)) { HTTPManager.Logger.Warning("HTTPRequest", "Abort - No active connection found with this request! (The request may already finished?)"); } this.State = HTTPRequestStates.Aborted; } else { // destroy the incomplete response if (Response != null && Response.IsStreamed) { Response.Dispose(); } // send an abort request to the connection connection.Abort(HTTPConnectionStates.AbortRequested); } } }