private void ParseCookies(string values) { values.ThrowIfNullOrEmpty(nameof(values)); string[] cookies = values.Split(HttpCookieStringSeparator); foreach (var cookie in cookies) { string[] parts = cookie.Split(HttpParameterNameValueSeparator, 2); Cookies.AddCookie(new HttpCookie(parts[0], parts[1])); } }
private void ParseCookies(string[] requestHeaders) { string cookieHeader = requestHeaders.SingleOrDefault(h => h.StartsWith(Constants.CookieRequestHeaderKey)); if (cookieHeader != null) { string[] cookies = cookieHeader .Replace($"{Constants.CookieRequestHeaderKey}: ", string.Empty) .Split("; ", StringSplitOptions.RemoveEmptyEntries); foreach (var cookie in cookies) { string[] cookieAttributes = cookie.Split('=', 2); string cookieName = cookieAttributes[0]; string cookieValue = cookieAttributes[1]; var httpCookie = new HttpCookie(cookieName, cookieValue); Cookies.AddCookie(httpCookie); } } }