コード例 #1
0
ファイル: HttpApi.cs プロジェクト: clrjunkie/Kalinda
 internal static extern UInt32 HttpSetRequestQueueProperty(
     CriticalHandle Handle,
     HTTP_SERVER_PROPERTY Property,
     IntPtr pPropertyInformation,
     UInt32 PropertyInformationLength,
     UInt32 Reserved,
     IntPtr pReserved);
コード例 #2
0
ファイル: Utility.cs プロジェクト: YunLi1988/ServiceBusFake
 internal static void CloseInvalidOutCriticalHandle(CriticalHandle handle)
 {
     if (handle != null)
     {
         handle.SetHandleAsInvalid();
     }
 }
コード例 #3
0
ファイル: Tuning.cs プロジェクト: honghong75042/Happer
 internal static extern uint HttpSetRequestQueueProperty(
     CriticalHandle requestQueueHandle,   // _In_       HANDLE               Handle,
     HTTP_SERVER_PROPERTY serverProperty, // _In_       HTTP_SERVER_PROPERTY Property,
     ref uint pPropertyInfo,              // _In_       PVOID                pPropertyInformation,
     uint propertyInfoLength,             // _In_       ULONG                PropertyInformationLength,
     uint reserved,                       // _Reserved_ ULONG                Reserved,
     IntPtr pReserved);                   // _Reserved_ PVOID                pReserved
コード例 #4
0
ファイル: PlatformUtils.cs プロジェクト: dotnetchris/nfx
 internal static extern uint HttpSetRequestQueueProperty(
     CriticalHandle requestQueueHandle,
     HTTP_SERVER_PROPERTY serverProperty,
     IntPtr pPropertyInfo,
     uint propertyInfoLength,
     uint reserved,
     IntPtr pReserved);
コード例 #5
0
 internal void CancelLastWrite(CriticalHandle requestQueueHandle)
 {
     if (m_ResponseStream != null)
     {
         m_ResponseStream.CancelLastWrite(requestQueueHandle);
     }
 }
コード例 #6
0
        internal void CancelLastWrite(CriticalHandle requestQueueHandle)
        {
            HttpResponseStreamAsyncResult asyncState = m_LastWrite;

            if (asyncState != null && !asyncState.IsCompleted)
            {
                UnsafeNclNativeMethods.CancelIoEx(requestQueueHandle, asyncState.m_pOverlapped);
            }
        }
コード例 #7
0
 internal static unsafe void CancelRequest(CriticalHandle requestQueueHandle, ulong requestId)
 {
     UnsafeNclNativeMethods.HttpApi.HTTP_DATA_CHUNK http_data_chunk;
     http_data_chunk = new UnsafeNclNativeMethods.HttpApi.HTTP_DATA_CHUNK {
         DataChunkType = UnsafeNclNativeMethods.HttpApi.HTTP_DATA_CHUNK_TYPE.HttpDataChunkFromMemory,
         pBuffer       = (byte *)&http_data_chunk
     };
     UnsafeNclNativeMethods.HttpApi.HttpSendResponseEntityBody(requestQueueHandle, requestId, 1, 1, &http_data_chunk, null, SafeLocalFree.Zero, 0, null, null);
 }
コード例 #8
0
        /// <summary>
        /// Initializes the Request Queue Handler.  Meant to be called once the servers <see cref="HttpListener"/> has been started.
        /// </summary>
        public void Initialize()
        {
            // HACK: Get the request queue handle so we can register for disconnect
            var requestQueueHandleField = typeof(HttpListener).GetField("m_RequestQueueHandle", BindingFlags.Instance | BindingFlags.NonPublic);

            if (requestQueueHandleField != null)
            {
                _requestQueueHandle = (CriticalHandle)requestQueueHandleField.GetValue(_listener);
            }
        }
コード例 #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CriticalHandleAdapter"/> class.
        /// </summary>
        /// <param name="handle">Handle to be used by the adapter.</param>
        public CriticalHandleAdapter(CriticalHandle handle)
            : base(handle)
        {
            if (handle == null)
            {
                throw new ArgumentNullException(nameof(handle));
            }

            _instance = handle;
        }
コード例 #10
0
        private bool IsSQLiteConnectionHandle(CriticalHandle handle)
        {
            if (handle is null)
            {
                return(false);
            }

            // if I can just get the type from somewhere and store it I can compare it here
            return(handle.GetType() == _sqliteConnectionHandleType);//typeof(SQLiteConnectionHandle);
        }
コード例 #11
0
        [SuppressMessage(FxCop.Category.Security, FxCop.Rule.TransparentMethodsMustNotReferenceCriticalCode)] // we got APTCA approval with no requirement to fix this transparency warning. plus, the callers of this method are not supported in partial trust.
        internal static void CloseInvalidOutCriticalHandle(CriticalHandle handle)
        {
            if (handle != null)
            {
#pragma warning disable 618
                Fx.Assert(handle.IsInvalid, "CloseInvalidOutCriticalHandle called with a valid handle!");
#pragma warning restore 618

                handle.SetHandleAsInvalid();
            }
        }
コード例 #12
0
        // 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);
            }
        }
コード例 #13
0
        /// <summary>
        /// Initializes the Request Queue Handler.  Meant to be called once the servers <see cref="HttpListener"/> has been started.
        /// </summary>
        public void Initialize()
        {
            // Get the request queue handle so we can register for disconnect
            var requestQueueHandleField = typeof(HttpListener).GetField("m_RequestQueueHandle", BindingFlags.Instance | BindingFlags.NonPublic);

            // Get the connection id field info from the request object
            _connectionIdField = typeof(HttpListenerRequest).GetField("m_ConnectionId", BindingFlags.Instance | BindingFlags.NonPublic);

            if (requestQueueHandleField != null)
            {
                _requestQueueHandle = (CriticalHandle)requestQueueHandleField.GetValue(_listener);
            }
        }
コード例 #14
0
        internal static unsafe void SetRequestQueueLength(System.Net.HttpListener listener, long length)
        {
            Type         listenerType = typeof(System.Net.HttpListener);
            PropertyInfo requestQueueHandleProperty = listenerType.GetProperty("RequestQueueHandle", BindingFlags.NonPublic | BindingFlags.Instance);

            if (requestQueueHandleProperty == null || requestQueueHandleProperty.PropertyType != typeof(CriticalHandle))
            {
                // The property changed, no-op.
                return;
            }

            CriticalHandle requestQueueHandle = (CriticalHandle)requestQueueHandleProperty.GetValue(listener, null);
            uint           result             = HttpSetRequestQueueProperty(requestQueueHandle, HTTP_SERVER_PROPERTY.HttpServerQueueLengthProperty,
                                                                            new IntPtr((void *)&length), (uint)Marshal.SizeOf(length), 0, IntPtr.Zero);

            if (result != 0)
            {
                throw new Win32Exception((int)result);
            }
        }
コード例 #15
0
        internal DisconnectHandler(WebListener listener, LoggerFunc logger)
        {
            _connectionCancellationTokens = new ConcurrentDictionary <ulong, ConnectionCancellation>();
            _listener = listener;
            _logger   = logger;

            // Get the request queue handle so we can register for disconnect
            FieldInfo requestQueueHandleField = typeof(WebListener).GetField("m_RequestQueueHandle", BindingFlags.Instance | BindingFlags.NonPublic);

            // Get the connection id field info from the request object
            _connectionIdField = typeof(Request).GetField("m_ConnectionId", BindingFlags.Instance | BindingFlags.NonPublic);

            if (requestQueueHandleField != null && requestQueueHandleField.FieldType == typeof(CriticalHandle))
            {
                _requestQueueHandle = (CriticalHandle)requestQueueHandleField.GetValue(_listener);
            }
            if (_connectionIdField == null || _requestQueueHandle == null)
            {
                LogHelper.LogInfo(_logger, "Unable to resolve handles. Disconnect notifications will be ignored.");
            }
        }
コード例 #16
0
ファイル: httpapi.cs プロジェクト: shenrui93/saker
 internal static extern uint HttpReceiveRequestEntityBody2(CriticalHandle requestQueueHandle, ulong requestId, uint flags, void *pEntityBuffer, uint entityBufferLength, out uint bytesReturned, [In] SafeHandle pOverlapped);
コード例 #17
0
ファイル: httpapi.cs プロジェクト: shenrui93/saker
 internal static extern uint HttpReceiveHttpRequest(CriticalHandle requestQueueHandle, ulong requestId, uint flags, HTTP_REQUEST *pRequestBuffer, uint requestBufferLength, uint *pBytesReturned, NativeOverlapped *pOverlapped);
コード例 #18
0
ファイル: httpapi.cs プロジェクト: shenrui93/saker
 internal static extern uint HttpSendHttpResponse(CriticalHandle requestQueueHandle, ulong requestId, uint flags, HTTP_RESPONSE *pHttpResponse, void *pCachePolicy, uint *pBytesSent, SafeLocalFree pRequestBuffer, uint requestBufferLength, NativeOverlapped *pOverlapped, void *pLogData);
コード例 #19
0
ファイル: httpapi.cs プロジェクト: shenrui93/saker
 internal static extern uint HttpCancelHttpRequest(CriticalHandle requestQueueHandle, ulong requestId, IntPtr pOverlapped);
コード例 #20
0
ファイル: httpapi.cs プロジェクト: shenrui93/saker
 internal static extern uint HttpSendResponseEntityBody(CriticalHandle requestQueueHandle, ulong requestId, uint flags, ushort entityChunkCount, HTTP_DATA_CHUNK *pEntityChunks, uint *pBytesSent, SafeLocalFree pRequestBuffer, uint requestBufferLength, NativeOverlapped *pOverlapped, void *pLogData);
コード例 #21
0
ファイル: httpapi.cs プロジェクト: shenrui93/saker
 internal static extern uint HttpSendResponseEntityBody2(CriticalHandle requestQueueHandle, ulong requestId, uint flags, ushort entityChunkCount, IntPtr pEntityChunks, out uint pBytesSent, SafeLocalFree pRequestBuffer, uint requestBufferLength, SafeHandle pOverlapped, IntPtr pLogData);
コード例 #22
0
 /// <summary>
 /// Converts <see cref="CriticalHandle"/> to <see cref="ICriticalHandle"/>.
 /// </summary>
 /// <param name="handle"><see cref="CriticalHandle"/> to convert.</param>
 /// <returns>Instance of <see cref="ICriticalHandle"/>.</returns>
 public static ICriticalHandle ToInterface(this CriticalHandle handle)
 {
     return((handle == null) ? null : new CriticalHandleAdapter(handle));
 }
コード例 #23
0
 internal static void CancelRequest(CriticalHandle requestQueueHandle, ulong requestId)
 {
     uint statusCode = UnsafeNclNativeMethods.HttpApi.HttpCancelHttpRequest(requestQueueHandle, requestId,
                                                                            IntPtr.Zero);
 }
コード例 #24
0
 internal static extern unsafe uint HttpWaitForDisconnectEx(CriticalHandle requestQueueHandle, ulong connectionId, uint reserved, NativeOverlapped *pOverlapped);
コード例 #25
0
ファイル: httpapi.cs プロジェクト: shenrui93/saker
 internal static extern uint HttpReceiveClientCertificate(CriticalHandle requestQueueHandle, ulong connectionId, uint flags, byte *pSslClientCertInfo, uint sslClientCertInfoSize, uint *pBytesReceived, NativeOverlapped *pOverlapped);