mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-09-13 12:15:35 +08:00
@@ -29,6 +29,17 @@ namespace Ocelot.WebSockets.Middleware
|
|||||||
var wsToUpstreamClient = await context.WebSockets.AcceptWebSocketAsync();
|
var wsToUpstreamClient = await context.WebSockets.AcceptWebSocketAsync();
|
||||||
|
|
||||||
var wsToDownstreamService = new ClientWebSocket();
|
var wsToDownstreamService = new ClientWebSocket();
|
||||||
|
|
||||||
|
foreach (var requestHeader in context.Request.Headers)
|
||||||
|
{
|
||||||
|
// Do not copy the Sec-Websocket headers because it is specified by the own connection it will fail when you copy this one.
|
||||||
|
if (requestHeader.Key.StartsWith("Sec-WebSocket"))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
wsToDownstreamService.Options.SetRequestHeader(requestHeader.Key, requestHeader.Value);
|
||||||
|
}
|
||||||
|
|
||||||
var uri = new Uri(serverEndpoint);
|
var uri = new Uri(serverEndpoint);
|
||||||
await wsToDownstreamService.ConnectAsync(uri, CancellationToken.None);
|
await wsToDownstreamService.ConnectAsync(uri, CancellationToken.None);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user