Ejemplo n.º 1
0
        public bool Equals(FiddlerHttpFilter yourFiddlerHttpFilter)
        {
            if (!UriMatch.Equals(yourFiddlerHttpFilter.UriMatch))
            {
                return(false);
            }

            if ((HeadMatch == null || yourFiddlerHttpFilter.HeadMatch == null) && (!(HeadMatch == null && yourFiddlerHttpFilter.HeadMatch == null)))
            {
                return(false);
            }
            if (HeadMatch != null && yourFiddlerHttpFilter.HeadMatch != null)
            {
                if (!HeadMatch.Equals(yourFiddlerHttpFilter.HeadMatch))
                {
                    return(false);
                }
            }

            if ((BodyMatch == null || yourFiddlerHttpFilter.BodyMatch == null) && (!(BodyMatch == null && yourFiddlerHttpFilter.BodyMatch == null)))
            {
                return(false);
            }
            if (BodyMatch != null && yourFiddlerHttpFilter.BodyMatch != null)
            {
                if (!BodyMatch.Equals(yourFiddlerHttpFilter.BodyMatch))
                {
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
        public bool Match(Session oSession, bool isRequest)
        {
            bool isMatch = true;

            if (UriMatch != null)
            {
                if (!UriMatch.Match(oSession.fullUrl))
                {
                    return(false);
                }
            }
            if (HeadMatch != null)
            {
                if (!HeadMatch.Match(isRequest ? (HTTPHeaders)oSession.RequestHeaders : (HTTPHeaders)oSession.ResponseHeaders))
                {
                    return(false);
                }
            }
            if (BodyMatch != null)
            {
                if (!BodyMatch.Match(isRequest?oSession.GetRequestBodyAsString():oSession.GetResponseBodyAsString()))
                {
                    return(false);
                }
            }
            return(isMatch);
        }
Ejemplo n.º 3
0
        public new string ToString()
        {
            StringBuilder tempSb = new StringBuilder(string.Format("Uri:\r\n{0}\r\n", UriMatch.ToString()));

            if (HeadMatch != null)
            {
                tempSb.Append(string.Format("Heads:\r\n{0}", HeadMatch.ToString()));
            }
            if (BodyMatch != null)
            {
                tempSb.AppendLine(string.Format("Body:\r\n{0}", BodyMatch.ToString()));
            }
            return(tempSb.ToString());
        }
Ejemplo n.º 4
0
        public bool Match(Session oSession, bool isRequest, WebSocketMessage webSocketMessage = null)
        {
            bool isWebSocket = webSocketMessage != null;// oSession.BitFlags.HasFlag(SessionFlags.IsWebSocketTunnel);
            bool isMatch     = true;

            if (isWebSocket)
            {
                if (!oSession.BitFlags.HasFlag(SessionFlags.IsWebSocketTunnel))
                {
                    return(false);
                }
                if (!((isRequest && webSocketMessage.IsOutbound) || (!isRequest && !webSocketMessage.IsOutbound)))
                {
                    return(false);
                }
                if (!UriMatch.Match(oSession.fullUrl))
                {
                    return(false);
                }
                if (BodyMatch != null)
                {
                    if (webSocketMessage.FrameType == WebSocketFrameTypes.Binary && BodyMatch.IsHexMatch)
                    {
                        if (!BodyMatch.Match(webSocketMessage.PayloadAsBytes()))
                        {
                            return(false);
                        }
                    }
                    else if (webSocketMessage.FrameType == WebSocketFrameTypes.Text && !BodyMatch.IsHexMatch)
                    {
                        if (!BodyMatch.Match(webSocketMessage.PayloadAsString()))
                        {
                            return(false);
                        }
                    }
                    else if (webSocketMessage.FrameType == WebSocketFrameTypes.Continuation)
                    {
                        //延续帧
                        return(false);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            else
            {
                if (UriMatch != null)
                {
                    if (!UriMatch.Match(oSession.fullUrl))
                    {
                        return(false);
                    }
                }
                if (HeadMatch != null)
                {
                    if (!HeadMatch.Match(true ? (HTTPHeaders)oSession.RequestHeaders : (HTTPHeaders)oSession.ResponseHeaders))
                    {
                        return(false);
                    }
                }
                if (BodyMatch != null)
                {
                    if (BodyMatch.IsHexMatch)
                    {
                        if (!BodyMatch.Match(true ? oSession.requestBodyBytes : oSession.responseBodyBytes))
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        if (!BodyMatch.Match(true ? oSession.GetRequestBodyAsString() : oSession.GetResponseBodyAsString()))
                        {
                            return(false);
                        }
                    }
                }
            }
            return(isMatch);
        }