#if !NET_2_1
web_request.ContentLength = (int) buffer.Length;
#endif
+
+#if NET_2_1
+ // We can verify cross domain access policy
+ // with full set of headers and target URL.
+ if (!CrossDomainAccessManager.Current.IsAllowed (destination, web_request.Headers.AllKeys))
+ throw new InvalidOperationException (String.Format ("Cross domain web service access to {0} is not allowed", destination));
+#endif
+
Stream requestStream = web_request.EndGetRequestStream (web_request.BeginGetRequestStream (null, null));
requestStream.Write (buffer.GetBuffer (), 0, (int) buffer.Length);
requestStream.Close ();
+2009-03-04 Atsushi Enomoto <atsushi@ximian.com>
+
+ * CrossDomainAccessManager.cs : replace reflection-based
+ Uri retrieval with actually working one.
+
2009-03-04 Atsushi Enomoto <atsushi@ximian.com>
* CrossDomainAccessManager.cs : 2.1 WebRequest misses some
static Uri GetApplicationDocumentUri ()
{
- var assembly = Assembly.Load ("System.Windows.Browser, Version=2.0.5.0, Culture=Neutral, PublicKeyToken=7cec85d7bea7798e");
+ var assembly = Assembly.Load ("System.Windows, Version=2.0.5.0, Culture=Neutral, PublicKeyToken=7cec85d7bea7798e");
if (assembly == null)
- throw new InvalidOperationException ("Can not load System.Windows.Browser");
+ throw new InvalidOperationException ("Can not load System.Windows.dll");
- var type = assembly.GetType ("System.Windows.Browser.HtmlPage");
+ var type = assembly.GetType ("System.Windows.Interop.PluginHost");
if (type == null)
throw new InvalidOperationException ("Can not get HtmlPage");
- object document = type.GetProperty ("Document").GetValue (null, null);
- return (Uri) document.GetType ().GetProperty ("DocumentUri").GetValue (document, null);
+ var prop = type.GetProperty ("RootUri");
+ return (Uri) prop.GetValue (null, null);
}
public static CrossDomainAccessManager CreateForUri (Uri applicationUri)
public bool IsAllowed (Uri uri, params string [] headerKeys)
{
-
if (uri.Host == ApplicationUri.Host)
return true;
}
else if (Domain != null) {
}
+Console.WriteLine ("##### Cross Domain Access Manager rejected '{0}' with headers {1}", uri, String.Join (",", headerKeys));
return false;
}
}