Browse Source

[system.net.http] Handle Content-Disposition in textual form as well.

Marek Safar 11 years ago
parent
commit
ebe2a3df1d

+ 1 - 0
mcs/class/System.Net.Http/System.Net.Http.Headers/HttpHeaders.cs

@@ -96,6 +96,7 @@ namespace System.Net.Http.Headers
 				HeaderInfo.CreateSingle<AuthenticationHeaderValue> ("Authorization", AuthenticationHeaderValue.TryParse, HttpHeaderKind.Request),
 				HeaderInfo.CreateSingle<CacheControlHeaderValue> ("Cache-Control", CacheControlHeaderValue.TryParse, HttpHeaderKind.Request | HttpHeaderKind.Response),
 				HeaderInfo.CreateMulti<string> ("Connection", CollectionParser.TryParse, HttpHeaderKind.Request | HttpHeaderKind.Response),
+				HeaderInfo.CreateSingle<ContentDispositionHeaderValue> ("Content-Disposition", ContentDispositionHeaderValue.TryParse, HttpHeaderKind.Content),
 				HeaderInfo.CreateMulti<string> ("Content-Encoding", CollectionParser.TryParse, HttpHeaderKind.Content),
 				HeaderInfo.CreateMulti<string> ("Content-Language", CollectionParser.TryParse, HttpHeaderKind.Content),
 				HeaderInfo.CreateSingle<long> ("Content-Length", Parser.Long.TryParse, HttpHeaderKind.Content),

+ 8 - 0
mcs/class/System.Net.Http/Test/System.Net.Http/StreamContentTest.cs

@@ -222,6 +222,7 @@ namespace MonoTests.System.Net.Http
 			Assert.AreEqual (330, scm.Headers.ContentLength, "#2");
 
 			headers.Allow.Add ("a1");
+			headers.ContentDisposition = new ContentDispositionHeaderValue ("cd1");
 			headers.ContentEncoding.Add ("ce1");
 			headers.ContentLanguage.Add ("cl1");
 			headers.ContentLength = 23;
@@ -234,6 +235,12 @@ namespace MonoTests.System.Net.Http
 
 
 			headers.Add ("allow", "a2");
+			try {
+				headers.Add ("content-disposition", "cd2");
+				Assert.Fail ("content-disposition");
+			} catch (FormatException) {
+			}
+
 			headers.Add ("content-encoding", "ce3");
 			headers.Add ("content-language", "cl2");
 
@@ -307,6 +314,7 @@ namespace MonoTests.System.Net.Http
 			Assert.AreEqual (new MediaTypeHeaderValue ("multipart/*"), headers.ContentType);
 			Assert.AreEqual (new DateTimeOffset (DateTime.Today), headers.Expires);
 			Assert.AreEqual (new DateTimeOffset (DateTime.Today), headers.LastModified);
+			Assert.AreEqual (new ContentDispositionHeaderValue ("cd1"), headers.ContentDisposition);
 		}
 
 		[Test]