public HttpConnection(Uri url, HttpTransportType transports, ILoggerFactory loggerFactory, HttpOptions httpOptions)
        {
            Url            = url ?? throw new ArgumentNullException(nameof(url));
            _loggerFactory = loggerFactory ?? NullLoggerFactory.Instance;

            _logger      = _loggerFactory.CreateLogger <HttpConnection>();
            _httpOptions = httpOptions;

            _requestedTransports = transports;
            if (_requestedTransports != HttpTransportType.WebSockets)
            {
                _httpClient = CreateHttpClient();
            }

            _transportFactory = new DefaultTransportFactory(transports, _loggerFactory, _httpClient, httpOptions);
            _logScope         = new ConnectionLogScope();
            _scopeDisposable  = _logger.BeginScope(_logScope);
        }
        public DefaultTransportFactory(TransportType requestedTransportType, ILoggerFactory loggerFactory, HttpClient httpClient, HttpOptions httpOptions)
        {
            if (requestedTransportType <= 0 || requestedTransportType > TransportType.All)
            {
                throw new ArgumentOutOfRangeException(nameof(requestedTransportType));
            }

            if (httpClient == null && requestedTransportType != TransportType.WebSockets)
            {
                throw new ArgumentNullException(nameof(httpClient));
            }

            _requestedTransportType = requestedTransportType;
            _loggerFactory          = loggerFactory;
            _httpClient             = httpClient;
            _httpOptions            = httpOptions;
        }
 public HttpConnection(Uri url, ITransportFactory transportFactory, ILoggerFactory loggerFactory, HttpOptions httpOptions)
 {
     Url                  = url ?? throw new ArgumentNullException(nameof(url));
     _loggerFactory       = loggerFactory ?? NullLoggerFactory.Instance;
     _logger              = _loggerFactory.CreateLogger <HttpConnection>();
     _httpOptions         = httpOptions;
     _httpClient          = CreateHttpClient();
     _requestedTransports = HttpTransports.All;
     _transportFactory    = transportFactory ?? throw new ArgumentNullException(nameof(transportFactory));
     _logScope            = new ConnectionLogScope();
     _scopeDisposable     = _logger.BeginScope(_logScope);
 }