void AbsorbResponseString(string ResponseString) { this.headers = new ResponseHeaderParameters(this); HTTPMessage Msg = new HTTPMessage(ResponseString); string[] FirstHeaderParts = Msg.FirstHeader.Split(new char[] { ' ' }, 3); if (FirstHeaderParts.Length < 3) { throw new Exception("Invalid Response Header"); } this.httpVersion = FirstHeaderParts[0]; if (!(this.HTTPVersion.Equals("HTTP/1.1") || this.HTTPVersion.Equals("HTTP/1.0"))) { throw new Exception("Invalid Response Header"); } try { this.code = Convert.ToInt32(FirstHeaderParts[1]); } catch { throw new Exception("Invalid Response Header"); } this.status = FirstHeaderParts[2]; this.headers = new ResponseHeaderParameters(this, Msg.Headers); this.SetBody(Msg.BodyString); }
internal Response(Fiddler.Session Sess) { this.headers = new ResponseHeaderParameters(this); try { this.ID = Int32.Parse(Sess.oFlags["IronFlag-ID"]); } catch { this.ID = 0; } if (Sess.oFlags.ContainsKey("IronFlag-TTL")) { this.TTL = Int32.Parse(Sess.oFlags["IronFlag-TTL"]); } if (Sess.oFlags.ContainsKey("IronFlag-SslError")) { this.isSSlValid = false; } if (Sess.oFlags.ContainsKey("IronFlag-BuiltBy")) { this.Source = Sess.oFlags["IronFlag-BuiltBy"]; } this.httpVersion = Sess.oResponse.headers.HTTPVersion; this.code = Sess.oResponse.headers.HTTPResponseCode; try { if (Sess.oResponse.headers.HTTPResponseStatus.IndexOf(' ') > -1) { this.status = Sess.oResponse.headers.HTTPResponseStatus.Substring(Sess.oResponse.headers.HTTPResponseStatus.IndexOf(' ')).Trim(); } else { this.status = ""; } } catch (Exception Exp) { Tools.Trace("Response.cs", "Invalid Fiddler Session Response Status - " + Sess.oResponse.headers.HTTPResponseStatus); throw (Exp); } Fiddler.HTTPResponseHeaders ResHeaders = new Fiddler.HTTPResponseHeaders(); foreach (Fiddler.HTTPHeaderItem HHI in Sess.oResponse.headers) { this.Headers.Add(HHI.Name, HHI.Value); } if (Sess.responseBodyBytes.Length > 0) { this.SetBody(Sess.responseBodyBytes); } }
internal Response(Fiddler.Session Sess) { this.headers = new ResponseHeaderParameters(this); try { this.ID = Int32.Parse(Sess.oFlags["IronFlag-ID"]); } catch { this.ID = 0; } if (Sess.oFlags.ContainsKey("IronFlag-TTL")) { this.TTL = Int32.Parse(Sess.oFlags["IronFlag-TTL"]); } if (Sess.oFlags.ContainsKey("IronFlag-SslError")) { this.isSSlValid = false; } this.httpVersion = Sess.oResponse.headers.HTTPVersion; this.code = Sess.oResponse.headers.HTTPResponseCode; try { if (Sess.oResponse.headers.HTTPResponseStatus.IndexOf(' ') > -1) this.status = Sess.oResponse.headers.HTTPResponseStatus.Substring(Sess.oResponse.headers.HTTPResponseStatus.IndexOf(' ')).Trim(); else this.status = ""; } catch(Exception Exp) { Tools.Trace("Response.cs", "Invalid Fiddler Session Response Status - " + Sess.oResponse.headers.HTTPResponseStatus); throw (Exp); } Fiddler.HTTPResponseHeaders ResHeaders = new Fiddler.HTTPResponseHeaders(); foreach (Fiddler.HTTPHeaderItem HHI in Sess.oResponse.headers) { this.Headers.Add(HHI.Name, HHI.Value); } if (Sess.responseBodyBytes.Length > 0) { this.SetBody(Sess.responseBodyBytes); } }
internal Response() { this.headers = new ResponseHeaderParameters(this); }
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); }