mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-04-22 06:22:50 +08:00
parent
37fb32b7f5
commit
89f0cc786a
@ -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);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user