diff options
-rw-r--r-- | mcs/class/System.Web/System.Web/HeadersCollection.cs | 24 | ||||
-rw-r--r-- | mcs/class/System.Web/Test/System.Web/HttpRequestTest.cs | 24 |
2 files changed, 48 insertions, 0 deletions
diff --git a/mcs/class/System.Web/System.Web/HeadersCollection.cs b/mcs/class/System.Web/System.Web/HeadersCollection.cs index b2a1c73b7fc..fe2cf558afa 100644 --- a/mcs/class/System.Web/System.Web/HeadersCollection.cs +++ b/mcs/class/System.Web/System.Web/HeadersCollection.cs @@ -39,6 +39,30 @@ namespace System.Web { } + public override void Add (string name, string value) + { + if (IsReadOnly) + throw new PlatformNotSupportedException (); + + base.Set (name, value); + } + + public override void Set (string name, string value) + { + if (IsReadOnly) + throw new PlatformNotSupportedException (); + + base.Set (name, value); + } + + public override void Remove (string name) + { + if (IsReadOnly) + throw new PlatformNotSupportedException (); + + base.Remove (name); + } + protected override void InsertInfo() { HttpWorkerRequest worker_request = _request.WorkerRequest; diff --git a/mcs/class/System.Web/Test/System.Web/HttpRequestTest.cs b/mcs/class/System.Web/Test/System.Web/HttpRequestTest.cs index 9ee9ebe1a1e..15d1f137a0a 100644 --- a/mcs/class/System.Web/Test/System.Web/HttpRequestTest.cs +++ b/mcs/class/System.Web/Test/System.Web/HttpRequestTest.cs @@ -254,6 +254,30 @@ namespace MonoTests.System.Web { { HttpContext.Current.Request.MapPath ("Web.config", "something", false); } + + [Test] + [ExpectedException (typeof (PlatformNotSupportedException))] + public void ReadOnlyHeadersAdd () + { + var r = new HttpRequest ("file", "http://www.gnome.org", "key=value&key2=value%32second"); + r.Headers.Add ("a","a"); + } + + [Test] + [ExpectedException (typeof (PlatformNotSupportedException))] + public void ReadOnlyHeadersSet () + { + var r = new HttpRequest ("file", "http://www.gnome.org", "key=value&key2=value%32second"); + r.Headers.Set ("a","a"); + } + + [Test] + [ExpectedException (typeof (PlatformNotSupportedException))] + public void ReadOnlyHeadersRemove () + { + var r = new HttpRequest ("file", "http://www.gnome.org", "key=value&key2=value%32second"); + r.Headers.Remove ("a"); + } } [TestFixture] |