CookieContainer.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. //
  2. // System.Net.CookieContainer
  3. //
  4. // Author:
  5. // Lawrence Pit ([email protected])
  6. //
  7. using System;
  8. using System.Collections;
  9. using System.Runtime.Serialization;
  10. namespace System.Net
  11. {
  12. [Serializable]
  13. public class CookieContainer
  14. {
  15. private int count;
  16. private int capacity;
  17. private int perDomainCapacity;
  18. private int maxCookieSize;
  19. // ctors
  20. public CookieContainer () : this (DefaultCookieLimit)
  21. {
  22. }
  23. public CookieContainer (int capacity) :
  24. this (capacity, DefaultPerDomainCookieLimit, DefaultCookieLengthLimit)
  25. {
  26. }
  27. public CookieContainer (int capacity, int perDomainCapacity, int maxCookieSize)
  28. {
  29. this.capacity = capacity;
  30. this.perDomainCapacity = perDomainCapacity;
  31. this.maxCookieSize = maxCookieSize;
  32. this.count = 0;
  33. }
  34. // fields
  35. public const int DefaultCookieLengthLimit = 4096;
  36. public const int DefaultCookieLimit = 300;
  37. public const int DefaultPerDomainCookieLimit = 20;
  38. // properties
  39. public int Count {
  40. get { return count; }
  41. }
  42. public int Capacity {
  43. get { return capacity; }
  44. set {
  45. if ((value <= 0) ||
  46. (value < perDomainCapacity && perDomainCapacity != Int32.MaxValue))
  47. throw new ArgumentOutOfRangeException ("value");
  48. if (value < maxCookieSize)
  49. maxCookieSize = value;
  50. capacity = value;
  51. }
  52. }
  53. public int MaxCookieSize {
  54. get { return maxCookieSize; }
  55. set {
  56. if (value <= 0)
  57. throw new ArgumentOutOfRangeException ("value");
  58. maxCookieSize = value;
  59. }
  60. }
  61. public int PerDomainCapacity {
  62. get { return perDomainCapacity; }
  63. set {
  64. if ((value <= 0) ||
  65. (value > DefaultCookieLimit && value != Int32.MaxValue))
  66. throw new ArgumentOutOfRangeException ("value");
  67. if (value < perDomainCapacity)
  68. perDomainCapacity = value;
  69. perDomainCapacity = value;
  70. }
  71. }
  72. [MonoTODO]
  73. public void Add (Cookie cookie)
  74. {
  75. throw new NotImplementedException ();
  76. }
  77. [MonoTODO]
  78. public void Add (CookieCollection cookies)
  79. {
  80. throw new NotImplementedException ();
  81. }
  82. [MonoTODO]
  83. public void Add (Uri uri, Cookie cookie)
  84. {
  85. throw new NotImplementedException ();
  86. }
  87. [MonoTODO]
  88. public void Add (Uri uri, CookieCollection cookies)
  89. {
  90. throw new NotImplementedException ();
  91. }
  92. [MonoTODO]
  93. public string GetCookieHeader (Uri uri)
  94. {
  95. throw new NotImplementedException ();
  96. }
  97. [MonoTODO]
  98. public CookieCollection GetCookies (Uri uri)
  99. {
  100. throw new NotImplementedException ();
  101. }
  102. [MonoTODO]
  103. public void SetCookies (Uri uri, string cookieHeader)
  104. {
  105. throw new NotImplementedException ();
  106. }
  107. } // CookieContainer
  108. } // System.Net