Ejemplo n.º 1
0
        private void HTTPHeaderParse(string Header)
        {
            #region HTTP HEADER REQUEST & RESPONSE

            HTTPHeaderField HHField;
            string          HTTPfield = null;
            int             Index;
            string          buffer;
            for (int f = (int)HTTPHeaderField.Accept; f < (int)HTTPHeaderField.HEADER_VALUE_MAX_PLUS_ONE; f++)
            {
                HHField   = (HTTPHeaderField)f;
                HTTPfield = null;
                if (!HeaderFieldToStrings.TryGetValue(HHField, out HTTPfield) || HTTPField == null)
                {
                    HTTPfield = "\n" + HHField.ToString().Replace('_', '-') + ": ";
                    HeaderFieldToStrings.Add(HHField, HTTPfield);
                }

                // Si le champ n'est pas pr?sent dans la requ?te, on passe au champ suivant
                Index = Header.IndexOf(HTTPfield, StringComparison.OrdinalIgnoreCase);
                if (Index == -1)
                {
                    continue;
                }

                buffer = Header.Substring(Index + HTTPfield.Length);
                Index  = buffer.IndexOf("\r\n", StringComparison.OrdinalIgnoreCase);
                if (Index == -1)
                {
                    m_StrHTTPField[HHField] = buffer.Trim();
                }
                else
                {
                    m_StrHTTPField[HHField] = buffer.Substring(0, Index).Trim();
                }

                if (m_StrHTTPField[HHField].Length == 0)
                {
                    XmlRpcUtil.log(XmlRpcUtil.XMLRPC_LOG_LEVEL.WARNING, "HTTP HEADER: field \"{0}\" has a length of 0", HHField.ToString());
                }
                XmlRpcUtil.log(XmlRpcUtil.XMLRPC_LOG_LEVEL.DEBUG, "HTTP HEADER: Index={0} | champ={1} = {2}", f, HTTPfield.Substring(1), m_StrHTTPField[HHField]);
            }

            #endregion
        }
Ejemplo n.º 2
0
        private void parseHeader(string header)
        {
            HttpHeaderField HHField;
            string          HTTPfield = null;
            int             index;
            string          buffer;

            for (int f = (int)HttpHeaderField.Accept; f < (int)HttpHeaderField.HEADER_VALUE_MAX_PLUS_ONE; f++)
            {
                HHField   = (HttpHeaderField)f;
                HTTPfield = null;
                if (!HeaderFieldToStrings.TryGetValue(HHField, out HTTPfield) || HTTPField == null)
                {
                    HTTPfield = "\n" + HHField.ToString().Replace('_', '-') + ": ";
                    HeaderFieldToStrings.Add(HHField, HTTPfield);
                }

                index = IndexOfNoCase(header, HTTPfield);
                if (index == -1)
                {
                    continue;
                }

                buffer = header.Substring(index + HTTPfield.Length);
                index  = buffer.IndexOf("\r\n");
                if (index == -1)
                {
                    m_StrHTTPField[HHField] = buffer.Trim();
                }
                else
                {
                    m_StrHTTPField[HHField] = buffer.Substring(0, index).Trim();
                }

                if (m_StrHTTPField[HHField].Length == 0)
                {
                    Console.WriteLine("HTTP HEADER: field \"{0}\" has a length of 0", HHField.ToString());
                }
                Debug.WriteLine("HTTP HEADER: Index={0} | champ={1} = {2}", f, HTTPfield.Substring(1), m_StrHTTPField[HHField]);
            }
        }