Esempio n. 1
0
        /* This method will process a script file and send the results as the
         * body of the response */
        private void _GenerateScriptResult(Socket socket, string path, Dictionary <string, string> requestParameters)
        {
            /* get a script result from the script processor using the request parameter dictionary */
            ScriptResult result = _scriptProcessor.ProcessScript(path, requestParameters);

            /* if the result was an error, send an HTTP Error (500) along with a summary of
             * what went wrong as the body */
            if (result.Error)
            {
                _SendResponse(socket, Encoding.ASCII.GetBytes(result.Result), "text/html; charset=utf8", ResponseType.ERROR);
            }
            else
            {
                /* send a response with the results of the script evaluation */
                _SendResponse(socket, Encoding.ASCII.GetBytes(result.Result), "text/html; charset=utf8", ResponseType.OK);
            }
        }
Esempio n. 2
0
        public ScriptResult ProcessScript(Stream stream, IDictionary <string, string> requestParameters)
        {
            sb = new StringBuilder();
            CscriptProcessor scriptProcessor = new CscriptProcessor();
            List <String>    inputLines      = new List <String>();

            StreamReader reader = new StreamReader(stream);
            string       line   = null;

            while ((line = reader.ReadLine()) != null)
            {
                inputLines.Add(line);
            }

            String parsedScript = ProcessInput(inputLines);

            stream = createStream(parsedScript);

            ScriptResult result = scriptProcessor.ProcessScript(stream, requestParameters);

            return(result);
        }