private void HandleRtmpt()
 {
     if (this._rtmptRequest == null)
     {
         string             str5;
         BufferStreamReader reader     = new BufferStreamReader(this._readBuffer);
         string[]           strArray   = reader.ReadLine().Split(new char[] { ' ' });
         string             httpMethod = strArray[0];
         string             pattern    = strArray[1];
         int startIndex = 0;
         while ((startIndex = pattern.IndexOf("%", startIndex)) != -1)
         {
             pattern = pattern.Substring(0, startIndex) + Uri.HexUnescape(pattern, ref startIndex) + pattern.Substring(startIndex);
         }
         string    protocol = strArray[2];
         Hashtable headers  = new Hashtable();
         string    str6     = null;
         while (((str5 = reader.ReadLine()) != null) && (str5 != string.Empty))
         {
             if ((str6 != null) && char.IsWhiteSpace(str5[0]))
             {
                 Hashtable hashtable2;
                 object    obj2;
                 (hashtable2 = headers)[obj2 = str6] = hashtable2[obj2] + str5;
             }
             else
             {
                 int index = str5.IndexOf(":");
                 if (index != -1)
                 {
                     str6 = str5.Substring(0, index);
                     string str7 = str5.Substring(index + 1).Trim();
                     headers[str6] = str7;
                 }
                 else
                 {
                     break;
                 }
             }
         }
         this._rtmptRequest = new RtmptRequest(this, pattern, protocol, httpMethod, headers);
     }
     if (this._readBuffer.Remaining == this._rtmptRequest.ContentLength)
     {
         RtmptEndpoint endpoint = this.Endpoint.GetMessageBroker().GetEndpoint("__@fluorinertmpt") as RtmptEndpoint;
         if (endpoint != null)
         {
             this._readBuffer.Compact();
             this._rtmptRequest.Data = this._readBuffer;
             this._readBuffer        = ByteBuffer.Allocate(0x1000);
             this._readBuffer.Flip();
             endpoint.Service(this._rtmptRequest);
             this._rtmptRequest = null;
         }
     }
 }
        public static RtmptRequest DecodeBuffer(RtmpConnection connection, ByteBuffer stream)
        {
            RtmpContext context  = connection.Context;
            int         position = (int)stream.Position;

            try
            {
                BufferStreamReader sr      = new BufferStreamReader(stream);
                string             request = sr.ReadLine();
                string[]           tokens  = request.Split(new char[] { ' ' });
                string             method  = tokens[0];
                string             url     = tokens[1];
                // Decode all encoded parts of the URL using the built in URI processing class
                int i = 0;
                while ((i = url.IndexOf("%", i)) != -1)
                {
                    url = url.Substring(0, i) + Uri.HexUnescape(url, ref i) + url.Substring(i);
                }
                // Lets just make sure we are using HTTP, thats about all I care about
                string protocol = tokens[2];// "HTTP/"
                //Read headers
                Hashtable headers = new Hashtable();
                string    line;
                string    name = null;
                while ((line = sr.ReadLine()) != null && line != string.Empty)
                {
                    // If the value begins with a space or a hard tab then this
                    // is an extension of the value of the previous header and
                    // should be appended
                    if (name != null && Char.IsWhiteSpace(line[0]))
                    {
                        headers[name] += line;
                        continue;
                    }
                    // Headers consist of [NAME]: [VALUE] + possible extension lines
                    int firstColon = line.IndexOf(":");
                    if (firstColon != -1)
                    {
                        name = line.Substring(0, firstColon);
                        string value = line.Substring(firstColon + 1).Trim();
                        headers[name] = value;
                    }
                    else
                    {
                        //400, "Bad header: " + line
                        break;
                    }
                }
                RtmptRequest rtmptRequest = new RtmptRequest(connection, url, protocol, method, headers);
                if (stream.Remaining == rtmptRequest.ContentLength)
                {
                    stream.Compact();
                    rtmptRequest.Data = ByteBuffer.Wrap(stream.ToArray());
                    stream.Flip();
                    return(rtmptRequest);
                }
                else
                {
                    // Move the position back to the start
                    stream.Position = position;
                }
            }
            catch
            {
                // Move the position back to the start
                stream.Position = position;
                throw;
            }
            return(null);
        }