public void StopAcceptingReads() { // Can't use dispose (or close) as can be disposed too early by user code // As exampled in EngineTests.ZeroContentLengthNotSetAutomaticallyForCertainStatusCodes _state = HttpStreamState.Closed; _body = null; }
public Streams(IISHttpContext context) { _context = context; _request = new HttpRequestStream(_context); _response = new HttpResponseStream(_context, _context); _upgradeableResponse = new WrappingStream(_response); _upgradeableRequest = new WrappingStream(_request); }
public void StartAcceptingReads(IISHttpContext body) { // Only start if not aborted if (_state == HttpStreamState.Closed) { _state = HttpStreamState.Open; _body = body; } }
///<inheritdoc/> public Task InitializeAsync(AuthenticationScheme scheme, HttpContext context) { _iisHttpContext = context.Features.Get <IISHttpContext>(); if (_iisHttpContext == null) { throw new InvalidOperationException("No IISHttpContext found."); } Scheme = scheme; _context = context; return(Task.CompletedTask); }
private static void OnDisconnect(IntPtr pvManagedHttpContext) { IISHttpContext context = null; try { context = (IISHttpContext)GCHandle.FromIntPtr(pvManagedHttpContext).Target; context?.AbortIO(clientDisconnect: true); } catch (Exception ex) { context?.Server._logger.LogError(0, ex, $"Unexpected exception in {nameof(IISHttpServer)}.{nameof(OnDisconnect)}."); } }
private static void CompleteRequest(IISHttpContext context, bool result) { // Post completion after completing the request to resume the state machine context.PostCompletion(ConvertRequestCompletionResults(result)); if (Interlocked.Decrement(ref context.Server._outstandingRequests) == 0 && context.Server.Stopping) { // All requests have been drained. context.Server._nativeApplication.StopCallsIntoManaged(); context.Server._shutdownSignal.TrySetResult(null); } // Dispose the context context.Dispose(); }
private static async Task HandleRequest(IISHttpContext context) { bool successfulRequest = false; try { successfulRequest = await context.ProcessRequestAsync(); } catch (Exception ex) { context.Server._logger.LogError("Exception in ProcessRequestAsync", ex); } finally { CompleteRequest(context, successfulRequest); } }
private static NativeMethods.REQUEST_NOTIFICATION_STATUS OnAsyncCompletion(IntPtr pvManagedHttpContext, int hr, int bytes) { IISHttpContext context = null; try { context = (IISHttpContext)GCHandle.FromIntPtr(pvManagedHttpContext).Target; context?.OnAsyncCompletion(hr, bytes); return(NativeMethods.REQUEST_NOTIFICATION_STATUS.RQ_NOTIFICATION_PENDING); } catch (Exception ex) { context?.Server._logger.LogError(0, ex, $"Unexpected exception in {nameof(IISHttpServer)}.{nameof(OnAsyncCompletion)}."); return(NativeMethods.REQUEST_NOTIFICATION_STATUS.RQ_NOTIFICATION_FINISH_REQUEST); } }
private static async Task HandleRequest(IISHttpContext context) { bool successfulRequest = false; try { successfulRequest = await context.ProcessRequestAsync(); } catch (Exception ex) { context.Server._logger.LogError(0, ex, $"Unexpected exception in {nameof(IISHttpServer)}.{nameof(HandleRequest)}."); } finally { CompleteRequest(context, successfulRequest); } }
public IISHttpRequestBody(IISHttpContext httpContext) { _httpContext = httpContext; }
public HttpResponseStream(IHttpBodyControlFeature bodyControl, IISHttpContext context) { _bodyControl = bodyControl; _context = context; _state = HttpStreamState.Closed; }
public IISHttpResponseBody(IISHttpContext httpContext) { _httpContext = httpContext; }