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, JwtBearerTokenFactory = hubConnectionBuilder.GetJwtBearerTokenFactory(), WebSocketOptions = hubConnectionBuilder.GetWebSocketOptions(), }; return(new HttpConnection(url, hubConnectionBuilder.GetTransport(), hubConnectionBuilder.GetLoggerFactory(), httpOptions)); }); return(hubConnectionBuilder); }
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(), Cookies = hubConnectionBuilder.GetCookies(), Proxy = hubConnectionBuilder.GetProxy(), UseDefaultCredentials = hubConnectionBuilder.GetUseDefaultCredentials(), ClientCertificates = hubConnectionBuilder.GetClientCertificates(), Credentials = hubConnectionBuilder.GetCredentials(), }; return(new HttpConnection(url, hubConnectionBuilder.GetTransport(), hubConnectionBuilder.GetLoggerFactory(), httpOptions)); }); return(hubConnectionBuilder); }
public static IHubConnectionBuilder WithHeader(this IHubConnectionBuilder hubConnectionBuilder, string name, string value) { if (string.IsNullOrEmpty(name)) { throw new ArgumentException("Header name cannot be null or empty string.", nameof(name)); } var headers = hubConnectionBuilder.GetHeaders(); if (headers == null) { headers = new Dictionary <string, string>(); hubConnectionBuilder.AddSetting(HeadersKey, headers); } headers.Add(name, value); return(hubConnectionBuilder); }