// The request is being aborted, but large writes may be in progress. Cancel them. internal void ForceCancelRequest(CriticalHandle requestQueueHandle, ulong requestId) { uint statusCode = UnsafeNclNativeMethods.HttpApi.HttpCancelHttpRequest(requestQueueHandle, requestId, IntPtr.Zero); // Either the connection has already dropped, or the last write is in progress. // The requestId becomes invalid as soon as the last Content-Length write starts. // The only way to cancel now is with CancelIoEx. if (statusCode == UnsafeNclNativeMethods.ErrorCodes.ERROR_CONNECTION_INVALID) { m_Response.CancelLastWrite(requestQueueHandle); } }