예제 #1
0
        /// <summary>
        /// Checks for ".ssp" extension and if its a match than it will return true, otherwise it will
        /// return false.
        /// </summary>
        /// <param name="request">this reprezents the requestStructs</param>
        /// <returns>returns true if was found and false if it didnt.</returns>
        public static bool verifyFileExtension(RequestStruct request)
        {
            string parse = request.url;

            string extension = parse.Substring(Math.Max(0, parse.Length - NumOfCharacters));

            if (extension == SspExtension)
            {
                return true;
            }

            return false;
        }
예제 #2
0
        /// <summary>
        /// This method searches for the file requested by the browser. if it does not exist than it will
        /// send an error page(file not found).
        /// </summary>
        /// <param name="RequestReference"> reference struct with all information about the new request</param>
        /// <param name="ResponseReference">reference struct with information to be send.</param>
        public override void OnResponse(ref RequestStruct RequestReference, ref ResponseStruct ResponseReference)
        {
            string path = this.Container  + RequestReference.url.Replace("/", "\\");
            if (Directory.Exists(path))
            {
                if(File.Exists(path + FileName))
                {
                    path += "\\"+ FileName;
                }
            }

            if (File.Exists(path))
            {

                ResponseReference.newFileStream = File.Open(path, FileMode.Open);

                RequestReference.headers["Content-type"] = "text";

            }
            else
            {

                ResponseReference.status = (int)ResponseState.NOT_FOUND;

                string bodyStr = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n";
                bodyStr += "<HTML><HEAD>\n";
                bodyStr += "<title>IIS Detailed Error - 404 - Not Found</title> \n";
                bodyStr += "<META http-equiv=Content-Type content=\"text/html; charset=windows-1252\">\n";
                bodyStr += "</HEAD>\n";
                bodyStr += "<BODY>\n";
                bodyStr += "<fieldset><legend>Error Summary</legend>\n";
                bodyStr += "<h2>HTTP Error 404 - Not Found</h2>\n";
                bodyStr += "<h3>The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.</h3>\n";
                bodyStr += "</fieldset>\n ";
                bodyStr += "</BODY></HTML>\n";

                ResponseReference.DataInBody = Encoding.ASCII.GetBytes(bodyStr);

            }
        }
예제 #3
0
 /// <summary>
 /// method to be overriten by the child class
 /// </summary>
 /// <param name="RequestReference"></param>
 /// <param name="ResponseReference"></param>
 public abstract void OnResponse(ref RequestStruct RequestReference, ref ResponseStruct ResponseReference);