示例#1
0
        private static void IterateHtppHeaders(HttpWebResponse response, ref StringBuilder builder, HeaderRowEvent headerRowCallback = null)
        {
            WebHeaderCollection headers = response.Headers;

            builder.Append("HTTP/");
            builder.Append(response.ProtocolVersion);
            builder.Append(" ");
            builder.Append((int)response.StatusCode);
            builder.Append(" ");
            builder.Append(response.StatusDescription);
            builder.Append("\r\n");

            if (headerRowCallback != null)
                headerRowCallback(ref builder);

            //if (str != null)
            //{
            //    builder.Append(str).Append("\r\n");
            //}
            for (int i = 0; i < headers.Count; i++)
            {
                string key = headers.GetKey(i);
                string str3 = headers.Get(i);
                if (key != null && key.Length != 0)//key isn't blank string
                {
                    builder.Append(key);
                    builder.Append(": ");
                    builder.Append(str3).Append("\r\n");

                    if (headerRowCallback != null)
                        headerRowCallback(ref builder);
                }
            }
            builder.Append("\r\n");

            if (headerRowCallback != null)
                headerRowCallback(ref builder);// this should also be returned
        }
示例#2
0
        private static void IterateHtppHeaders(HttpWebResponse response, ref StringBuilder builder, HeaderRowEvent headerRowCallback = null)
        {
            WebHeaderCollection headers = response.Headers;

            builder.Append("HTTP/");
            builder.Append(response.ProtocolVersion);
            builder.Append(" ");
            builder.Append((int)response.StatusCode);
            builder.Append(" ");
            builder.Append(response.StatusDescription);
            builder.Append("\r\n");

            if (headerRowCallback != null)
            {
                headerRowCallback(ref builder);
            }

            //if (str != null)
            //{
            //    builder.Append(str).Append("\r\n");
            //}
            for (int i = 0; i < headers.Count; i++)
            {
                string key  = headers.GetKey(i);
                string str3 = headers.Get(i);
                if (key != null && key.Length != 0)//key isn't blank string
                {
                    builder.Append(key);
                    builder.Append(": ");
                    builder.Append(str3).Append("\r\n");

                    if (headerRowCallback != null)
                    {
                        headerRowCallback(ref builder);
                    }
                }
            }
            builder.Append("\r\n");

            if (headerRowCallback != null)
            {
                headerRowCallback(ref builder);// this should also be returned
            }
        }