internal CookieCollection CookieCutter(Uri uri, string headerName, string setCookieHeader, bool isThrow) { CookieCollection cookies = new CookieCollection(); CookieVariant unknown = CookieVariant.Unknown; if (headerName == null) { unknown = CookieVariant.Rfc2109; } else { for (int i = 0; i < HeaderInfo.Length; i++) { if (string.Compare(headerName, HeaderInfo[i].Name, StringComparison.OrdinalIgnoreCase) == 0) { unknown = HeaderInfo[i].Variant; } } } bool isLocalDomain = this.IsLocalDomain(uri.Host); try { Cookie cookie; CookieParser parser = new CookieParser(setCookieHeader); Label_0060: cookie = parser.Get(); if (cookie != null) { if (ValidationHelper.IsBlankString(cookie.Name)) { if (isThrow) { throw new CookieException(SR.GetString("net_cookie_format")); } } else if (cookie.VerifySetDefaults(unknown, uri, isLocalDomain, this.m_fqdnMyDomain, true, isThrow)) { cookies.InternalAdd(cookie, true); } goto Label_0060; } } catch (Exception exception) { if (((exception is ThreadAbortException) || (exception is StackOverflowException)) || (exception is OutOfMemoryException)) { throw; } if (isThrow) { throw new CookieException(SR.GetString("net_cookie_parse_header", new object[] { uri.AbsoluteUri }), exception); } } foreach (Cookie cookie2 in cookies) { this.Add(cookie2, isThrow); } return(cookies); }
internal CookieCollection CookieCutter(Uri uri, string headerName, string setCookieHeader, bool isThrow) { CookieCollection cookies = new CookieCollection(); CookieVariant unknown = CookieVariant.Unknown; if (headerName == null) { unknown = CookieVariant.Rfc2109; } else { for (int i = 0; i < HeaderInfo.Length; i++) { if (string.Compare(headerName, HeaderInfo[i].Name, StringComparison.OrdinalIgnoreCase) == 0) { unknown = HeaderInfo[i].Variant; } } } bool isLocalDomain = this.IsLocalDomain(uri.Host); try { Cookie cookie; CookieParser parser = new CookieParser(setCookieHeader); Label_0060: cookie = parser.Get(); if (cookie != null) { if (ValidationHelper.IsBlankString(cookie.Name)) { if (isThrow) { throw new CookieException(SR.GetString("net_cookie_format")); } } else if (cookie.VerifySetDefaults(unknown, uri, isLocalDomain, this.m_fqdnMyDomain, true, isThrow)) { cookies.InternalAdd(cookie, true); } goto Label_0060; } } catch (Exception exception) { if (((exception is ThreadAbortException) || (exception is StackOverflowException)) || (exception is OutOfMemoryException)) { throw; } if (isThrow) { throw new CookieException(SR.GetString("net_cookie_parse_header", new object[] { uri.AbsoluteUri }), exception); } } foreach (Cookie cookie2 in cookies) { this.Add(cookie2, isThrow); } return cookies; }
internal CookieCollection CookieCutter(Uri uri, string headerName, string setCookieHeader, bool isThrow) { if (NetEventSource.IsEnabled) { if (NetEventSource.IsEnabled) { NetEventSource.Info(this, $"uri:{uri} headerName:{headerName} setCookieHeader:{setCookieHeader} isThrow:{isThrow}"); } } CookieCollection cookies = new CookieCollection(); CookieVariant variant = CookieVariant.Unknown; if (headerName == null) { variant = CookieVariant.Default; } else { for (int i = 0; i < s_headerInfo.Length; ++i) { if ((String.Compare(headerName, s_headerInfo[i].Name, StringComparison.OrdinalIgnoreCase) == 0)) { variant = s_headerInfo[i].Variant; } } } bool isLocalDomain = IsLocalDomain(uri.Host); try { CookieParser parser = new CookieParser(setCookieHeader); do { Cookie cookie = parser.Get(); if (NetEventSource.IsEnabled) { NetEventSource.Info(this, $"CookieParser returned cookie:{cookie}"); } if (cookie == null) { break; } // Parser marks invalid cookies this way if (String.IsNullOrEmpty(cookie.Name)) { if (isThrow) { throw new CookieException(SR.net_cookie_format); } // Otherwise, ignore (reject) cookie continue; } // This will set the default values from the response URI // AND will check for cookie validity if (!cookie.VerifySetDefaults(variant, uri, isLocalDomain, m_fqdnMyDomain, true, isThrow)) { continue; } // If many same cookies arrive we collapse them into just one, hence setting // parameter isStrict = true below cookies.InternalAdd(cookie, true); } while (true); } catch (OutOfMemoryException) { throw; } catch (Exception e) { if (isThrow) { throw new CookieException(SR.Format(SR.net_cookie_parse_header, uri.AbsoluteUri), e); } } foreach (Cookie c in cookies) { Add(c, isThrow); } return(cookies); }
internal CookieCollection CookieCutter(Uri uri, string headerName, string setCookieHeader, bool isThrow) { GlobalLog.Print("CookieContainer#" + Logging.HashString(this) + "::CookieCutter() uri:" + uri + " headerName:" + headerName + " setCookieHeader:" + setCookieHeader + " isThrow:" + isThrow); CookieCollection cookies = new CookieCollection(); CookieVariant variant = CookieVariant.Unknown; if (headerName == null) { variant = CookieVariant.Default; } else { for (int i = 0; i < s_headerInfo.Length; ++i) { if ((String.Compare(headerName, s_headerInfo[i].Name, StringComparison.OrdinalIgnoreCase) == 0)) { variant = s_headerInfo[i].Variant; } } } bool isLocalDomain = IsLocalDomain(uri.Host); try { CookieParser parser = new CookieParser(setCookieHeader); do { Cookie cookie = parser.Get(); GlobalLog.Print("CookieContainer#" + Logging.HashString(this) + "::CookieCutter() CookieParser returned cookie:" + Logging.ObjectToString(cookie)); if (cookie == null) { break; } // Parser marks invalid cookies this way if (String.IsNullOrEmpty(cookie.Name)) { if (isThrow) { throw new CookieException(SR.net_cookie_format); } // Otherwise, ignore (reject) cookie continue; } // This will set the default values from the response URI // AND will check for cookie validity if (!cookie.VerifySetDefaults(variant, uri, isLocalDomain, _fqdnMyDomain, true, isThrow)) { continue; } // If many same cookies arrive we collapse them into just one, hence setting // parameter isStrict = true below cookies.InternalAdd(cookie, true); } while (true); } catch (OutOfMemoryException) { throw; } catch (Exception e) { if (isThrow) { throw new CookieException(SR.Format(SR.net_cookie_parse_header, uri.AbsoluteUri), e); } } foreach (Cookie c in cookies) { Add(c, isThrow); } return cookies; }
internal CookieCollection CookieCutter(Uri uri, string HeaderName, string setCookieHeader, bool isThrow) { CookieCollection cookies = new CookieCollection(); CookieVariant variant = CookieVariant.Unknown; if (HeaderName == null) { variant = CookieVariant.Default; } else { for (int i = 0; i < HeaderInfo.Length; ++i) { if ((String.Compare(HeaderName, HeaderInfo[i].Name, true, CultureInfo.InvariantCulture) == 0)) { variant = HeaderInfo[i].Variant; } } } bool isLocalDomain = IsLocal(uri.Host); try { CookieParser parser = new CookieParser(setCookieHeader); do { Cookie cookie = parser.Get(); if (cookie == null) { //Console.WriteLine("CookieCutter: eof cookies"); break; } //Parser marks invalid cookies this way if (cookie.Name == string.Empty) { if (isThrow) { throw new CookieException(SR.GetString(SR.net_cookie_format)); } //Otherwise, ignore (reject) cookie continue; } // this will set the default values from the response URI // AND will check for cookie validity if (!cookie.VerifySetDefaults(variant, uri, isLocalDomain, m_fqdnMyDomain, true, isThrow)) { continue; } // If many same cookies arrive we collapse them into just one, hence setting // parameter isStrict = true below cookies.InternalAdd(cookie, true); } while (true); } catch (Exception e) { if (isThrow) { throw new CookieException(SR.GetString(SR.net_cookie_parse_header, uri.AbsoluteUri), e); } } foreach (Cookie c in cookies) { Add(c, isThrow); } return(cookies); }
internal CookieCollection CookieCutter(Uri uri, string headerName, string setCookieHeader, bool isThrow) { CookieCollection cookieCollection = new CookieCollection(); CookieVariant variant = CookieVariant.Unknown; if (headerName == null) { variant = CookieVariant.Rfc2109; } else { for (int index = 0; index < CookieContainer.HeaderInfo.Length; ++index) { if (string.Compare(headerName, CookieContainer.HeaderInfo[index].Name, StringComparison.OrdinalIgnoreCase) == 0) variant = CookieContainer.HeaderInfo[index].Variant; } } bool isLocalDomain = this.IsLocalDomain(uri.Host); try { CookieParser cookieParser = new CookieParser(setCookieHeader); while (true) { Cookie cookie; do { cookie = cookieParser.Get(); if (cookie != null) { if (ValidationHelper.IsBlankString(cookie.Name)) { if (isThrow) throw new CookieException(SR.GetString("net_cookie_format")); } } else goto label_19; } while (!cookie.VerifySetDefaults(variant, uri, isLocalDomain, this.m_fqdnMyDomain, true, isThrow)); cookieCollection.InternalAdd(cookie, true); } } catch (Exception ex) { if (ex is ThreadAbortException || ex is StackOverflowException || ex is OutOfMemoryException) throw; else if (isThrow) throw new CookieException(SR.GetString("net_cookie_parse_header", new object[1] { (object) uri.AbsoluteUri }), ex); } label_19: foreach (Cookie cookie in cookieCollection) this.Add(cookie, isThrow); return cookieCollection; }
internal CookieCollection CookieCutter(Uri uri, string HeaderName, string setCookieHeader, bool isThrow) { CookieCollection cookies = new CookieCollection(); CookieVariant variant = CookieVariant.Unknown; if (HeaderName == null) { variant = CookieVariant.Default; } else for (int i = 0; i < HeaderInfo.Length; ++i) { if ((String.Compare(HeaderName, HeaderInfo[i].Name, true, CultureInfo.InvariantCulture) == 0)) { variant = HeaderInfo[i].Variant; } } bool isLocalDomain = IsLocal(uri.Host); try { CookieParser parser = new CookieParser(setCookieHeader); do { Cookie cookie = parser.Get(); if (cookie == null) { //Console.WriteLine("CookieCutter: eof cookies"); break; } //Parser marks invalid cookies this way if (cookie.Name == string.Empty) { if(isThrow) { throw new CookieException(SR.GetString(SR.net_cookie_format)); } //Otherwise, ignore (reject) cookie continue; } // this will set the default values from the response URI // AND will check for cookie validity if(!cookie.VerifySetDefaults(variant, uri, isLocalDomain, m_fqdnMyDomain, true, isThrow)) { continue; } // If many same cookies arrive we collapse them into just one, hence setting // parameter isStrict = true below cookies.InternalAdd(cookie, true); } while (true); } catch (Exception e) { if(isThrow) { throw new CookieException(SR.GetString(SR.net_cookie_parse_header, uri.AbsoluteUri), e); } } foreach (Cookie c in cookies) { Add(c, isThrow); } return cookies; }
internal CookieCollection CookieCutter(Uri uri, string headerName, string setCookieHeader, bool isThrow) { GlobalLog.Print("CookieContainer#" + ValidationHelper.HashString(this) + "::CookieCutter() uri:" + uri + " headerName:" + headerName + " setCookieHeader:" + setCookieHeader + " isThrow:" + isThrow); CookieCollection cookies = new CookieCollection(); CookieVariant variant = CookieVariant.Unknown; if (headerName == null) { variant = CookieVariant.Default; } else { for (int i = 0; i < HeaderInfo.Length; ++i) { if ((String.Compare(headerName, HeaderInfo[i].Name, StringComparison.OrdinalIgnoreCase) == 0)) { variant = HeaderInfo[i].Variant; } } } bool isLocalDomain = IsLocalDomain(uri.Host); try { CookieParser parser = new CookieParser(setCookieHeader); do { Cookie cookie = parser.Get(); GlobalLog.Print("CookieContainer#" + ValidationHelper.HashString(this) + "::CookieCutter() CookieParser returned cookie:" + ValidationHelper.ToString(cookie)); if (cookie == null) { break; } //Parser marks invalid cookies this way if (ValidationHelper.IsBlankString(cookie.Name)) { if (isThrow) { throw new CookieException(SR.GetString(SR.net_cookie_format)); } //Otherwise, ignore (reject) cookie continue; } // this will set the default values from the response URI // AND will check for cookie validity if (!cookie.VerifySetDefaults(variant, uri, isLocalDomain, m_fqdnMyDomain, true, isThrow)) { continue; } // If many same cookies arrive we collapse them into just one, hence setting // parameter isStrict = true below cookies.InternalAdd(cookie, true); } while (true); } catch (Exception e) { if (e is ThreadAbortException || e is StackOverflowException || e is OutOfMemoryException) { throw; } if (isThrow) { throw new CookieException(SR.GetString(SR.net_cookie_parse_header, uri.AbsoluteUri), e); } } foreach (Cookie c in cookies) { Add(c, isThrow); } return(cookies); }
internal CookieCollection CookieCutter(Uri uri, string headerName, string setCookieHeader, bool isThrow) { CookieCollection cookieCollection = new CookieCollection(); CookieVariant variant = CookieVariant.Unknown; if (headerName == null) { variant = CookieVariant.Rfc2109; } else { for (int index = 0; index < CookieContainer.HeaderInfo.Length; ++index) { if (string.Compare(headerName, CookieContainer.HeaderInfo[index].Name, StringComparison.OrdinalIgnoreCase) == 0) { variant = CookieContainer.HeaderInfo[index].Variant; } } } bool isLocalDomain = this.IsLocalDomain(uri.Host); try { CookieParser cookieParser = new CookieParser(setCookieHeader); while (true) { Cookie cookie; do { cookie = cookieParser.Get(); if (cookie != null) { if (ValidationHelper.IsBlankString(cookie.Name)) { if (isThrow) { throw new CookieException(SR.GetString("net_cookie_format")); } } } else { goto label_19; } }while (!cookie.VerifySetDefaults(variant, uri, isLocalDomain, this.m_fqdnMyDomain, true, isThrow)); cookieCollection.InternalAdd(cookie, true); } } catch (Exception ex) { if (ex is ThreadAbortException || ex is StackOverflowException || ex is OutOfMemoryException) { throw; } else if (isThrow) { throw new CookieException(SR.GetString("net_cookie_parse_header", new object[1] { (object)uri.AbsoluteUri }), ex); } } label_19: foreach (Cookie cookie in cookieCollection) { this.Add(cookie, isThrow); } return(cookieCollection); }