示例#1
0
 public void Http3StreamAbort(string traceIdentifier, Http3ErrorCode error, ConnectionAbortedException abortReason)
 {
     _trace1.Http3StreamAbort(traceIdentifier, error, abortReason);
     _trace2.Http3StreamAbort(traceIdentifier, error, abortReason);
 }
 public override void Abort(ConnectionAbortedException abortReason)
 {
     _httpContext.Abort();
 }
示例#3
0
 public void Http2StreamResetAbort(string traceIdentifier, Http2ErrorCode error, ConnectionAbortedException abortReason)
 {
     _http2StreamResetError(_logger, traceIdentifier, error, abortReason);
 }
示例#4
0
 public void Close(ConnectionAbortedException exception = default) => this.CloseInternal(exception);
示例#5
0
 void IHttpOutputAborter.Abort(ConnectionAbortedException abortReason)
 {
     _stream.Abort(abortReason, Http3ErrorCode.InternalError);
 }
示例#6
0
 public override void Abort(ConnectionAbortedException abortReason)
 {
 }
示例#7
0
 public void Abort(ConnectionAbortedException error)
 {
     // TODO: RST_STREAM?
 }
        private async Task DoReceive()
        {
            Exception error = null;

            try
            {
                while (true)
                {
                    // Ensure we have some reasonable amount of buffer space
                    var buffer = Input.GetMemory(MinAllocBufferSize);

                    var bytesReceived = await _receiver.ReceiveAsync(buffer);

                    if (bytesReceived == 0)
                    {
                        // FIN
                        _trace.ConnectionReadFin(ConnectionId);
                        break;
                    }

                    Input.Advance(bytesReceived);


                    var flushTask = Input.FlushAsync();

                    if (!flushTask.IsCompleted)
                    {
                        _trace.ConnectionPause(ConnectionId);

                        await flushTask;

                        _trace.ConnectionResume(ConnectionId);
                    }

                    var result = flushTask.GetAwaiter().GetResult();
                    if (result.IsCompleted)
                    {
                        // Pipe consumer is shut down, do we stop writing
                        break;
                    }
                }
            }
            catch (SocketException ex) when(ex.SocketErrorCode == SocketError.ConnectionReset)
            {
                error = new ConnectionResetException(ex.Message, ex);
                _trace.ConnectionReset(ConnectionId);
            }
            catch (SocketException ex) when(ex.SocketErrorCode == SocketError.OperationAborted ||
                                            ex.SocketErrorCode == SocketError.ConnectionAborted ||
                                            ex.SocketErrorCode == SocketError.Interrupted ||
                                            ex.SocketErrorCode == SocketError.InvalidArgument)
            {
                if (!_aborted)
                {
                    // Calling Dispose after ReceiveAsync can cause an "InvalidArgument" error on *nix.
                    error = new ConnectionAbortedException();
                    _trace.ConnectionError(ConnectionId, error);
                }
            }
            catch (ObjectDisposedException)
            {
                if (!_aborted)
                {
                    error = new ConnectionAbortedException();
                    _trace.ConnectionError(ConnectionId, error);
                }
            }
            catch (IOException ex)
            {
                error = ex;
                _trace.ConnectionError(ConnectionId, error);
            }
            catch (Exception ex)
            {
                error = new IOException(ex.Message, ex);
                _trace.ConnectionError(ConnectionId, error);
            }
            finally
            {
                if (_aborted)
                {
                    error = error ?? new ConnectionAbortedException();
                }

                Input.Complete(error);
            }
        }
示例#9
0
 public void Abort(ConnectionAbortedException ex)
 {
     Abort(ex, Http3ErrorCode.InternalError);
 }
 public void Abort(ConnectionAbortedException ex)
 {
     _stopping = true;
     _frameWriter.Abort(ex);
 }
 public void Abort(ConnectionAbortedException abortReason)
 {
     Dispose();
 }
示例#12
0
        protected override void ApplicationAbort()
        {
            var abortReason = new ConnectionAbortedException(CoreStrings.ConnectionAbortedByApplication);

            ResetAndAbort(abortReason, Http2ErrorCode.CANCEL);
        }
示例#13
0
 public override void Abort(ConnectionAbortedException abortReason)
 {
     // dedup calls to abort here.
     _closeTask = _connection.CloseAsync(errorCode: Error).AsTask();
 }
示例#14
0
 // This is called when a CancellationToken fires mid-write. In HTTP/1.x, this aborts the entire connection.
 // For HTTP/2 we abort the stream.
 void IHttpOutputAborter.Abort(ConnectionAbortedException abortReason)
 {
     _stream.ResetAndAbort(abortReason, Http2ErrorCode.INTERNAL_ERROR);
     Dispose();
 }