Guest User

mono WebConnection useUnsafeHeaderParsing

a guest
Jun 8th, 2012
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. diff --git a/mcs/class/System/System.Net/WebConnection.cs b/mcs/class/System/System.Net/WebConnection.cs
  2. index b8e28b5..a4d2aad 100644
  3. --- a/mcs/class/System/System.Net/WebConnection.cs
  4. +++ b/mcs/class/System/System.Net/WebConnection.cs
  5. @@ -30,6 +30,8 @@
  6.  
  7. using System.IO;
  8. using System.Collections;
  9. +using System.Configuration;
  10. +using System.Net.Configuration;
  11. using System.Net.Sockets;
  12. using System.Reflection;
  13. using System.Security.Cryptography.X509Certificates;
  14. @@ -86,15 +88,32 @@ namespace System.Net
  15.  
  16. #if MONOTOUCH
  17. static MethodInfo start_wwan;
  18. +#endif
  19. +
  20. +#if !NET_2_1
  21. + static bool useUnsafeHeaderParsing = false;
  22. + static string configKey = "system.net/settings";
  23. +#endif
  24.  
  25. static WebConnection ()
  26. {
  27. +#if MONOTOUCH
  28. Type type = Type.GetType ("MonoTouch.ObjCRuntime.Runtime, monotouch");
  29. if (type != null)
  30. start_wwan = type.GetMethod ("StartWWAN", new Type [] { typeof (System.Uri) });
  31. - }
  32. #endif
  33.  
  34. +#if !NET_2_1
  35. +#if NET_2_0 && CONFIGURATION_DEP
  36. + SettingsSection s = ConfigurationManager.GetSection(configKey) as SettingsSection;
  37. +
  38. + if (s != null) {
  39. + useUnsafeHeaderParsing = s.HttpWebRequest.UseUnsafeHeaderParsing;
  40. + }
  41. +#endif
  42. +#endif
  43. + }
  44. +
  45. public WebConnection (WebConnectionGroup group, ServicePoint sPoint)
  46. {
  47. this.sPoint = sPoint;
  48. @@ -458,7 +477,7 @@ namespace System.Net
  49. exc = e;
  50. }
  51.  
  52. - if (exc != null || pos == -1) {
  53. + if (exc != null || (!useUnsafeHeaderParsing && pos == -1)) {
  54. cnc.HandleError (WebExceptionStatus.ServerProtocolViolation, exc, "ReadDone4");
  55. return;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment