unosquare / embedio

A tiny, cross-platform, module based web server for .NET
http://unosquare.github.io/embedio
Other
1.45k stars 175 forks source link

Cookies issue #583

Open anatoly-abramov opened 1 year ago

anatoly-abramov commented 1 year ago

Hello, i found issue with cookies. When using WebSocketModule, response returns Set-Cookie header with all request cookies joined into one cookie. NameValueCollection in WebSocketHandshakeResponse joins all the values under the same key via comma separator, which causes confusing result in response headers, like image

This problem occurs only when Embedio built with WebSocketModule. Perhaps, the problem is in line 26 in unexpected NameValueCollection.Add method behavior. image image image

And WebSocketHandshakeResponse.cs, line 45 returns that merged cookie string. image

Steps to reproduce the behavior:

  1. Run Embedio with WebSocketModule

A. (UWP) Set cookies for Microsoft.Web.WebView2.Core.CoreWebView2 via CoreWebView2 .CoreWebView2.CookieManager.AddOrUpdateCookie(cookie); B. (Android) Set cookies for Android.Webkit.WebView via CookieManager.Instance.SetAcceptCookie(true); CookieManager.Instance.SetAcceptThirdPartyCookies(webView, true); CookieManager.Instance.SetCookie(cookie);

  1. Try to connect to the webocket
  2. Check response cookies via DevTools

Expected behavior should be:

Set-Cookie: en=culture Set-Cookie: token=...

Desktop

Smartphone: