Merge pull request #4618 from BrzVlad/feature-par-nrs
[mono.git] / mcs / class / System / System.Net.Configuration / NetConfigurationHandler.cs
old mode 100755 (executable)
new mode 100644 (file)
index a614975..59f6481
@@ -34,20 +34,21 @@ using System.Collections;
 using System.Configuration;
 #if (XML_DEP)
 using System.Xml;
+#else
+using XmlNode = System.Object;
 #endif
 
 namespace System.Net.Configuration
 {
        class NetConfigurationHandler : IConfigurationSectionHandler
        {
-#if (XML_DEP)
                public virtual object Create (object parent, object configContext, XmlNode section)
                {
+                       NetConfig config = new NetConfig ();
+#if (XML_DEP)
                        if (section.Attributes != null && section.Attributes.Count != 0)
                                HandlersUtil.ThrowException ("Unrecognized attribute", section);
 
-                       NetConfig config = new NetConfig ();
-
                        XmlNodeList reqHandlers = section.ChildNodes;
                        foreach (XmlNode child in reqHandlers) {
                                XmlNodeType ntype = child.NodeType;
@@ -72,19 +73,24 @@ namespace System.Net.Configuration
                                }
 
                                if (name == "httpWebRequest") {
-                                       string value = HandlersUtil.ExtractAttributeValue
-                                                               ("maximumResponseHeadersLength", child, false);
+                                       string max = HandlersUtil.ExtractAttributeValue
+                                                               ("maximumResponseHeadersLength", child, true);
+
+                                       // this one is just ignored
+                                       HandlersUtil.ExtractAttributeValue ("useUnsafeHeaderParsing", child, true);
 
                                        if (child.Attributes != null && child.Attributes.Count != 0)
                                                HandlersUtil.ThrowException ("Unrecognized attribute", child);
 
                                        try {
-                                               int val = Int32.Parse (value.Trim ());
-                                               if (val < -1)
-                                                       HandlersUtil.ThrowException ("Must be -1 or >= 0", child);
+                                               if (max != null) {
+                                                       int val = Int32.Parse (max.Trim ());
+                                                       if (val < -1)
+                                                               HandlersUtil.ThrowException ("Must be -1 or >= 0", child);
 
-                                               config.MaxResponseHeadersLength = val;
-                                       } catch (Exception e) {
+                                                       config.MaxResponseHeadersLength = val;
+                                               }
+                                       } catch {
                                                HandlersUtil.ThrowException ("Invalid int value", child);
                                        }
 
@@ -93,9 +99,9 @@ namespace System.Net.Configuration
 
                                HandlersUtil.ThrowException ("Unexpected element", child);
                        }
+#endif                 
 
                        return config;
                }
-#endif
        }
 }