Skip to content

Commit 9908f8a

Browse files
committed
Throw exception when user passes only SSE when running in browser
1 parent f83f5ef commit 9908f8a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/SignalR/clients/csharp/Http.Connections.Client/src/HttpConnection.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,18 @@ public HttpConnection(HttpConnectionOptions httpConnectionOptions, ILoggerFactor
151151
_httpClient = CreateHttpClient();
152152
}
153153

154+
_isRunningInBrowser = Utils.IsRunningInBrowser();
155+
156+
157+
(if httpConnectionOptions.Transports == HttpTransportType.ServerSentEvents && _isRunningInBrowser)
158+
{
159+
throw new ArgumentException("ServerSentEvents can not be the only transport specified when running in the browser.", nameof(httpConnectionOptions));
160+
}
161+
154162
_transportFactory = new DefaultTransportFactory(httpConnectionOptions.Transports, _loggerFactory, _httpClient, httpConnectionOptions, GetAccessTokenAsync);
155163
_logScope = new ConnectionLogScope();
156164

157165
Features.Set<IConnectionInherentKeepAliveFeature>(this);
158-
159-
_isRunningInBrowser = Utils.IsRunningInBrowser();
160166
}
161167

162168
// Used by unit tests

0 commit comments

Comments
 (0)