Beispiel #1
0
 private bool isRequestComplete()
 {
     if (this.m_headers == null)
     {
         if (!this.HeadersAvailable())
         {
             return(false);
         }
         if (!this.ParseRequestForHeaders())
         {
             string str;
             if (this.m_requestData != null)
             {
                 str = Utilities.ByteArrayToHexView(this.m_requestData.GetBuffer(), 0x18, (int)Math.Min(this.m_requestData.Length, 0x800L));
             }
             else
             {
                 str = "{Kavprot Proxy:no data}";
             }
             if (this.m_headers == null)
             {
                 this.m_headers             = new HTTPRequestHeaders();
                 this.m_headers.HTTPMethod  = "BAD";
                 this.m_headers["Host"]     = "BAD-REQUEST";
                 this.m_headers.RequestPath = "/BAD_REQUEST";
             }
             this.FailSession(400, "Kavprot Proxy - Bad Request", "[Kavprot Proxy] Request Header parsing failed. Request was:\n" + str);
             return(true);
         }
         this.m_session.Timers.KProxyGotRequestHeaders = DateTime.Now;
         this.m_session._AssignID();
         KProxyApplication.DoRequestHeadersAvailable(this.m_session);
     }
     if (this.m_headers.ExistsAndEquals("Transfer-encoding", "chunked"))
     {
         long num;
         long num2;
         return(Utilities.IsChunkedBodyComplete(this.m_session, this.m_requestData, (long)this.iEntityBodyOffset, out num2, out num));
     }
     if (this.m_headers.Exists("Content-Length"))
     {
         long result = 0L;
         try
         {
             if (!long.TryParse(this.m_headers["Content-Length"], NumberStyles.Integer, NumberFormatInfo.InvariantInfo, out result) || (result < 0L))
             {
                 KProxyApplication.HandleHTTPError(this.m_session, SessionFlags.ProtocolViolationInRequest, true, true, "Request content length was invalid.\nContent-Length: " + this.m_headers["Content-Length"]);
                 this.FailSession(400, "Kavprot Proxy - Bad Request", "[Kavprot Proxy] Request Content-Length header parsing failed.\nContent-Length: " + this.m_headers["Content-Length"]);
                 return(true);
             }
             return(this.m_requestData.Length >= (this.iEntityBodyOffset + result));
         }
         catch
         {
             this.FailSession(400, "Kavprot Proxy - Bad Request", "[Kavprot Proxy] Unknown error: Check content length header?");
             return(false);
         }
     }
     return(true);
 }