using System.Threading.Tasks;
using System.Net;
using System.Linq;
+using System.Text;
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;
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");
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]
Assert.AreEqual ("Content-MD5: AwU=\r\n", headers.ToString (), "#1");
}
+ [Test]
+ public void Headers_ContentLength ()
+ {
+ var content = new StreamContent (new MemoryStream (Encoding.UTF8.GetBytes ("test")));
+ Assert.AreEqual ("", content.Headers.ToString ());
+ var length = content.Headers.ContentLength;
+ Assert.AreEqual ("Content-Length: 4\r\n", content.Headers.ToString ());
+ }
+
[Test]
public void Headers_Invalid ()
{