Skip to content

Commit 01afd6d

Browse files
authored
Demonstrate SignalR JS header option (#20247)
1 parent 28e0190 commit 01afd6d

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

aspnetcore/signalr/configuration.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ Additional options can be configured in the `WithUrl` (`withUrl` in JavaScript)
343343
| JavaScript Option | Default Value | Description |
344344
| ----------------- | ------------- | ----------- |
345345
| `accessTokenFactory` | `null` | A function returning a string that is provided as a Bearer authentication token in HTTP requests. |
346+
| `transport` | `null` | An <xref:Microsoft.AspNetCore.Http.Connections.HttpTransportType> value specifying the transport to use for the connection. |
346347
| `headers` | `null` | Dictionary of headers sent with every HTTP request. Sending headers in the browser doesn't work for WebSockets or the <xref:Microsoft.AspNetCore.Http.Connections.HttpTransportType.ServerSentEvents> stream. |
347348
| `logMessageContent` | `null` | Set to `true` to log the bytes/chars of messages sent and received by the client. |
348349
| `skipNegotiation` | `false` | Set this to `true` to skip the negotiation step. **Only supported when the WebSockets transport is the only enabled transport**. This setting can't be enabled when using the Azure SignalR Service. |
@@ -364,6 +365,8 @@ In the .NET Client, these options can be modified by the options delegate provid
364365
var connection = new HubConnectionBuilder()
365366
.WithUrl("https://example.com/chathub", options => {
366367
options.Headers["Foo"] = "Bar";
368+
options.SkipNegotiation = true;
369+
options.Transports = HttpTransportType.WebSockets;
367370
options.Cookies.Add(new Cookie(/* ... */);
368371
options.ClientCertificates.Add(/* ... */);
369372
})
@@ -375,8 +378,9 @@ In the JavaScript Client, these options can be provided in a JavaScript object p
375378
```javascript
376379
let connection = new signalR.HubConnectionBuilder()
377380
.withUrl("/chathub", {
378-
skipNegotiation: true,
379-
transport: signalR.HttpTransportType.WebSockets
381+
// "Foo: Bar" will not be sent with WebSockets or Server-Sent Events requests
382+
headers: { "Foo": "Bar" },
383+
transport: signalR.HttpTransportType.LongPolling
380384
})
381385
.build();
382386
```
@@ -731,6 +735,7 @@ Additional options can be configured in the `WithUrl` (`withUrl` in JavaScript)
731735
| JavaScript Option | Default Value | Description |
732736
| ----------------- | ------------- | ----------- |
733737
| `accessTokenFactory` | `null` | A function returning a string that is provided as a Bearer authentication token in HTTP requests. |
738+
| `transport` | `null` | An <xref:Microsoft.AspNetCore.Http.Connections.HttpTransportType> value specifying the transport to use for the connection. |
734739
| `logMessageContent` | `null` | Set to `true` to log the bytes/chars of messages sent and received by the client. |
735740
| `skipNegotiation` | `false` | Set this to `true` to skip the negotiation step. **Only supported when the WebSockets transport is the only enabled transport**. This setting can't be enabled when using the Azure SignalR Service. |
736741

@@ -1116,6 +1121,7 @@ Additional options can be configured in the `WithUrl` (`withUrl` in JavaScript)
11161121
| JavaScript Option | Default Value | Description |
11171122
| ----------------- | ------------- | ----------- |
11181123
| `accessTokenFactory` | `null` | A function returning a string that is provided as a Bearer authentication token in HTTP requests. |
1124+
| `transport` | `null` | An <xref:Microsoft.AspNetCore.Http.Connections.HttpTransportType> value specifying the transport to use for the connection. |
11191125
| `logMessageContent` | `null` | Set to `true` to log the bytes/chars of messages sent and received by the client. |
11201126
| `skipNegotiation` | `false` | Set this to `true` to skip the negotiation step. **Only supported when the WebSockets transport is the only enabled transport**. This setting can't be enabled when using the Azure SignalR Service. |
11211127

@@ -1465,6 +1471,7 @@ Additional options can be configured in the `WithUrl` (`withUrl` in JavaScript)
14651471
| JavaScript Option | Default Value | Description |
14661472
| ----------------- | ------------- | ----------- |
14671473
| `accessTokenFactory` | `null` | A function returning a string that is provided as a Bearer authentication token in HTTP requests. |
1474+
| `transport` | `null` | An <xref:Microsoft.AspNetCore.Http.Connections.HttpTransportType> value specifying the transport to use for the connection. |
14681475
| `logMessageContent` | `null` | Set to `true` to log the bytes/chars of messages sent and received by the client. |
14691476
| `skipNegotiation` | `false` | Set this to `true` to skip the negotiation step. **Only supported when the WebSockets transport is the only enabled transport**. This setting can't be enabled when using the Azure SignalR Service. |
14701477

@@ -1808,6 +1815,7 @@ Additional options can be configured in the `WithUrl` (`withUrl` in JavaScript)
18081815
| JavaScript Option | Default Value | Description |
18091816
| ----------------- | ------------- | ----------- |
18101817
| `accessTokenFactory` | `null` | A function returning a string that is provided as a Bearer authentication token in HTTP requests. |
1818+
| `transport` | `null` | An <xref:Microsoft.AspNetCore.Http.Connections.HttpTransportType> value specifying the transport to use for the connection. |
18111819
| `logMessageContent` | `null` | Set to `true` to log the bytes/chars of messages sent and received by the client. |
18121820
| `skipNegotiation` | `false` | Set this to `true` to skip the negotiation step. **Only supported when the WebSockets transport is the only enabled transport**. This setting can't be enabled when using the Azure SignalR Service. |
18131821

0 commit comments

Comments
 (0)