예제 #1
0
        public void StartTest(int block, int count)
        {
            var srcDir = string.Format("{0}\\WebServerTest", TestUtil.ProjectDirectory());

            //こちらの自作cat.exeでは、200Mbyteまでしか対応できていない
            var execProcess = new ExecProcess(string.Format("{0}\\cat.exe",srcDir), "", srcDir,null);

            var buf = new byte[block];
            for (var b = 0; b < block; b++) {
                buf[b] = (byte)b;
            }
            var inputStream = new WebStream(block*count);
            for (var i = 0; i < count; i++) {
                inputStream.Add(buf);
            }
            WebStream outputStream;
            execProcess.Start(inputStream,out outputStream);

            for (var i = 0; i < count; i++) {
                var len = outputStream.Read(buf, 0, buf.Length);
                Assert.AreEqual(len, block);
                if(i==0){
                    Assert.AreEqual(buf[0], 0);
                    Assert.AreEqual(buf[1], 1);
                    Assert.AreEqual(buf[2], 2);

                }
            }

            outputStream.Dispose();
            inputStream.Dispose();
        }
예제 #2
0
파일: Cgi.cs 프로젝트: schifflee/bjd5
        public bool Exec(Target target, string param, Env env, WebStream inputStream, out WebStream outputStream, int cgiTimeout)
        {
            var cmd = target.CgiCmd;

            if (cmd == null)
            {
                outputStream = new WebStream(-1);
                outputStream.Add(Encoding.ASCII.GetBytes("cmd==null"));
                return(false);
            }
            if (cmd.ToUpper().IndexOf("COMSPEC") == 0)
            {
                cmd = Environment.GetEnvironmentVariable("ComSpec");
                // /cがウインドウクローズのために必要
                param = "/c " + param;
            }
            else if (cmd.ToUpper().IndexOf("CMD.EXE") != -1)
            {
                cmd = target.FullPath;
            }
            else
            {
                param = string.Format("{0} {1}", Path.GetFileName(target.FullPath), param);
            }

            var execProcess = new ExecProcess(cmd, param, Path.GetDirectoryName(target.FullPath), env);

            return(execProcess.Start(inputStream, out outputStream));
        }
예제 #3
0
파일: Cgi.cs 프로젝트: jsakamoto/bjd5
        public bool Exec(Target target, string param, Env env, WebStream inputStream, out WebStream outputStream, int cgiTimeout)
        {
            var cmd = target.CgiCmd;
            if(cmd==null){
                outputStream = new WebStream(-1);
                outputStream.Add(Encoding.ASCII.GetBytes("cmd==null"));
                return false;
            }
            if (cmd.ToUpper().IndexOf("COMSPEC") == 0) {
                cmd = Environment.GetEnvironmentVariable("ComSpec");
                // /cがウインドウクローズのために必要
                param = "/c " + param;
            } else if (cmd.ToUpper().IndexOf("CMD.EXE") != -1) {
                cmd = target.FullPath;
            } else {
                param = string.Format("{0} {1}", Path.GetFileName(target.FullPath), param);
            }

            var execProcess = new ExecProcess(cmd, param, Path.GetDirectoryName(target.FullPath),env);
            return execProcess.Start(inputStream,out outputStream);
        }