public static IHubConnectionBuilder WithUrl(this IHubConnectionBuilder hubConnectionBuilder, Uri url)
        {
            if (url == null)
            {
                throw new ArgumentNullException(nameof(url));
            }

            hubConnectionBuilder.ConfigureConnectionFactory(() =>
            {
                var headers     = hubConnectionBuilder.GetHeaders();
                var httpOptions = new HttpOptions
                {
                    HttpMessageHandler = hubConnectionBuilder.GetMessageHandler(),
                    Headers            = headers != null ? new ReadOnlyDictionary <string, string>(headers) : null,
                    AccessTokenFactory = hubConnectionBuilder.GetAccessTokenFactory(),
                    WebSocketOptions   = hubConnectionBuilder.GetWebSocketOptions(),
                };

                return(new HttpConnection(url,
                                          hubConnectionBuilder.GetTransport(),
                                          hubConnectionBuilder.GetLoggerFactory(),
                                          httpOptions));
            });
            return(hubConnectionBuilder);
        }