Beispiel #1
0
        public void BuildingRecords()
        {
            // After supplying the factory with a record's bytes, the same record must come out
            var beginRec = new BeginRequestRecord(1);

            beginRec.Role = Role.Responder;
            var stdinRec = new StdinRecord(1);

            stdinRec.Contents.WriteByte(0);
            stdinRec.Contents.WriteByte(0);

            BeginRequestRecord builtBeginReqRecord = null;
            StdinRecord        builtStdinRecord    = null;

            var recFactory = new RecordFactory();

            foreach (var recData in beginRec.GetBytes())
            {
                builtBeginReqRecord = (BeginRequestRecord)recFactory.Read(recData).SingleOrDefault();
            }
            foreach (var recData in stdinRec.GetBytes())
            {
                builtStdinRecord = (StdinRecord)recFactory.Read(recData).SingleOrDefault();
            }

            Assert.AreEqual(beginRec, builtBeginReqRecord);
            Assert.AreEqual(stdinRec, builtStdinRecord);
        }
Beispiel #2
0
        public void NewAllTypesOfRecords()
        {
            RecordBase rec = new BeginRequestRecord(1);

            Assert.AreEqual(RecordType.FCGIBeginRequest, rec.RecordType);

            rec = new EndRequestRecord(1);
            Assert.AreEqual(RecordType.FCGIEndRequest, rec.RecordType);

            rec = new StdinRecord(1);
            Assert.AreEqual(RecordType.FCGIStdin, rec.RecordType);

            rec = new StdoutRecord(1);
            Assert.AreEqual(RecordType.FCGIStdout, rec.RecordType);

            rec = new StderrRecord(1);
            Assert.AreEqual(RecordType.FCGIStderr, rec.RecordType);

            rec = new ParamsRecord(1);
            Assert.AreEqual(RecordType.FCGIParams, rec.RecordType);

            rec = new BeginRequestRecord(1);
            Assert.AreEqual(RecordType.FCGIBeginRequest, rec.RecordType);

            rec = new DataRecord(1);
            Assert.AreEqual(RecordType.FCGIData, rec.RecordType);
        }
        public void SendBeginRequest(Role applicationRole, bool applicationMustCloseConnection)
        {
            var beginRec = new BeginRequestRecord(RequestId);

            beginRec.Role = applicationRole;
            beginRec.ApplicationMustCloseConnection = applicationMustCloseConnection;
            Send(beginRec);
        }
        public void SetAndGetAppMustClose()
        {
            var rec = new BeginRequestRecord(1);

            rec.ApplicationMustCloseConnection = true;
            Assert.AreEqual(true, rec.ApplicationMustCloseConnection);

            rec.ApplicationMustCloseConnection = false;
            Assert.AreEqual(false, rec.ApplicationMustCloseConnection);
        }
Beispiel #5
0
        public void BeginRequestRecordInBlocks()
        {
            var beginRec = new BeginRequestRecord(1);

            BeginRequestRecord builtRecord = null;

            var byteReader = new RecordFactory();

            foreach (var recData in beginRec.GetBytes())
            {
                builtRecord = (BeginRequestRecord)byteReader.Read(recData).SingleOrDefault();
            }

            Assert.AreNotEqual(null, builtRecord);
            Assert.AreEqual(beginRec, builtRecord);
        }
        public void SetAndGetRole()
        {
            var rec = new BeginRequestRecord(1);

            var role = Role.Authorizer;

            rec.Role = role;
            Assert.AreEqual(role, rec.Role);

            role     = Role.Filter;
            rec.Role = role;
            Assert.AreEqual(role, rec.Role);

            role     = Role.Responder;
            rec.Role = role;
            Assert.AreEqual(role, rec.Role);
        }
Beispiel #7
0
 /// <summary>
 /// Initializes a FastCgi Request over a socket that represents the point of view of the application (not of the webserver).
 /// All received records' contents' are stored in memory up to 2kB of data, all data that exceeds this limit is stored in secondary storage.
 /// </summary>
 public ApplicationSocketRequest(Socket s, BeginRequestRecord beginRequestRecord)
     : this(s)
 {
     AddReceivedRecord(beginRequestRecord);
 }