internal void CreateSetCookieListFromParameters(HeaderParameters Headers) { this.setCookies = new List <SetCookie>(); if (Headers.Has("Set-Cookie")) { foreach (string SCString in Headers.GetAll("Set-Cookie")) { SetCookie SC = new SetCookie(SCString); this.SetCookies.Add(SC); } } }
public static List<string> GetHeaderVariations(string Trigg, HeaderParameters Headers, string HeaderString) { List<string> FinalMatches = new List<string>(); if (Trigg.Contains(":")) { string[] Parts = Trigg.Split(new char[] { ':' }, 2); string TrimmedName = Parts[0].Trim(); string TrimmedValue = Parts[1].Trim(); if (TrimmedName.Length > 0) { List<string[]> Matches = new List<string[]>(); foreach (string Name in Headers.GetNames()) { if (Name.Trim().Equals(TrimmedName, StringComparison.OrdinalIgnoreCase)) { foreach (string Value in Headers.GetAll(Name)) { if (Value.Trim().Equals(TrimmedValue)) { Matches.Add(new string[] { Name, Value }); } } } } List<string> Lines = Tools.SplitLines(HeaderString); foreach (string Line in Lines) { foreach (string[] Match in Matches) { string EncodedName = ""; string EncodedValue = ""; if (Line.StartsWith(Match[0])) { EncodedName = Match[0]; } else if (Line.StartsWith(RequestHeaderParameters.Encode(Match[0]))) { EncodedName = RequestHeaderParameters.Encode(Match[0]); } else if (Line.StartsWith(ResponseHeaderParameters.Encode(Match[0]))) { EncodedName = ResponseHeaderParameters.Encode(Match[0]); } if (Line.EndsWith(Match[1])) { EncodedValue = Match[1]; } else if (Line.EndsWith(RequestHeaderParameters.Encode(Match[1]))) { EncodedValue = RequestHeaderParameters.Encode(Match[1]); } else if (Line.EndsWith(ResponseHeaderParameters.Encode(Match[1]))) { EncodedValue = ResponseHeaderParameters.Encode(Match[1]); } if (EncodedValue.Length > 0)//If EncodedValue is empty then .Replace(EncodedValue, "") throws an exception, as empty value cannot be replaced { if (Line.Substring(EncodedName.Length).Replace(EncodedValue, "").Trim().Equals(":")) { FinalMatches.Add(Line); } } else { if (Line.Substring(EncodedName.Length).Trim().Equals(":")) { FinalMatches.Add(Line); } } } } } } return FinalMatches; }
internal void CreateSetCookieListFromParameters(HeaderParameters Headers) { this.setCookies = new List<SetCookie>(); if (Headers.Has("Set-Cookie")) { foreach (string SCString in Headers.GetAll("Set-Cookie")) { SetCookie SC = new SetCookie(SCString); this.SetCookies.Add(SC); } } }
public static List <string> GetHeaderVariations(string Trigg, HeaderParameters Headers, string HeaderString) { List <string> FinalMatches = new List <string>(); if (Trigg.Contains(":")) { string[] Parts = Trigg.Split(new char[] { ':' }, 2); string TrimmedName = Parts[0].Trim(); string TrimmedValue = Parts[1].Trim(); if (TrimmedName.Length > 0) { List <string[]> Matches = new List <string[]>(); foreach (string Name in Headers.GetNames()) { if (Name.Trim().Equals(TrimmedName, StringComparison.OrdinalIgnoreCase)) { foreach (string Value in Headers.GetAll(Name)) { if (Value.Trim().Equals(TrimmedValue)) { Matches.Add(new string[] { Name, Value }); } } } } List <string> Lines = Tools.SplitLines(HeaderString); foreach (string Line in Lines) { foreach (string[] Match in Matches) { string EncodedName = ""; string EncodedValue = ""; if (Line.StartsWith(Match[0])) { EncodedName = Match[0]; } else if (Line.StartsWith(RequestHeaderParameters.Encode(Match[0]))) { EncodedName = RequestHeaderParameters.Encode(Match[0]); } else if (Line.StartsWith(ResponseHeaderParameters.Encode(Match[0]))) { EncodedName = ResponseHeaderParameters.Encode(Match[0]); } if (Line.EndsWith(Match[1])) { EncodedValue = Match[1]; } else if (Line.EndsWith(RequestHeaderParameters.Encode(Match[1]))) { EncodedValue = RequestHeaderParameters.Encode(Match[1]); } else if (Line.EndsWith(ResponseHeaderParameters.Encode(Match[1]))) { EncodedValue = ResponseHeaderParameters.Encode(Match[1]); } if (EncodedValue.Length > 0)//If EncodedValue is empty then .Replace(EncodedValue, "") throws an exception, as empty value cannot be replaced { if (Line.Substring(EncodedName.Length).Replace(EncodedValue, "").Trim().Equals(":")) { FinalMatches.Add(Line); } } else { if (Line.Substring(EncodedName.Length).Trim().Equals(":")) { FinalMatches.Add(Line); } } } } } } return(FinalMatches); }