private void ParseCookies(WebSocketHandshake handshake) { if (handshake == null) { throw new ArgumentNullException(nameof(handshake)); } var host = handshake.Request.Headers[RequestHeader.Host]; foreach (var cookieValue in handshake.Request.Headers.GetValues(RequestHeader.Cookie)) { try { foreach (var cookie in CookieParser.Parse(cookieValue)) { cookie.Domain = host; cookie.Path = string.Empty; handshake.Request.Cookies.Add(cookie); } } catch (Exception ex) { throw new WebSocketException("Cannot parse cookie string: '" + (cookieValue ?? "") + "' because: " + ex.Message); } } }
private void ParseCookies(WebSocketHandshake handshake) { if (handshake.Request.Headers.HeaderNames.Contains(WebSocketHeaders.Cookie)) { var cookieString = handshake.Request.Headers[WebSocketHeaders.Cookie]; try { foreach (var cookie in CookieParser.Parse(cookieString)) { cookie.Domain = handshake.Request.Headers.Host; cookie.Path = String.Empty; handshake.Request.Cookies.Add(cookie); } } catch (Exception ex) { throw new WebSocketException("Cannot parse cookie string: '" + (cookieString ?? "") + "' because: " + ex.Message); } } }