Пример #1
0
 public static IntPtr WinHttpSetStatusCallback(
     SafeWinHttpHandle handle,
     Interop.WinHttp.WINHTTP_STATUS_CALLBACK callback,
     uint notificationFlags,
     IntPtr reserved)
 {
     return(IntPtr.Zero);
 }
Пример #2
0
        public static IntPtr WinHttpSetStatusCallback(
            SafeWinHttpHandle handle,
            Interop.WinHttp.WINHTTP_STATUS_CALLBACK callback,
            uint notificationFlags,
            IntPtr reserved)
        {
            if (handle == null)
            {
                throw new ArgumentNullException("handle");
            }

            return(IntPtr.Zero);
        }
Пример #3
0
        public static IntPtr WinHttpSetStatusCallback(
            SafeWinHttpHandle handle,
            Interop.WinHttp.WINHTTP_STATUS_CALLBACK callback,
            uint notificationFlags,
            IntPtr reserved)
        {
            if (handle == null)
            {
                throw new ArgumentNullException(nameof(handle));
            }

            var fakeHandle = (FakeSafeWinHttpHandle)handle;

            fakeHandle.Callback = callback;

            return(IntPtr.Zero);
        }
Пример #4
0
        private void SetStatusCallback(
            SafeWinHttpHandle requestHandle,
            Interop.WinHttp.WINHTTP_STATUS_CALLBACK callback)
        {
            IntPtr oldCallback = Interop.WinHttp.WinHttpSetStatusCallback(
                requestHandle,
                callback,
                Interop.WinHttp.WINHTTP_CALLBACK_FLAG_ALL_NOTIFICATIONS,
                IntPtr.Zero);

            if (oldCallback == new IntPtr(Interop.WinHttp.WINHTTP_INVALID_STATUS_CALLBACK))
            {
                int lastError = Marshal.GetLastWin32Error();
                if (lastError != Interop.WinHttp.ERROR_INVALID_HANDLE) // Ignore error if handle was already closed.
                {
                    throw WinHttpException.CreateExceptionUsingError(lastError);
                }
            }
        }
Пример #5
0
        private void SetStatusCallback(
            SafeWinHttpHandle requestHandle,
            Interop.WinHttp.WINHTTP_STATUS_CALLBACK callback)
        {
            // TODO: Issue #5036. Having the status callback use WINHTTP_CALLBACK_FLAG_ALL_NOTIFICATIONS
            // isn't strictly necessary. However, some of the notification flags are required.
            // This will be addressed this as part of WinHttpHandler performance improvements.
            IntPtr oldCallback = Interop.WinHttp.WinHttpSetStatusCallback(
                requestHandle,
                callback,
                Interop.WinHttp.WINHTTP_CALLBACK_FLAG_ALL_NOTIFICATIONS,
                IntPtr.Zero);

            if (oldCallback == new IntPtr(Interop.WinHttp.WINHTTP_INVALID_STATUS_CALLBACK))
            {
                int lastError = Marshal.GetLastWin32Error();
                if (lastError != Interop.WinHttp.ERROR_INVALID_HANDLE) // Ignore error if handle was already closed.
                {
                    throw WinHttpException.CreateExceptionUsingError(lastError);
                }
            }
        }