diff options
author | Marcos Henrich <marcoshenrich@gmail.com> | 2016-01-29 12:35:27 +0300 |
---|---|---|
committer | Marcos Henrich <marcoshenrich@gmail.com> | 2016-01-29 12:35:27 +0300 |
commit | d56d04602506540487506d0ee9875a635090877c (patch) | |
tree | 9edbec8a0d25931d128aefa36d9908bc05fe8115 | |
parent | 70de6ee10818f7c68268a756844c7a38f3c91e79 (diff) | |
parent | 1180f64665e4aa14994126abacc610ee032dadd2 (diff) |
Merge pull request #2531 from esdrubal/systemweb
[System.Web] HeadersCollection read only exception
-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] |