Ejemplo n.º 1
0
        /// <summary>
        /// Class constructor which initializes used with an external ram 23K640
        /// </summary>
        /// <param name="Connection">Current socket</param>
        /// <param name="RamBuffer">RamString passed</param>
        /// <param name="DataSize">Available read size</param>
        /// <param name="FilesPath">Files storage path</param>
        public HttpRequest(Socket Connection, RamString RamBuffer, int DataSize, string FilesPath)
        {
            this.ram_string   = RamBuffer;
            this.use_ram      = true;
            this.files_path   = FilesPath;
            this.host_address = ((IPEndPoint)Connection.RemoteEndPoint).Address.ToString();
            this.connection   = Connection;

            byte[] b = new byte[1];

            ram_string.BeginWrite(0);
            for (int i = 0; i < DataSize; i++)
            {
                Connection.Receive(b, 0, b.Length, SocketFlags.None);
                ram_string.WriteSingle(b[0]);
            }
            ram_string.EndWrite();

            if (this.ram_string.IndexOf("GET") >= 0)
            {
                this.http_method = "GET";
            }
            else if (this.ram_string.IndexOf("POST") >= 0)
            {
                this.http_method = "POST";
            }
            else
            {
                throw new Exception("Only GET And POST Methods Are Supported");
            }
            this.request_length = this.ram_string.Length;
        }
Ejemplo n.º 2
0
        private bool ram_stream_verification()
        {
            string test_chars = "t e s t 0 1 2 3 4 5 6 7 8 9";

            ram_buffer.BeginWrite(0);
            for (int i = 0; i < test_chars.Length; i++)
            {
                ram_buffer.WriteSingle(test_chars[i]);
            }
            ram_buffer.EndWrite();
            int counter = 0;

            for (int i = 0; i < test_chars.Length; i++)
            {
                if (ram_buffer[i] == test_chars[i])
                {
                    ++counter;
                }
            }
            return(counter == test_chars.Length);
        }