// Atsushi Enomoto <atsushi@ximian.com>
// Jb Evain <jbevain@novell.com>
//
-// Copyright (C) 2007, 2009 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2007, 2009-2010 Novell, Inc (http://www.novell.com)
//
//
// note: the NotImplementedException are needed to match MS implementation
+ // note: MS documents a lot of thing for this type but, in truth, all happens
+ // in a type that derive from HttpWebRequest. In Moonlight case this is either
+ // * BrowserHttpWebRequest (browser stack) located in System.Windows.Browser.dll; or
+ // * System.Net.Browser.ClientHttpWebRequest (client stack) located in System.Windows.dll
+
public abstract class HttpWebRequest : WebRequest {
- private string accept;
- private string content_type;
private WebHeaderCollection headers;
protected HttpWebRequest ()
}
public string Accept {
- get { return accept; }
- set {
- if (String.IsNullOrEmpty (value))
- accept = null;
- else
- accept = value;
- }
+ get { return Headers [HttpRequestHeader.Accept]; }
+ // this header cannot be set directly inside the collection (hence the helper)
+ set { Headers.SetHeader ("accept", value); }
}
public virtual bool AllowReadStreamBuffering {
set { throw NotImplemented (); }
}
+ // new in SL4 RC
+ public virtual bool AllowWriteStreamBuffering {
+ get { throw NotImplemented (); }
+ set { throw NotImplemented (); }
+ }
+
public override string ContentType {
- get { return content_type; }
- set {
- if (String.IsNullOrEmpty (value))
- content_type = null;
- else
- content_type = value;
- }
+ get { return Headers [HttpRequestHeader.ContentType]; }
+ // this header cannot be set directly inside the collection (hence the helper)
+ set { Headers.SetHeader ("content-type", value); }
}
public virtual bool HaveResponse {
public override WebHeaderCollection Headers {
get {
if (headers == null)
- headers = new WebHeaderCollection ();
+ headers = new WebHeaderCollection (true);
return headers;
}
set {
- if (value == null)
- throw new NullReferenceException ();
- headers = value;
+ // note: this is not a field assignment but a copy (see unit tests)
+ // make sure everything we're supplied is valid...
+ string[] keys = value.AllKeys;
+ foreach (string header in keys) {
+ // anything bad will throw
+ WebHeaderCollection.ValidateHeader (header);
+ }
+ // ... before making those values our own
+ Headers.headers.Clear ();
+ foreach (string header in keys) {
+ headers [header] = value [header];
+ }
}
}
+ public virtual CookieContainer CookieContainer {
+ get { throw NotImplemented (); }
+ set { throw NotImplemented (); }
+ }
+
public override string Method {
get { throw NotImplemented (); }
set { throw NotImplemented (); }
get { throw NotImplemented (); }
}
+ // new in SL4 RC
+ public virtual bool SupportsCookieContainer {
+ get { return false; }
+ }
public override void Abort ()
{