예제 #1
0
        private static bool IsAuthenticated(HeyHttpRequest request)
        {
            string authorization = request.GetHeader("Proxy-Authorization");

            if (!String.IsNullOrEmpty(authorization))
            {
                // Credentails are included.
                return(true);
            }

            return(false);
        }
예제 #2
0
        private static void Upgrade()
        {
            if (requestHeaders.Method != "GET")
            {
                throw new Exception("HTTP method must be 'GET'.");
            }

            // E.g.: Upgrade: websocket
            if (requestHeaders.GetHeader("Upgrade", "").ToLower() != "websocket")
            {
                throw new Exception("'Upgrade' header must be 'websocket'.");
            }

            // E.g.: Connection: keep-alive, Upgrade
            if (!requestHeaders.GetHeader("Connection", "").ToLower().Contains("upgrade"))
            {
                throw new Exception("'Connection' header must be 'upgrade'.");
            }

            SendResponseHeaders();
            ReadData();
        }
예제 #3
0
 private void ReadRequestContent()
 {
     using (FileStream logFileStream = File.OpenWrite(logFile.FullName))
     {
         if (request.GetHeader("Transfer-Encoding") == "chunked")
         {
             ReadChunkedRequestContent(logFileStream);
         }
         else
         {
             ReadNormalRequestContent(logFileStream);
         }
     }
 }