Example #1
0
        /// <summary>
        /// Fills the Request with the header values
        /// </summary>
        /// <param name="data">Input from network</param>
        private void ProcessHeader(char[] data)
        {
            bool replace = false;

            for (int i = 0; i < data.Length - 3; i++)
            {
                replace = false;

                switch (data[i].ToString() + data[i + 1] + data[i + 2])
                {
                case "%5C":
                    data[i]     = '\\';
                    data[i + 1] = '\0';
                    data[i + 2] = '\0';
                    replace     = true;
                    break;

                case "%2F":
                    data[i]     = '/';
                    data[i + 1] = '\0';
                    data[i + 2] = '\0';
                    replace     = true;
                    break;
                }

                if (replace)
                {
                    for (int x = i + 3; x < data.Length; x++)
                    {
                        if (data[x] != '\0')
                        {
                            data[x - 2] = data[x];
                            data[x]     = '\0';
                        }
                    }
                }
            }

            string content = new string(data);

            string[] lines = content.Split('\n');

            // Parse the first line of the request: "GET /path/ HTTP/1.1"
            string[] firstLineSplit = lines[0].Split(' ');
            _method = firstLineSplit[0];
            string[] path = firstLineSplit[1].Split('?');
            _url = path[0].Substring(1); // Substring to ignore the leading '/'

            _getArguments.Clear();
            if (path.Length > 1)
            {
                ProcessGETParameters(path[1]);
            }

            using (NeonMika.Util.Converter c = new NeonMika.Util.Converter())
            {
                Headers = c.ToHashtable(lines, ": ", 1);
            }
        }
Example #2
0
        /// <summary>
        /// Generated Key-Value-Hashtable for GET-Parameters
        /// </summary>
        /// <param name="value"></param>
        private void ProcessGETParameters(string parameters)
        {
            _getArguments = new Hashtable();
            string[] urlArguments = parameters.Split('&');

            using (NeonMika.Util.Converter c = new NeonMika.Util.Converter())
            {
                _getArguments = c.ToHashtable(urlArguments, "=");
            }
        }