Exemple #1
0
 public Http1OutputProducer(
     PipeReader outputPipeReader,
     PipeWriter pipeWriter,
     string connectionId,
     IKestrelTrace log,
     ITimeoutControl timeoutControl,
     IConnectionLifetimeFeature lifetimeFeature,
     IBytesWrittenFeature transportBytesWrittenFeature)
 {
     _outputPipeReader = outputPipeReader;
     _pipeWriter       = pipeWriter;
     _connectionId     = connectionId;
     _timeoutControl   = timeoutControl;
     _log             = log;
     _flushCompleted  = OnFlushCompleted;
     _lifetimeFeature = lifetimeFeature;
     _transportBytesWrittenFeature = transportBytesWrittenFeature;
 }
        private void InitializeFeatures()
        {
            _httpContext       = _context.ConnectionFeatures.Get <HttpListenerContext>();
            _connectionFeature = _context.ConnectionFeatures.Get <IConnectionLifetimeFeature>();

            var interfaces = this.GetType().GetInterfaces();

            foreach (var @interface in interfaces)
            {
                if (@interface is IFeatureCollection)
                {
                    continue;
                }
                _supportedFeatures.Add(@interface);
            }
            _requestHeaders = new RequestHeaderDictionary(_httpContext.Request.Headers,
                                                          _httpContext.Request.ContentLength64);
            _responseHeaders = new ResponseHeaderDictionary(_httpContext.Response);
        }
        private Http1OutputProducer CreateOutputProducer(
            PipeOptions pipeOptions = null,
            IConnectionLifetimeFeature lifetimeFeature = null)
        {
            pipeOptions     = pipeOptions ?? new PipeOptions();
            lifetimeFeature = lifetimeFeature ?? Mock.Of <IConnectionLifetimeFeature>();

            var pipe           = new Pipe(pipeOptions);
            var serviceContext = new TestServiceContext();
            var socketOutput   = new Http1OutputProducer(
                pipe.Reader,
                pipe.Writer,
                "0",
                serviceContext.Log,
                Mock.Of <ITimeoutControl>(),
                lifetimeFeature,
                Mock.Of <IBytesWrittenFeature>());

            return(socketOutput);
        }